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.
SoundWaveGenerator.cpp
00001 #include "snd_wave_generator/SoundWaveGenerator.h" 00002 00003 namespace snd_wave_generator { 00004 00005 void SoundWaveGenerator::play(Wave *wave) 00006 { 00007 wave->prepare(this->sampleRate); 00008 00009 this->wave = wave; 00010 00011 this->pos = 0; 00012 this->ticker.attach(this, &SoundWaveGenerator::tickerHandler, 1.0 / this->sampleRate); 00013 } 00014 00015 void SoundWaveGenerator::stop() 00016 { 00017 this->ticker.detach(); 00018 this->output.write(0.0); 00019 this->wave = NULL; 00020 } 00021 00022 void SoundWaveGenerator::tickerHandler() 00023 { 00024 float v = this->wave ? this->wave->read(this->pos++) : 0.0; 00025 this->output.write(v); 00026 } 00027 00028 } // snd_wave_generator
Generated on Wed Jul 13 2022 16:23:43 by
1.7.2