Laura Delaney / Mbed 2 deprecated Ldelaney17_frdm_Final_Project

Dependencies:   DmTouch_UniGraphic UniGraphic-forLdelaney17FinalProject mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Song.h Source File

Song.h

00001 #ifndef SONG_H
00002 #define SONG_H
00003 #include<vector>
00004 #include "mbed.h"
00005 extern PwmOut myBuzzer;
00006 extern Timeout note_duration;
00007 extern DigitalOut led;
00008 extern Serial pc;
00009 
00010 class Song{
00011 protected: 
00012     float beat_length;
00013 public: 
00014     vector<float> freqs;
00015     vector<float> beats;
00016     //int * freqs;
00017     //int * beats;
00018     int song_length;
00019     int place_in_song;   
00020      
00021     Song(vector<float> &freq, vector<float> &beat, int length, int tempo){ //length format left over from int arrays. Had pointer issues. Replaced with vectors. 
00022         pc.printf("In song constructor with length %d\r\n", length);
00023         if (tempo == 0) //prevent divide by zero runtime errors
00024             tempo = 120;
00025         beat_length = 60.0/tempo; //beats/minute -> beat duration in seconds
00026         pc.printf("Beat length is %.2fs\r\n", beat_length);
00027         freqs = freq;
00028         beats = beat;
00029         song_length = length;
00030         place_in_song = 0;
00031         return;
00032     }
00033     
00034     void play();
00035     void set_note(int index);
00036     void set_tempo(int tempo);
00037 };
00038 
00039 #endif