Simple fish eat program
Dependencies: mbed mbed-rtos N5110 ShiftReg Tone
classes/Sound.cpp
- Committer:
- el18a2k
- Date:
- 2021-08-02
- Revision:
- 14:f1552b691274
- Parent:
- 13:183bd19f3d7d
File content as of revision 14:f1552b691274:
/* Fish Eat Game v2.0 * Author: Andrew Knowles * Date: 21/04/2021 * Note: See hearder files for additional recognistion */ #include "Sound.h" #include "Tone.h" //creates the main theme to be played void Sound::mainTheme(Tone &dac){ //create an array of notes to be played const int mainTheme_note_array[] = { NOTE_C3, NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 1 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3, NOTE_D3, NOTE_C3, 0, NOTE_C3, NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 2 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3, NOTE_D3, NOTE_C3, 0, NOTE_C3, NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 3 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3, NOTE_D3, NOTE_C3, 0, NOTE_C3, NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 4 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3, NOTE_D3, NOTE_C3, 0, NOTE_C4, NOTE_C4, NOTE_A4, NOTE_C4, NOTE_G4, //bar 5 NOTE_C4, NOTE_F4, NOTE_C4, NOTE_E4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_E4, NOTE_D4, NOTE_C4, 0, NOTE_C4, NOTE_C4, NOTE_A4, NOTE_C4, NOTE_G4, //bar 6 NOTE_C4, NOTE_F4, NOTE_C4, NOTE_E4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_E4, NOTE_D4, NOTE_C4, 0, NOTE_C3, NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 7 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3, NOTE_D3, NOTE_C3, 0, NOTE_C3, NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 8 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3, NOTE_D3, NOTE_C3, 0, }; //create an array defining the duration of each note const int mainTheme_note_duration_array[] = { 8, 8,8,8,8, //bar 1 8,8,8,8, 8,8,8,8, 8,8,8, 8, 8,8,8,8,//bar 2 8,8,8,8, 8,8,8,8, 8,8,8, 8, 8,8,8,8,//bar 3 8,8,8,8, 8,8,8,8, 8,8,8, 8, 8,8,8,8,//bar 4 8,8,8,8, 8,8,8,8, 8,8,8, 8, 8,8,8,8, //bar 5 8,8,8,8, 8,8,8,8, 8,8,8, 8, 8,8,8,8,//bar 6 8,8,8,8, 8,8,8,8, 8,8,8, 8, 8,8,8,8,//bar 7 8,8,8,8, 8,8,8,8, 8,8,8, 8, 8,8,8,8,//bar 8 8,8,8,8, 8,8,8,8, 8,8,8, }; n = sizeof(mainTheme_note_array)/sizeof(int); //determine duration dac.play_melody(n,mainTheme_note_array,mainTheme_note_duration_array,60.0,false); //play melody wait_ms(100); //let melody fully play out }