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 #ifndef WAVE_BUFFER_H_
osmeest 0:1324e7d9d471 2 #define WAVE_BUFFER_H_
osmeest 0:1324e7d9d471 3
osmeest 0:1324e7d9d471 4 #include <cstddef>
osmeest 0:1324e7d9d471 5
osmeest 0:1324e7d9d471 6 namespace snd_wave_generator {
osmeest 0:1324e7d9d471 7
osmeest 0:1324e7d9d471 8 /**
osmeest 0:1324e7d9d471 9 * @brief A class used to hold buffered sound wave data.
osmeest 0:1324e7d9d471 10 * It's basically a vector of floats which can be read in a cyclic way.
osmeest 0:1324e7d9d471 11 */
osmeest 0:1324e7d9d471 12 class WaveBuffer {
osmeest 0:1324e7d9d471 13 public:
osmeest 0:1324e7d9d471 14 WaveBuffer() : size_(0), capacity_(0), data_(NULL) { }
osmeest 0:1324e7d9d471 15 ~WaveBuffer() { delete[] this->data_; }
osmeest 0:1324e7d9d471 16
osmeest 0:1324e7d9d471 17 void resize(std::size_t size);
osmeest 0:1324e7d9d471 18
osmeest 0:1324e7d9d471 19 void write(std::size_t pos, float v) {
osmeest 0:1324e7d9d471 20 if (pos < this->size_) {
osmeest 0:1324e7d9d471 21 this->data_[pos] = v;
osmeest 0:1324e7d9d471 22 }
osmeest 0:1324e7d9d471 23 }
osmeest 0:1324e7d9d471 24
osmeest 0:1324e7d9d471 25 float read(std::size_t pos) const {
osmeest 0:1324e7d9d471 26 return this->data_[pos % this->size_];
osmeest 0:1324e7d9d471 27 }
osmeest 0:1324e7d9d471 28
osmeest 0:1324e7d9d471 29 private:
osmeest 0:1324e7d9d471 30 std::size_t size_;
osmeest 0:1324e7d9d471 31 std::size_t capacity_;
osmeest 0:1324e7d9d471 32 float *data_;
osmeest 0:1324e7d9d471 33 };
osmeest 0:1324e7d9d471 34
osmeest 0:1324e7d9d471 35 } // snd_wave_generator
osmeest 0:1324e7d9d471 36
osmeest 0:1324e7d9d471 37 #endif // WAVE_BUFFER_H_