Clarvie-Edouard YETIKOUA / Mbed 2 deprecated piano_canettes

Dependencies:   mbed

main.cpp

Committer:
clarvie
Date:
2019-12-20
Revision:
2:8081b948c668
Parent:
1:2e6ea42675c7

File content as of revision 2:8081b948c668:

#include "mbed.h"
#include "Player.h"
#include "Note.h"
#include "TouchClamp.h"

// Song test program - plays a song using PWM and timer interrupts

//Set up notes and durations for sample song to play
// A 0.0 duration note at end terminates song play
//float note[18]= {1568.0,1396.9,494,1244.5,1396.9,1568.0,1568.0,1568.0,1396.9,
//                 1244.5,1396.9,1568.0,1396.9,1244.5,1174.7,1244.5,1244.5, 0.0
//                };
//float duration[18]= {0.48,0.24,0.72,0.48,0.24,0.48,0.24,0.24,0.24,
//                     0.24,0.24,0.24,0.24,0.48,0.24,0.48,0.48, 0.0
//                    };
                    
float note[] = {
  NOTE_E5,       0, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_C5, NOTE_B4, NOTE_A4,
        0, NOTE_A4, NOTE_C5, NOTE_E5, NOTE_E5, NOTE_D5, NOTE_C5, NOTE_B4,       0, NOTE_C5,
  NOTE_D5,       0, NOTE_E5,       0, NOTE_C5,       0, NOTE_A4,       0, NOTE_A4,       0,
  NOTE_B4, NOTE_C5,       0, NOTE_D5,       0, NOTE_F5, NOTE_A5,       0, NOTE_G5, NOTE_F5,
  NOTE_E5,       0,       0, NOTE_C5, NOTE_E5,       0, NOTE_D5, NOTE_C5, NOTE_B4,       0,
  NOTE_B4, NOTE_C5, NOTE_D5,       0, NOTE_E5,       0, NOTE_C5,       0, NOTE_A4,       0,
  NOTE_A4 
};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
float duration[] = {
  0.24, 0.24, 0.24, 0,24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
  0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 
  0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 
  0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
  0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
  0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
  0.24
};

BusOut leds(LED1,LED2,LED3,LED4);
DigitalOut led1(LED1);
int main()
{
// setup instance of new Player class, mySpeaker using pin 26
// the pin must be a PWM output pin
    Player mySpeaker(p21);
    TouchClamp clamp(p28, p27,0x5A);
    clamp.init();
    

    // loops forever while song continues to play to end using interrupts
    while(1) {
       
       char value=0;
       char c=clamp.read(0x00);
       value +=clamp.read(0x01)<<8;
       leds=value;
    
        wait(1);
       
    }
}