Here is a small example playing the SuperMario Overworld Theme begin:
- Code: Select all
// Set the speed of melody (the value is just multiplied be the time and sleep-duration of each note)
sound::setMelodySpeed(2.0f);
#if 1 // 1 or 0 when using the first or the second example
// Note name first (there is also CIS, DIS etc.), Octave, Time, Sleep-duration
sound::playMelody(sound::NOTE_E, 3, 250, 10);
sound::playMelody(sound::NOTE_E, 3, 250, 250);
sound::playMelody(sound::NOTE_E, 3, 250, 250);
sound::playMelody(sound::NOTE_C, 3, 250, 10);
sound::playMelody(sound::NOTE_E, 3, 250, 250);
sound::playMelody(sound::NOTE_G, 3, 250, 500);
sound::playMelody(sound::NOTE_G, 2, 250, 0);
#else
// The same using the second "playMelody" function:
// 'O' is the octave, 'T' the time, 'S' the sleep duration after playing the tone and all the other letters are the Note's name ;-)
sound::playMelody("O3;T250;S10;E;S250;E;E;S10;C;S250;E;S750;G;O2;S0;G;");
#endif
