diff options
author | Robin Gareus <robin@gareus.org> | 2016-07-07 15:36:13 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-07-07 15:37:11 +0200 |
commit | ef1e20f6a281f4e6a030b92382c2e3dc5809fe3c (patch) | |
tree | 1a5edad1a3d1df29d8ba1d9d571bd024d45ba3bc | |
parent | 44a3f042a7a878af45ae893e0361d6a8be315da4 (diff) |
some more lua-bindings
* allow C memory allocation with lua-lifetime
* expose some ChanMapping methods
-rw-r--r-- | libs/ardour/ardour/dsp_filter.h | 4 | ||||
-rw-r--r-- | libs/ardour/dsp_filter.cc | 2 | ||||
-rw-r--r-- | libs/ardour/luabindings.cc | 4 |
3 files changed, 8 insertions, 2 deletions
diff --git a/libs/ardour/ardour/dsp_filter.h b/libs/ardour/ardour/dsp_filter.h index 6220dddf5a..50fe1ff704 100644 --- a/libs/ardour/ardour/dsp_filter.h +++ b/libs/ardour/ardour/dsp_filter.h @@ -48,12 +48,13 @@ namespace ARDOUR { namespace DSP { */ 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 () { @@ -65,6 +66,7 @@ namespace ARDOUR { namespace DSP { * @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; } } diff --git a/libs/ardour/dsp_filter.cc b/libs/ardour/dsp_filter.cc index 3b93c9c6f3..d39d03b9b9 100644 --- a/libs/ardour/dsp_filter.cc +++ b/libs/ardour/dsp_filter.cc @@ -390,7 +390,7 @@ FFTSpectrum::execute () 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; } diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 1ff2f39987..dce33dd95c 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -428,6 +428,9 @@ LuaBindings::common (lua_State* L) .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 () @@ -1365,6 +1368,7 @@ LuaBindings::dsp (lua_State* L) .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) |