PlayNotes
Play simple music notes on the beeper.
void PlayNotes(const string& strNotes); void PlayNotes(const char* pszNotes);
Parameters
- strNotes - string containing notes to play
- pszNotes - character array pointer containing notes to play
Return Value
- void - does not return any value
Remarks
Any application that will use PlayNotes must call OpenBeeeper first.
The duration of note may be specified such as 8A as an eighth note, 4C and a quarter note. The octave may be specified after the note such as 8A5 to specify an eighth A note octave 5.
The available notes are limited to:
Octave 5 - A, B, C, D, E, F, G
Octave 6 - A, C, E, G
Octave 7 - C, D, E
The beeper device /dev/cardbeep accepts formatted strings containing various notes to play. The following notes are supported:
Note | Octave | Frequency (Hz) |
C | 5 | 523.25 |
D | 5 | 587.33 |
E | 5 | 659.26 |
F | 5 | 698.46 |
G | 5 | 783.99 |
A | 5 | 880 |
B | 5 | 987.77 |
C | 6 | 1046.5 |
E | 6 | 1318.5 |
G | 6 | 1568 |
A | 6 | 1760 |
C | 7 | 2093 |
D | 7 | 2349.3 |
E | 7 | 2637 |
A string can be formatted to send to the device in the format:
<duration><note><octave> * duration * 1 – 8, note = 1/duration * 1 = whole (1/1) note * 4 = quarter (1/4) note * 8 = eighth (1/8) note * note - letter from above table * octave - number from above table
Commas are used to separate note information, for example:
4A5,8E6
Plays a 1/4 note A in octave five then a 1/8 note E in octave 6.
The default octave may be set by:
O<octave>
Example:
O5,A,B,C
Sets the default octave to 5 then plays note A, B, and C.
The tempo may be set by:
T<tempo>
tempo must be three characters numeric
Example:
T100,A,B
Sets the tempo to 100 then plays note A and B.
Examples
string str = "A,B,C\r"; PlayNotes(str);
PlayNotes("A,B,C\r");