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.cpp
00001 #include "Song.h" 00002 00003 void mute(){ 00004 note_duration.detach(); 00005 myBuzzer = 0; 00006 } 00007 00008 void Song::play(){ 00009 if (place_in_song < song_length){ 00010 set_note(place_in_song); 00011 note_duration.attach(this, &Song::play, beat_length*beats[place_in_song]); 00012 place_in_song++; 00013 } 00014 else{ 00015 mute(); 00016 place_in_song = 0; 00017 } 00018 } 00019 00020 void Song::set_note(int index){ 00021 myBuzzer.period(1/(2*freqs[index])); 00022 myBuzzer = 0.5; 00023 } 00024 00025 void Song::set_tempo(int tempo){ 00026 beat_length = 60.0/tempo; 00027 }
Generated on Wed Jul 27 2022 04:00:21 by
