wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/KeypadSound/PlayNotes

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:

NoteOctaveFrequency (Hz)
C5523.25
D5587.33
E5659.26
F5698.46
G5783.99
A5880
B5987.77
C61046.5
E61318.5
G61568
A61760
C72093
D72349.3
E72637

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");

See Also

Last modified 7 years ago Last modified on 04/12/18 13:04:46
Note: See TracWiki for help on using the wiki.