mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-24 22:27:36 +01:00
some more lua-bindings
* allow C memory allocation with lua-lifetime * expose some ChanMapping methods
This commit is contained in:
parent
44a3f042a7
commit
ef1e20f6a2
3 changed files with 8 additions and 2 deletions
|
|
@ -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; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue