Simple fish eat program

Dependencies:   mbed mbed-rtos N5110 ShiftReg Tone

classes/Sound.cpp

Committer:
el18a2k
Date:
2021-03-24
Revision:
3:8c9c9794bcf2
Child:
7:6f951d175df6

File content as of revision 3:8c9c9794bcf2:

#include "Sound.h"
#include "Tone.h"

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,
        
    };
    
    int n = sizeof(mainTheme_note_array)/sizeof(int);
    dac.play_melody(n,mainTheme_note_array,mainTheme_note_duration_array,60.0,true);
    wait_ms(100);
}