Simple fish eat program
Dependencies: mbed mbed-rtos N5110 ShiftReg Tone
classes/Sound.cpp
- Committer:
- el18a2k
- Date:
- 2021-04-21
- Revision:
- 12:20ac766b3175
- Parent:
- 7:6f951d175df6
- Child:
- 13:183bd19f3d7d
File content as of revision 12:20ac766b3175:
#include "Sound.h" #include "Tone.h" //creates the main theme to be played void Sound::mainTheme(Tone &dac){ 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, }; 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); dac.play_melody(n,mainTheme_note_array,mainTheme_note_duration_array,60.0,false); wait_ms(100); } void Sound::pointScore(Tone &dac){ const int pointScore_note_array[] = { NOTE_C3, 0, NOTE_C3, NOTE_D3, NOTE_C3, }; const int pointScore_note_duration_array[] = { 8,8,8,8, 4, }; n = sizeof(pointScore_note_array)/sizeof(int); dac.play_melody(n,pointScore_note_array,pointScore_note_duration_array,60.0,false); wait_ms(100); } void Sound::lifeLoss(Tone &dac){ const int lifeLoss_note_array[] = { NOTE_D4, 0, NOTE_D4, }; const int lifeLoss_note_duration_array[] = { 8,8,4, }; n = sizeof(lifeLoss_note_array)/sizeof(int); dac.play_melody(n,lifeLoss_note_array,lifeLoss_note_duration_array,60.0,false); wait_ms(100); }