Search This Blog

To adblock users

Hello! If you see this, you are most likely using an ad blocker. (Or maybe you have JavaScript disabled. Or maybe my web server is down.) I have no problem with ad blockers; in fact I use one myself. If a site tries to deny me access unless I disable it, I just find a way to circumvent that. But if a site politely asks me to do so, but still allows access to the site, I disable it for the site. I am asking you to please do the same for this site. I can't make you, but I would appreciate it. Thank you! :-)

Sunday, March 04, 2012

playnotes.c

First post in a while! Anyway, I was playing around with libao, and I ended up creating a simple program that plays a string of notes on the command line. The only limitations I can think of are that all notes need to be the same length and there are no flats or sharps. There is also a clicking noise in between notes, but I kind of like this as it makes it so consecutive identical notes don't just sound like longer single notes.

The syntax is pretty simple. You run the program with a string of notes as the first argument, and an optional note length (in seconds) as the second argument. As for the string of notes, any letters from A to G play their respective notes, and + and - go up and down an octave respectively. Any other characters act as rests, pausing for the same amount of time as one note.

Here's a link to the source code: http://pastebin.com/4Bwr5hiv

Remember; you need libao (http://xiph.org/ao/) to compile this. Once that library is installed, compile it with gcc -o playnotes -lao playnotes.c.