Monday, June 28, 2010

Making sounds or notes with internal speakers

If you have qbasic you can try this:
http://www.youtube.com/watch?v=hITypVqHWjk
here is the code that will play a song.

PLAY "T120 << e8e8f8g8g8f8e8d8c8c8d8e8e8d12d4"
PLAY "e8e8f8g8g8fe8d8c8c8d8e8d8c12c4"
PLAY "d8d8e8c8d8e12f12e8c8d8e12f12e8d8c8d8P8"
PLAY "e8e8f8g8g8fe8d8c8c8d8e8d8c12c4"

The T120 is the tempo and the << means go down 2 octaves

Then I also got my internal pc speakers to play different tones with this python code:
import winsound
winsound.Beep(337, 200);
winsound.Beep(437, 200);
winsound.Beep(537, 200);
winsound.Beep(637, 200);
winsound.Beep(737, 200);
winsound.Beep(937, 200);
winsound.Beep(637, 200);
winsound.Beep(337, 200);

although it is not as music sounding. But I may try making it sound better later.
The first parameter of the winsound.Beep is the frequency and the second is the length of the note.

No comments: