Simple fish eat program

Dependencies:   mbed mbed-rtos N5110 ShiftReg Tone

Committer:
el18a2k
Date:
Thu Mar 25 13:00:19 2021 +0000
Revision:
7:6f951d175df6
Parent:
3:8c9c9794bcf2
Child:
12:20ac766b3175
sound implemented

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el18a2k 3:8c9c9794bcf2 1 #include "Sound.h"
el18a2k 3:8c9c9794bcf2 2 #include "Tone.h"
el18a2k 3:8c9c9794bcf2 3
el18a2k 3:8c9c9794bcf2 4 void Sound::mainTheme(Tone &dac){
el18a2k 3:8c9c9794bcf2 5
el18a2k 3:8c9c9794bcf2 6 //
el18a2k 3:8c9c9794bcf2 7 const int mainTheme_note_array[] = {
el18a2k 3:8c9c9794bcf2 8 NOTE_C3,
el18a2k 3:8c9c9794bcf2 9
el18a2k 3:8c9c9794bcf2 10 NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 1
el18a2k 3:8c9c9794bcf2 11 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 12 NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 13 NOTE_D3, NOTE_C3, 0,
el18a2k 3:8c9c9794bcf2 14
el18a2k 3:8c9c9794bcf2 15 NOTE_C3,
el18a2k 3:8c9c9794bcf2 16
el18a2k 3:8c9c9794bcf2 17 NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 2
el18a2k 3:8c9c9794bcf2 18 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 19 NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 20 NOTE_D3, NOTE_C3, 0,
el18a2k 3:8c9c9794bcf2 21
el18a2k 3:8c9c9794bcf2 22 NOTE_C3,
el18a2k 3:8c9c9794bcf2 23
el18a2k 3:8c9c9794bcf2 24 NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 3
el18a2k 3:8c9c9794bcf2 25 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 26 NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 27 NOTE_D3, NOTE_C3, 0,
el18a2k 3:8c9c9794bcf2 28
el18a2k 3:8c9c9794bcf2 29 NOTE_C3,
el18a2k 3:8c9c9794bcf2 30
el18a2k 3:8c9c9794bcf2 31 NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 4
el18a2k 3:8c9c9794bcf2 32 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 33 NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 34 NOTE_D3, NOTE_C3, 0,
el18a2k 3:8c9c9794bcf2 35
el18a2k 3:8c9c9794bcf2 36 NOTE_C4,
el18a2k 3:8c9c9794bcf2 37
el18a2k 3:8c9c9794bcf2 38 NOTE_C4, NOTE_A4, NOTE_C4, NOTE_G4, //bar 5
el18a2k 3:8c9c9794bcf2 39 NOTE_C4, NOTE_F4, NOTE_C4, NOTE_E4,
el18a2k 3:8c9c9794bcf2 40 NOTE_D4, NOTE_E4, NOTE_F4, NOTE_E4,
el18a2k 3:8c9c9794bcf2 41 NOTE_D4, NOTE_C4, 0,
el18a2k 3:8c9c9794bcf2 42
el18a2k 3:8c9c9794bcf2 43 NOTE_C4,
el18a2k 3:8c9c9794bcf2 44
el18a2k 3:8c9c9794bcf2 45 NOTE_C4, NOTE_A4, NOTE_C4, NOTE_G4, //bar 6
el18a2k 3:8c9c9794bcf2 46 NOTE_C4, NOTE_F4, NOTE_C4, NOTE_E4,
el18a2k 3:8c9c9794bcf2 47 NOTE_D4, NOTE_E4, NOTE_F4, NOTE_E4,
el18a2k 3:8c9c9794bcf2 48 NOTE_D4, NOTE_C4, 0,
el18a2k 3:8c9c9794bcf2 49
el18a2k 3:8c9c9794bcf2 50 NOTE_C3,
el18a2k 3:8c9c9794bcf2 51
el18a2k 3:8c9c9794bcf2 52 NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 7
el18a2k 3:8c9c9794bcf2 53 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 54 NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 55 NOTE_D3, NOTE_C3, 0,
el18a2k 3:8c9c9794bcf2 56
el18a2k 3:8c9c9794bcf2 57 NOTE_C3,
el18a2k 3:8c9c9794bcf2 58
el18a2k 3:8c9c9794bcf2 59 NOTE_C3, NOTE_A3, NOTE_C3, NOTE_G3, //bar 8
el18a2k 3:8c9c9794bcf2 60 NOTE_C3, NOTE_F3, NOTE_C3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 61 NOTE_D3, NOTE_E3, NOTE_F3, NOTE_E3,
el18a2k 3:8c9c9794bcf2 62 NOTE_D3, NOTE_C3, 0,
el18a2k 3:8c9c9794bcf2 63 };
el18a2k 3:8c9c9794bcf2 64
el18a2k 3:8c9c9794bcf2 65 const int mainTheme_note_duration_array[] = {
el18a2k 3:8c9c9794bcf2 66
el18a2k 3:8c9c9794bcf2 67 8,
el18a2k 3:8c9c9794bcf2 68
el18a2k 3:8c9c9794bcf2 69 8,8,8,8, //bar 1
el18a2k 3:8c9c9794bcf2 70 8,8,8,8,
el18a2k 3:8c9c9794bcf2 71 8,8,8,8,
el18a2k 3:8c9c9794bcf2 72 8,8,8,
el18a2k 3:8c9c9794bcf2 73
el18a2k 3:8c9c9794bcf2 74 8,
el18a2k 3:8c9c9794bcf2 75
el18a2k 3:8c9c9794bcf2 76 8,8,8,8,//bar 2
el18a2k 3:8c9c9794bcf2 77 8,8,8,8,
el18a2k 3:8c9c9794bcf2 78 8,8,8,8,
el18a2k 3:8c9c9794bcf2 79 8,8,8,
el18a2k 3:8c9c9794bcf2 80
el18a2k 3:8c9c9794bcf2 81 8,
el18a2k 3:8c9c9794bcf2 82
el18a2k 3:8c9c9794bcf2 83 8,8,8,8,//bar 3
el18a2k 3:8c9c9794bcf2 84 8,8,8,8,
el18a2k 3:8c9c9794bcf2 85 8,8,8,8,
el18a2k 3:8c9c9794bcf2 86 8,8,8,
el18a2k 3:8c9c9794bcf2 87
el18a2k 3:8c9c9794bcf2 88 8,
el18a2k 3:8c9c9794bcf2 89
el18a2k 3:8c9c9794bcf2 90 8,8,8,8,//bar 4
el18a2k 3:8c9c9794bcf2 91 8,8,8,8,
el18a2k 3:8c9c9794bcf2 92 8,8,8,8,
el18a2k 3:8c9c9794bcf2 93 8,8,8,
el18a2k 3:8c9c9794bcf2 94
el18a2k 3:8c9c9794bcf2 95 8,
el18a2k 3:8c9c9794bcf2 96
el18a2k 3:8c9c9794bcf2 97 8,8,8,8, //bar 5
el18a2k 3:8c9c9794bcf2 98 8,8,8,8,
el18a2k 3:8c9c9794bcf2 99 8,8,8,8,
el18a2k 3:8c9c9794bcf2 100 8,8,8,
el18a2k 3:8c9c9794bcf2 101
el18a2k 3:8c9c9794bcf2 102 8,
el18a2k 3:8c9c9794bcf2 103
el18a2k 3:8c9c9794bcf2 104 8,8,8,8,//bar 6
el18a2k 3:8c9c9794bcf2 105 8,8,8,8,
el18a2k 3:8c9c9794bcf2 106 8,8,8,8,
el18a2k 3:8c9c9794bcf2 107 8,8,8,
el18a2k 3:8c9c9794bcf2 108
el18a2k 3:8c9c9794bcf2 109 8,
el18a2k 3:8c9c9794bcf2 110
el18a2k 3:8c9c9794bcf2 111 8,8,8,8,//bar 7
el18a2k 3:8c9c9794bcf2 112 8,8,8,8,
el18a2k 3:8c9c9794bcf2 113 8,8,8,8,
el18a2k 3:8c9c9794bcf2 114 8,8,8,
el18a2k 3:8c9c9794bcf2 115
el18a2k 3:8c9c9794bcf2 116 8,
el18a2k 3:8c9c9794bcf2 117
el18a2k 3:8c9c9794bcf2 118 8,8,8,8,//bar 8
el18a2k 3:8c9c9794bcf2 119 8,8,8,8,
el18a2k 3:8c9c9794bcf2 120 8,8,8,8,
el18a2k 3:8c9c9794bcf2 121 8,8,8,
el18a2k 3:8c9c9794bcf2 122
el18a2k 3:8c9c9794bcf2 123 };
el18a2k 3:8c9c9794bcf2 124
el18a2k 3:8c9c9794bcf2 125 int n = sizeof(mainTheme_note_array)/sizeof(int);
el18a2k 7:6f951d175df6 126 dac.play_melody(n,mainTheme_note_array,mainTheme_note_duration_array,60.0,false);
el18a2k 3:8c9c9794bcf2 127 wait_ms(100);
el18a2k 3:8c9c9794bcf2 128 }