Implement demo app

This commit is contained in:
Sylvain Schneider
2026-02-27 22:52:45 +01:00
parent 0e78926833
commit 187e8772c6
5 changed files with 408 additions and 0 deletions

46
src/main.cpp Normal file
View File

@@ -0,0 +1,46 @@
#include "midiPlayer.h"
#include <iostream>
#include <pitches/all.h>
#include <span>
#include <unordered_map>
using namespace std;
//--------------------------------------------------------------
int main(int argc, char *argv[])
{
cout << "Playing melodies..." << endl;
// Prepare melodies look-up table
unordered_map<string, std::span<const pitches::Note>> melodies = {
{ "Amazing Grace", pitches::amazing_grace },
{ "An die Freude (Ode a la joie)", pitches::an_die_freude },
{ "Auld Lang Syne", pitches::auld_lang_syne },
{ "Canon de Pachelbel", pitches::canon_pachelbel },
{ "Au clair de la Lune", pitches::au_clair_lune },
{ "Douce Nuit", pitches::douce_nuit },
{ "Frere Jacques", pitches::frere_jacques },
{ "Fur Elise", pitches::fur_elise },
{ "God Save the Queen", pitches::god_save_the_queen },
{ "Greensleeves", pitches::greensleeves },
{ "Happy Birthday", pitches::happy_birthday },
{ "Indiana Jones", pitches::indiana_jones },
{ "Jingle Bells", pitches::jingle_bells },
{ "Super Mario Theme", pitches::mario },
{ "La Marseillaise", pitches::marseillaise },
{ "Tetris", pitches::tetris },
{ "Twinkle Twinkle", pitches::twinkle_twinkle },
{ "Vive le Vent", pitches::vive_le_vent }
};
// Play melodies
const MidiPlayer player;
for (const auto &[title, melody] : melodies)
{
cout << " Playing: " << title << endl;
player.playBuffer(melody);
}
return 0;
}
//--------------------------------------------------------------