Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DmTouch_UniGraphic UniGraphic-forLdelaney17FinalProject mbed
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
Generated on Wed Jul 27 2022 04:00:21 by
