Simple Programming with Sound

Music has always been part of my mind, body, and soul. From listening to it to practicing one of my instruments, I’m almost always doing something that involves music. Once I picked up programming, I wondered how to program sounds to come out of the PC speaker.

So I spent many nights on my parents’ computer, tinkering in QBASIC. I eventually figured out how to get the sounds out of the PC speaker and how to get them to sound right so that a song could play. This is what I came up with:

PLAY "X" + VARPTR$(DrMario$)

As time went on, I figured out how to create MIDIs and would spend some spare time away from my computer keyboard to put my MIDI keyboard to use.

Now that I’m into programming again, my music talents are playing second (bass) fiddle. However, I’ve grown up since playing with QBASIC, and the PC speaker no longer easily amuses me. But I’m still curious about things that make sound, especially the Speech Synthesizer. So with IronPython, I figured I’d check out the Speech Synthesizer and how to invoke it. It was actually very easy to do. Here’s what I created:

>>> import clr
>>> clr.AddReference('System.Speech')
>>> from System.Speech.Synthesis import *
>>> ssSpeech = SpeechSynthesizer()
>>> ssSpeech.SpeakAsync('Cleveland Day of .NET Rocks!')

I was watching a presentation this morning on IronPython that gave me some other ideas as well, but seeing how simple speech looked, I just had to try it out for myself.

If you’re wondering why I chose IronPython for this, you’ll have to come to the Cleveland Day of .NET on May 17 to see my presentation on IronPython. Details will be posted as they come, but definitely keep the date reserved and keep an eye on the site!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.