Two player imu pong

Dependencies:   4DGL-uLCD-SE IMUfilter LSM9DS0 PinDetect mbed

sound.cpp

Committer:
rrr93
Date:
2015-10-22
Revision:
0:941225f01ccc

File content as of revision 0:941225f01ccc:

#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());
    }
}