A DTMF sequence editor and player for HAM radio equipment command & control.

Dependencies:   mbed ExtTextLCD

Committer:
osmeest
Date:
Mon Mar 07 22:51:19 2011 +0000
Revision:
0:1324e7d9d471

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
osmeest 0:1324e7d9d471 1 #include "snd_wave_generator/SoundWaveGenerator.h"
osmeest 0:1324e7d9d471 2
osmeest 0:1324e7d9d471 3 namespace snd_wave_generator {
osmeest 0:1324e7d9d471 4
osmeest 0:1324e7d9d471 5 void SoundWaveGenerator::play(Wave *wave)
osmeest 0:1324e7d9d471 6 {
osmeest 0:1324e7d9d471 7 wave->prepare(this->sampleRate);
osmeest 0:1324e7d9d471 8
osmeest 0:1324e7d9d471 9 this->wave = wave;
osmeest 0:1324e7d9d471 10
osmeest 0:1324e7d9d471 11 this->pos = 0;
osmeest 0:1324e7d9d471 12 this->ticker.attach(this, &SoundWaveGenerator::tickerHandler, 1.0 / this->sampleRate);
osmeest 0:1324e7d9d471 13 }
osmeest 0:1324e7d9d471 14
osmeest 0:1324e7d9d471 15 void SoundWaveGenerator::stop()
osmeest 0:1324e7d9d471 16 {
osmeest 0:1324e7d9d471 17 this->ticker.detach();
osmeest 0:1324e7d9d471 18 this->output.write(0.0);
osmeest 0:1324e7d9d471 19 this->wave = NULL;
osmeest 0:1324e7d9d471 20 }
osmeest 0:1324e7d9d471 21
osmeest 0:1324e7d9d471 22 void SoundWaveGenerator::tickerHandler()
osmeest 0:1324e7d9d471 23 {
osmeest 0:1324e7d9d471 24 float v = this->wave ? this->wave->read(this->pos++) : 0.0;
osmeest 0:1324e7d9d471 25 this->output.write(v);
osmeest 0:1324e7d9d471 26 }
osmeest 0:1324e7d9d471 27
osmeest 0:1324e7d9d471 28 } // snd_wave_generator