Megazeux style sound effect generator
Posted: Thu Nov 10, 2011 2:34 am
Following a blog post I saw last night about dynamically generating tones in Love, I decided to run with the idea and make a monophonic song player. Anyone familiar with Megazeux or ZZT would be immediately familiar with these songs (used as sound effects).
Here's the code: http://pastebin.com/5nHqknCQ
As a quick explanation of the code, there's a string parser that will run through the song in two passes, first to figure out the number of sample required to store the song in. Second pass to generate the tones for each note.
I decided to tune to 440, though megazeux tuned to something slightly lower. Also, I guessed at the BPM being 200. Even though I have the source code of megazeux, and can talk to the devs, I was more interested in getting code working than waiting for them to respond on IRC.
So, play around with it (consider it licensed under the WTFPL https://secure.wikimedia.org/wikipedia/en/wiki/WTFPL). Tell me if there are any bugs or things that I should fix.
Here's the code: http://pastebin.com/5nHqknCQ
As a quick explanation of the code, there's a string parser that will run through the song in two passes, first to figure out the number of sample required to store the song in. Second pass to generate the tones for each note.
I decided to tune to 440, though megazeux tuned to something slightly lower. Also, I guessed at the BPM being 200. Even though I have the source code of megazeux, and can talk to the devs, I was more interested in getting code working than waiting for them to respond on IRC.
So, play around with it (consider it licensed under the WTFPL https://secure.wikimedia.org/wikipedia/en/wiki/WTFPL). Tell me if there are any bugs or things that I should fix.