I decided to have a little fun with one of the new Console features. I wrote a quick program that will load a text file containing a series of {freqeuency, duration} pairs and play it using Console.Beep(). The program loads the integer data into a Song class. A Song consists of an array of Note types, which are {frequency, duration} pairs. Frequency is in Hertz; duration is in milliseconds; a zero frequency represents a rest. Playing a Song calls Note.Play on each Note, which either calls Thread.Sleep() for a rest or Console.Beep() for a note.
I included two data files: “twinkle.dat” is “Twinkle, Twinkle, Little Star” (also the A-B-C song) and “teapot.dat” is “I'm a Little Teapot.” You can download the code and data files from http://msdn.microsoft.com/netframework/downloads/samples/bclsamples/. Of course, you can also easily make your own dat files.
Caveats:
So, the title says Part 1, indicating some room to consider improvements. Here are some of the ideas I’ve had for making this better in Part 2:
I decided to have a little fun with one of the new Console features. I wrote a quick program that will load a text file containing a series of {freqeuency, duration} pairs and play it using Console.Beep(). The program loads the integer data into a Son
PingBack from http://patiochairsite.info/story.php?id=27309
PingBack from http://patiosetsite.info/story.php?id=171
PingBack from http://mydebtconsolidator.info/story.php?id=11892