Classes to produce a computed sound wave on the analog output.
Dependents: SoundWaveGeneratorTest SoundWaveGeneratorTest
Diff: WaveBuffer.cpp
- Revision:
- 0:ed89ef772e92
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WaveBuffer.cpp Mon Jan 24 22:44:39 2011 +0000 @@ -0,0 +1,21 @@ +#include "snd_wave_generator/WaveBuffer.h" + +namespace snd_wave_generator { + +void WaveBuffer::resize(std::size_t size) +{ + if (this->capacity_ > 0 && size > this->capacity_) { + delete[] this->data_; + this->data_ = NULL; + this->capacity_ = 0; + } + + if (size > this->capacity_) { + this->data_ = new float[size]; + this->capacity_ = size; + } + + this->size_ = size; +} + +} // snd_wave_generator \ No newline at end of file