From 33a67c26be597f7d5c6e6aeac4656056c9d05d73 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 19 Nov 2016 21:18:15 +0100 Subject: [PATCH] Allow to call ARDOUR.DSP Lua functions from UI scripts --- libs/ardour/luabindings.cc | 150 +++++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 66 deletions(-) diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index cfe84f2f9b..4c0b653af5 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -27,6 +27,7 @@ #include "ardour/amp.h" #include "ardour/audioengine.h" +#include "ardour/audioregion.h" #include "ardour/audiosource.h" #include "ardour/audio_backend.h" #include "ardour/audio_buffer.h" @@ -202,6 +203,8 @@ CLASSKEYS(std::list >); CLASSKEYS(std::list >); CLASSKEYS(std::list >); +CLASSKEYS(boost::shared_ptr); +CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr >); CLASSKEYS(boost::shared_ptr); @@ -211,6 +214,7 @@ CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr); +CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr); CLASSKEYS(boost::shared_ptr >); @@ -511,8 +515,9 @@ LuaBindings::common (lua_State* L) .addConst ("Curved", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Curved)) .endNamespace () - .endNamespace () // Evoral + .endNamespace (); // Evoral + luabridge::getGlobalNamespace (L) .beginNamespace ("Vamp") .beginClass ("RealTime") @@ -626,8 +631,9 @@ LuaBindings::common (lua_State* L) .endClass () .endNamespace () // Vamp::Plugin - .endNamespace () // Vamp + .endNamespace ();// Vamp + luabridge::getGlobalNamespace (L) .beginNamespace ("ARDOUR") .beginClass ("InterThreadInfo") @@ -981,6 +987,7 @@ LuaBindings::common (lua_State* L) .deriveWSPtrClass ("Region") .addCast ("to_readable") .addCast ("to_midiregion") + .addCast ("to_audioregion") /* properties */ .addFunction ("position", &Region::position) .addFunction ("start", &Region::start) @@ -1047,6 +1054,12 @@ LuaBindings::common (lua_State* L) .addFunction ("length_beats", &MidiRegion::length_beats) .endClass () + .deriveWSPtrClass ("AudioRegion") + .addFunction ("audio_source", &AudioRegion::audio_source) + .addFunction ("set_scale_amplitude", &AudioRegion::set_scale_amplitude) + .addFunction ("scale_amplitude", &AudioRegion::scale_amplitude) + .endClass () + .deriveWSPtrClass ("Source") .addCast ("to_audiosource") .addCast ("to_midisource") @@ -1802,6 +1815,75 @@ LuaBindings::common (lua_State* L) .endNamespace () // end LuaAPI .endNamespace ();// end ARDOUR + + // DSP functions + luabridge::getGlobalNamespace (L) + .beginNamespace ("ARDOUR") + .beginNamespace ("DSP") + .addFunction ("compute_peak", ARDOUR::compute_peak) + .addFunction ("find_peaks", ARDOUR::find_peaks) + .addFunction ("apply_gain_to_buffer", ARDOUR::apply_gain_to_buffer) + .addFunction ("mix_buffers_no_gain", ARDOUR::mix_buffers_no_gain) + .addFunction ("mix_buffers_with_gain", ARDOUR::mix_buffers_with_gain) + .addFunction ("copy_vector", ARDOUR::copy_vector) + .addFunction ("dB_to_coefficient", &dB_to_coefficient) + .addFunction ("fast_coefficient_to_dB", &fast_coefficient_to_dB) + .addFunction ("accurate_coefficient_to_dB", &accurate_coefficient_to_dB) + .addFunction ("memset", &DSP::memset) + .addFunction ("mmult", &DSP::mmult) + .addFunction ("log_meter", &DSP::log_meter) + .addFunction ("log_meter_coeff", &DSP::log_meter_coeff) + .addFunction ("process_map", &DSP::process_map) + .addRefFunction ("peaks", &DSP::peaks) + + .beginClass ("LowPass") + .addConstructor () + .addFunction ("proc", &DSP::LowPass::proc) + .addFunction ("ctrl", &DSP::LowPass::ctrl) + .addFunction ("set_cutoff", &DSP::LowPass::set_cutoff) + .addFunction ("reset", &DSP::LowPass::reset) + .endClass () + .beginClass ("Biquad") + .addConstructor () + .addFunction ("run", &DSP::Biquad::run) + .addFunction ("compute", &DSP::Biquad::compute) + .addFunction ("configure", &DSP::Biquad::configure) + .addFunction ("reset", &DSP::Biquad::reset) + .addFunction ("dB_at_freq", &DSP::Biquad::dB_at_freq) + .endClass () + .beginClass ("FFTSpectrum") + .addConstructor () + .addFunction ("set_data_hann", &DSP::FFTSpectrum::set_data_hann) + .addFunction ("execute", &DSP::FFTSpectrum::execute) + .addFunction ("power_at_bin", &DSP::FFTSpectrum::power_at_bin) + .addFunction ("freq_at_bin", &DSP::FFTSpectrum::freq_at_bin) + .endClass () + + /* DSP enums */ + .beginNamespace ("BiquadType") + .addConst ("LowPass", ARDOUR::DSP::Biquad::LowPass) + .addConst ("HighPass", ARDOUR::DSP::Biquad::HighPass) + .addConst ("BandPassSkirt", ARDOUR::DSP::Biquad::BandPassSkirt) + .addConst ("BandPass0dB", ARDOUR::DSP::Biquad::BandPass0dB) + .addConst ("Notch", ARDOUR::DSP::Biquad::Notch) + .addConst ("AllPass", ARDOUR::DSP::Biquad::AllPass) + .addConst ("Peaking", ARDOUR::DSP::Biquad::Peaking) + .addConst ("LowShelf", ARDOUR::DSP::Biquad::LowShelf) + .addConst ("HighShelf", ARDOUR::DSP::Biquad::HighShelf) + .endNamespace () + + .beginClass ("DspShm") + .addConstructor () + .addFunction ("allocate", &DSP::DspShm::allocate) + .addFunction ("clear", &DSP::DspShm::clear) + .addFunction ("to_float", &DSP::DspShm::to_float) + .addFunction ("to_int", &DSP::DspShm::to_int) + .addFunction ("atomic_set_int", &DSP::DspShm::atomic_set_int) + .addFunction ("atomic_get_int", &DSP::DspShm::atomic_get_int) + .endClass () + + .endNamespace () // DSP + .endNamespace ();// end ARDOUR } void @@ -1876,70 +1958,6 @@ LuaBindings::dsp (lua_State* L) luabridge::getGlobalNamespace (L) .beginNamespace ("ARDOUR") - .beginNamespace ("DSP") - .addFunction ("compute_peak", ARDOUR::compute_peak) - .addFunction ("find_peaks", ARDOUR::find_peaks) - .addFunction ("apply_gain_to_buffer", ARDOUR::apply_gain_to_buffer) - .addFunction ("mix_buffers_no_gain", ARDOUR::mix_buffers_no_gain) - .addFunction ("mix_buffers_with_gain", ARDOUR::mix_buffers_with_gain) - .addFunction ("copy_vector", ARDOUR::copy_vector) - .addFunction ("dB_to_coefficient", &dB_to_coefficient) - .addFunction ("fast_coefficient_to_dB", &fast_coefficient_to_dB) - .addFunction ("accurate_coefficient_to_dB", &accurate_coefficient_to_dB) - .addFunction ("memset", &DSP::memset) - .addFunction ("mmult", &DSP::mmult) - .addFunction ("log_meter", &DSP::log_meter) - .addFunction ("log_meter_coeff", &DSP::log_meter_coeff) - .addFunction ("process_map", &DSP::process_map) - .addRefFunction ("peaks", &DSP::peaks) - - .beginClass ("LowPass") - .addConstructor () - .addFunction ("proc", &DSP::LowPass::proc) - .addFunction ("ctrl", &DSP::LowPass::ctrl) - .addFunction ("set_cutoff", &DSP::LowPass::set_cutoff) - .addFunction ("reset", &DSP::LowPass::reset) - .endClass () - .beginClass ("Biquad") - .addConstructor () - .addFunction ("run", &DSP::Biquad::run) - .addFunction ("compute", &DSP::Biquad::compute) - .addFunction ("configure", &DSP::Biquad::configure) - .addFunction ("reset", &DSP::Biquad::reset) - .addFunction ("dB_at_freq", &DSP::Biquad::dB_at_freq) - .endClass () - .beginClass ("FFTSpectrum") - .addConstructor () - .addFunction ("set_data_hann", &DSP::FFTSpectrum::set_data_hann) - .addFunction ("execute", &DSP::FFTSpectrum::execute) - .addFunction ("power_at_bin", &DSP::FFTSpectrum::power_at_bin) - .addFunction ("freq_at_bin", &DSP::FFTSpectrum::freq_at_bin) - .endClass () - - /* DSP enums */ - .beginNamespace ("BiquadType") - .addConst ("LowPass", ARDOUR::DSP::Biquad::LowPass) - .addConst ("HighPass", ARDOUR::DSP::Biquad::HighPass) - .addConst ("BandPassSkirt", ARDOUR::DSP::Biquad::BandPassSkirt) - .addConst ("BandPass0dB", ARDOUR::DSP::Biquad::BandPass0dB) - .addConst ("Notch", ARDOUR::DSP::Biquad::Notch) - .addConst ("AllPass", ARDOUR::DSP::Biquad::AllPass) - .addConst ("Peaking", ARDOUR::DSP::Biquad::Peaking) - .addConst ("LowShelf", ARDOUR::DSP::Biquad::LowShelf) - .addConst ("HighShelf", ARDOUR::DSP::Biquad::HighShelf) - .endNamespace () - - .beginClass ("DspShm") - .addConstructor () - .addFunction ("allocate", &DSP::DspShm::allocate) - .addFunction ("clear", &DSP::DspShm::clear) - .addFunction ("to_float", &DSP::DspShm::to_float) - .addFunction ("to_int", &DSP::DspShm::to_int) - .addFunction ("atomic_set_int", &DSP::DspShm::atomic_set_int) - .addFunction ("atomic_get_int", &DSP::DspShm::atomic_get_int) - .endClass () - - .endNamespace () // DSP .beginClass ("LuaTableRef") .addCFunction ("get", &LuaTableRef::get)