I gave one of my IRC bots the ability to compose music on the fly! You use it simply by writing a chat message starting with “!compose”, followed by the tempo in beats per minute, and then a sequence of characters indicating the notes.
For example:
!compose 130 5A 5F#. 5G. 5A 5F#. 5G. 5A. 4A. 4B. 5C#. 5D. 5E. 5F#. 5G. 5F# 5D. 5E. 5F# 4F#. 4G. 4A. 4B. 4A. 4G. 4A. 4F#. 4G. 4A. 4G 4B. 4A. 4G 4F#. 4E. 4F#. 4E. 4D. 4E. 4F#. 4G. 4A. 4B. 4C#. 4D.
That’s a song someone else wrote. The bot spits out a link to an MP3 version of the song to be played through Flash. You can also choose the SoundFont that it uses, allowing you to switch to the appropriate instrument.
To produce the MP3s, I am using FluidSynth to read the SoundFont files to process MIDI files generated by the bot.
I'm on Twitter!