some more lua-bindings
authorRobin Gareus <robin@gareus.org>
Thu, 7 Jul 2016 13:36:13 +0000 (15:36 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 7 Jul 2016 13:37:11 +0000 (15:37 +0200)
* allow C memory allocation with lua-lifetime
* expose some ChanMapping methods

libs/ardour/ardour/dsp_filter.h
libs/ardour/dsp_filter.cc
libs/ardour/luabindings.cc

index 6220dddf5a2f9d5af95b03f903a0699c5cca16f9..50fe1ff704f440c415ff6548cba8377630f8682c 100644 (file)
@@ -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; }
                        }
index 3b93c9c6f3e71cba0fd227d20b8f06f8e519e90b..d39d03b9b9946648d6d7054537cfa77dbf046a45 100644 (file)
@@ -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;
 }
index 1ff2f3998744b92361200d9b67e607f475c0cdf7..dce33dd95c1656f096b940a3b68357ab7ddf500d 100644 (file)
@@ -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)