Post by OpenCoder on Sept 6, 2009 13:51:01 GMT
Almost all computers have an internal 'beeper', which is a monophonic square wave generator. (don't worry if you don't know what that means).
I have written a program which allows music to be played through this beeper. Music is stored in separate files, and loaded at run-time.
{Download}
The program reads the following:
string is the string on the guitar (High E string is 1, Low E string is 6)
duration is the length of the note. can be any of the following:
"squaver1" - first of a swing-quaver duo
"squaver2" - second of a swing-quaver duo
"demisemiquaver"
"semiquaver":
"quaver":
"crotchet":
"minim":
"semibreve":
"trip_crotchet": - triplet crotchet
"trip_quaver": - triplet quaver
"trip_semiquaver": - triplet semiquaver
"trip_demisemiquaver": - triplet demisemiquaver
a decimal which defines the number of crotchets the note lasts (e.g, a value of 0.5 would give a quaver, a value of 4 would give a semibreve)
The first line of each file MUST be a tempo declaration, and it must be MAXIMUM 1 event per line.
For example:
This plays the Pac-man Noise from the Dragonforce song, "Through the Fire and Flames", at tempo 200BPM, labelling the section as "Pac-Man noise - 243" (it's the 243rd bar of the song).
I have written a program which allows music to be played through this beeper. Music is stored in separate files, and loaded at run-time.
{Download}
The program reads the following:
Tempo(int tempo);
tempo is set as crotchets per minute#TEXT
displays "TEXT" as the song section title//TEXT
displays "TEXT" after the section title (I use this to track bar numbers)Rest(string duration)
Beep(int fret, int string, string duration)
fret is the fret on the guitar for the note.string is the string on the guitar (High E string is 1, Low E string is 6)
duration is the length of the note. can be any of the following:
"squaver1" - first of a swing-quaver duo
"squaver2" - second of a swing-quaver duo
"demisemiquaver"
"semiquaver":
"quaver":
"crotchet":
"minim":
"semibreve":
"trip_crotchet": - triplet crotchet
"trip_quaver": - triplet quaver
"trip_semiquaver": - triplet semiquaver
"trip_demisemiquaver": - triplet demisemiquaver
a decimal which defines the number of crotchets the note lasts (e.g, a value of 0.5 would give a quaver, a value of 4 would give a semibreve)
The first line of each file MUST be a tempo declaration, and it must be MAXIMUM 1 event per line.
For example:
Tempo(200);
#Pac-Man noise
//243
Beep(20,6,trip_demisemiquaver);
Beep(20,5,trip_demisemiquaver);
Beep(20,4,trip_demisemiquaver);
Beep(20,3,trip_demisemiquaver);
Beep(20,2,trip_demisemiquaver);
Beep(20,1,trip_demisemiquaver);
Rest(quaver);
Beep(20,6,trip_demisemiquaver);
Beep(20,5,trip_demisemiquaver);
Beep(20,4,trip_demisemiquaver);
Beep(20,3,trip_demisemiquaver);
Beep(20,2,trip_demisemiquaver);
Beep(20,1,trip_demisemiquaver);
Rest(quaver);
Beep(20,6,trip_demisemiquaver);
Beep(20,5,trip_demisemiquaver);
Beep(20,4,trip_demisemiquaver);
Beep(20,3,trip_demisemiquaver);
Beep(20,2,trip_demisemiquaver);
Beep(20,1,trip_demisemiquaver);
Rest(quaver);
Beep(20,6,trip_demisemiquaver);
Beep(20,5,trip_demisemiquaver);
Beep(20,4,trip_demisemiquaver);
Beep(20,3,trip_demisemiquaver);
Beep(20,2,trip_demisemiquaver);
Beep(20,1,trip_demisemiquaver);
Rest(quaver);
This plays the Pac-man Noise from the Dragonforce song, "Through the Fire and Flames", at tempo 200BPM, labelling the section as "Pac-Man noise - 243" (it's the 243rd bar of the song).