Two player imu pong
Dependencies: 4DGL-uLCD-SE IMUfilter LSM9DS0 PinDetect mbed
Diff: sound.cpp
- Revision:
- 0:941225f01ccc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sound.cpp Thu Oct 22 16:50:22 2015 +0000 @@ -0,0 +1,53 @@ +#include "soundBuilder.h" + + +Note::Note() +{ + freq = 333; + length = 3; + volume = 1; + } +Note::Note(float f, float len, float vol) +{ + freq =f; + length = len; + volume = vol; + + } +//get +float Note::getFreq() +{ + return freq; + } +float Note::getLength() +{ + return length; + } +float Note::getVol() +{ + return volume; + } + +SoundBuilder::SoundBuilder() +{ + ind = 0; + + } +SoundBuilder::SoundBuilder(Speaker *speakerin) +{ + ind = 0; + speaker = speakerin; + } +void SoundBuilder::addNote(Note note) +{ + song[ind] = note; + ind = ind+1; + } +void SoundBuilder::playSong() +{ + for (int i = 0; i < ind; i++) + { + speaker->PlayNote(song[i].getFreq(), song[i].getLength(), song[i].getVol()); + } +} +