*/
class DspShm {
public:
- DspShm ()
+ DspShm (size_t s = 0)
: _data (0)
, _size (0)
{
assert (sizeof(float) == sizeof (int32_t));
assert (sizeof(float) == sizeof (int));
+ allocate (s);
}
~DspShm () {
* @param s size, total number of float or integer elements to store.
*/
void allocate (size_t s) {
+ if (s == _size) { return; }
_data = realloc (_data, sizeof(float) * s);
if (_data) { _size = s; }
}
float
FFTSpectrum::power_at_bin (const uint32_t b, const float norm) const {
- assert (b >= 0 && b < _fft_data_size);
+ assert (b < _fft_data_size);
const float a = _fft_power[b] * norm;
return a > 1e-12 ? 10.0 * fast_log10 (a) : -INFINITY;
}
.addVoidConstructor ()
.addFunction ("get", static_cast<uint32_t(ChanMapping::*)(DataType, uint32_t) const>(&ChanMapping::get))
.addFunction ("set", &ChanMapping::set)
+ .addFunction ("count", &ChanMapping::count)
+ .addFunction ("n_total", &ChanMapping::n_total)
+ .addFunction ("is_monotonic", &ChanMapping::is_monotonic)
.addConst ("Invalid", 4294967295U) // UINT32_MAX
.endClass ()
.endNamespace ()
.beginClass <DSP::DspShm> ("DspShm")
+ .addConstructor<void (*) (size_t)> ()
.addFunction ("allocate", &DSP::DspShm::allocate)
.addFunction ("clear", &DSP::DspShm::clear)
.addFunction ("to_float", &DSP::DspShm::to_float)