Only show user-presets in favorite sidebar
[ardour.git] / libs / ardour / luabindings.cc
index d15b8fec93fcc13d9e6d5511b5f3412dbcad4e72..9fb807e5debddb9e648133e96a3481a5176d10fb 100644 (file)
@@ -28,6 +28,7 @@
 #include "evoral/Range.hpp"
 
 #include "ardour/amp.h"
+#include "ardour/async_midi_port.h"
 #include "ardour/audioengine.h"
 #include "ardour/audioregion.h"
 #include "ardour/audiosource.h"
 #include "ardour/buffer_set.h"
 #include "ardour/beats_samples_converter.h"
 #include "ardour/chan_mapping.h"
+#include "ardour/convolver.h"
 #include "ardour/dB.h"
+#include "ardour/delayline.h"
 #include "ardour/disk_reader.h"
 #include "ardour/disk_writer.h"
 #include "ardour/dsp_filter.h"
 #include "ardour/file_source.h"
+#include "ardour/filesystem_paths.h"
 #include "ardour/fluid_synth.h"
 #include "ardour/interthread_info.h"
+#include "ardour/ltc_file_reader.h"
 #include "ardour/lua_api.h"
 #include "ardour/luabindings.h"
 #include "ardour/luaproc.h"
 #include "ardour/playlist.h"
 #include "ardour/plugin.h"
 #include "ardour/plugin_insert.h"
+#include "ardour/polarity_processor.h"
 #include "ardour/port_manager.h"
 #include "ardour/progress.h"
+#include "ardour/raw_midi_parser.h"
 #include "ardour/runtime_functions.h"
 #include "ardour/region.h"
 #include "ardour/region_factory.h"
@@ -165,7 +172,8 @@ CLASSINFO(TrackSelection);
 CLASSINFO(TrackViewList);
 
 
-CLASSKEYS(std::bitset<48ul>); // LuaSignal::LAST_SIGNAL
+/* this needs to match gtk2_ardour/luasignal.h */
+CLASSKEYS(std::bitset<49ul>); // LuaSignal::LAST_SIGNAL
 
 CLASSKEYS(void);
 CLASSKEYS(float);
@@ -228,6 +236,7 @@ CLASSKEYS(std::list<Evoral::ControlEvent*>);
 CLASSKEYS(std::vector<ARDOUR::Plugin::PresetRecord>);
 CLASSKEYS(std::vector<boost::shared_ptr<ARDOUR::Processor> >);
 CLASSKEYS(std::vector<boost::shared_ptr<ARDOUR::Source> >);
+CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::PluginInfo> >); // PluginInfoList
 
 CLASSKEYS(std::list<ArdourMarker*>);
 CLASSKEYS(std::list<TimeAxisView*>);
@@ -541,6 +550,7 @@ LuaBindings::common (lua_State* L)
 
                .beginWSPtrClass <Evoral::ControlList> ("ControlList")
                .addFunction ("add", &Evoral::ControlList::add)
+               .addFunction ("editor_add", &Evoral::ControlList::editor_add)
                .addFunction ("thin", &Evoral::ControlList::thin)
                .addFunction ("eval", &Evoral::ControlList::eval)
                .addRefFunction ("rt_safe_eval", &Evoral::ControlList::rt_safe_eval)
@@ -825,6 +835,7 @@ LuaBindings::common (lua_State* L)
                .addFunction ("set_start", &Location::set_start)
                .addFunction ("set_end", &Location::set_end)
                .addFunction ("set_length", &Location::set)
+               .addFunction ("set_name", &Location::set_name)
                .addFunction ("move_to", &Location::move_to)
                .addFunction ("matches", &Location::matches)
                .addFunction ("flags", &Location::flags)
@@ -867,6 +878,7 @@ LuaBindings::common (lua_State* L)
 
                .beginWSPtrClass <Port> ("Port")
                .addCast<MidiPort> ("to_midiport")
+               .addCast<AsyncMIDIPort> ("to_asyncmidiport")
                .addCast<AudioPort> ("to_audioport")
                .addFunction ("name", &Port::name)
                .addFunction ("pretty_name", &Port::pretty_name)
@@ -888,11 +900,16 @@ LuaBindings::common (lua_State* L)
                .endClass ()
 
                .deriveWSPtrClass <MidiPort, Port> ("MidiPort")
+               .addCast<AsyncMIDIPort> ("to_asyncmidiport")
                .addFunction ("input_active", &MidiPort::input_active)
                .addFunction ("set_input_active", &MidiPort::set_input_active)
                .addFunction ("get_midi_buffer", &MidiPort::get_midi_buffer) // DSP only
                .endClass ()
 
+               .deriveWSPtrClass <AsyncMIDIPort, MidiPort> ("AsyncMIDIPort")
+               .addFunction ("write", &AsyncMIDIPort::write)
+               .endClass ()
+
                .beginWSPtrClass <PortSet> ("PortSet")
                .addFunction ("num_ports", (size_t (PortSet::*)(DataType)const)&PortSet::num_ports)
                .addFunction ("add", &PortSet::add)
@@ -1004,29 +1021,29 @@ LuaBindings::common (lua_State* L)
                .addFunction ("pan_width_control", &Stripable::pan_width_control)
                .addFunction ("pan_frontback_control", &Stripable::pan_frontback_control)
                .addFunction ("pan_lfe_control", &Stripable::pan_lfe_control)
-               .addFunction ("send_level_control", &Stripable::send_level_controllable)
-               .addFunction ("send_enable_control", &Stripable::send_level_controllable)
+               .addFunction ("send_level_controllable", &Stripable::send_level_controllable)
+               .addFunction ("send_enable_controllable", &Stripable::send_enable_controllable)
                .addFunction ("send_name", &Stripable::send_name)
                .addFunction ("monitor_control", &Stripable::monitor_control)
-               .addFunction ("master_send_enable_control ", &Stripable::master_send_enable_controllable )
-               .addFunction ("comp_enable_control ", &Stripable::comp_enable_controllable )
-               .addFunction ("comp_threshold_control ", &Stripable::comp_threshold_controllable )
-               .addFunction ("comp_speed_control ", &Stripable::comp_speed_controllable )
-               .addFunction ("comp_mode_control ", &Stripable::comp_mode_controllable )
-               .addFunction ("comp_makeup_control ", &Stripable::comp_makeup_controllable )
-               .addFunction ("comp_redux_control ", &Stripable::comp_redux_controllable )
+               .addFunction ("master_send_enable_controllable", &Stripable::master_send_enable_controllable)
+               .addFunction ("comp_enable_controllabl", &Stripable::comp_enable_controllable)
+               .addFunction ("comp_threshold_controllable", &Stripable::comp_threshold_controllable)
+               .addFunction ("comp_speed_controllable", &Stripable::comp_speed_controllable)
+               .addFunction ("comp_mode_controllable", &Stripable::comp_mode_controllable)
+               .addFunction ("comp_makeup_controllable", &Stripable::comp_makeup_controllable)
+               .addFunction ("comp_redux_controllable", &Stripable::comp_redux_controllable)
                .addFunction ("comp_mode_name", &Stripable::comp_mode_name)
                .addFunction ("comp_speed_name", &Stripable::comp_speed_name)
-               .addFunction ("eq_band_cnt ", &Stripable::eq_band_cnt)
-               .addFunction ("eq_enable_control ", &Stripable::eq_enable_controllable )
+               .addFunction ("eq_band_cnt", &Stripable::eq_band_cnt)
+               .addFunction ("eq_enable_controllable", &Stripable::eq_enable_controllable)
                .addFunction ("eq_band_name", &Stripable::eq_band_name)
-               .addFunction ("eq_gain_control", &Stripable::eq_gain_controllable)
-               .addFunction ("eq_freq_control ", &Stripable::eq_freq_controllable )
-               .addFunction ("eq_q_control ", &Stripable::eq_q_controllable )
-               .addFunction ("eq_shape_control ", &Stripable::eq_shape_controllable )
-               .addFunction ("filter_freq_controllable ", &Stripable::filter_freq_controllable )
-               .addFunction ("filter_slope_controllable ", &Stripable::filter_slope_controllable )
-               .addFunction ("filter_enable_controllable ", &Stripable::filter_enable_controllable )
+               .addFunction ("eq_gain_controllable", &Stripable::eq_gain_controllable)
+               .addFunction ("eq_freq_controllable", &Stripable::eq_freq_controllable)
+               .addFunction ("eq_q_controllable", &Stripable::eq_q_controllable)
+               .addFunction ("eq_shape_controllable", &Stripable::eq_shape_controllable)
+               .addFunction ("filter_freq_controllable", &Stripable::filter_freq_controllable)
+               .addFunction ("filter_slope_controllable", &Stripable::filter_slope_controllable)
+               .addFunction ("filter_enable_controllable", &Stripable::filter_enable_controllable)
                .addFunction ("set_presentation_order", &Stripable::set_presentation_order)
                .addFunction ("presentation_info_ptr", &Stripable::presentation_info_ptr)
 
@@ -1110,7 +1127,7 @@ LuaBindings::common (lua_State* L)
                .addFunction ("combine", &Playlist::combine)
                .addFunction ("uncombine", &Playlist::uncombine)
                .addFunction ("split_region", &Playlist::split_region)
-               .addFunction ("split", (void (Playlist::*)(samplepos_t))&Playlist::split)
+               //.addFunction ("split", &Playlist::split) // XXX needs MusicSample
                .addFunction ("cut", (boost::shared_ptr<Playlist> (Playlist::*)(std::list<AudioRange>&, bool))&Playlist::cut)
 #if 0
                .addFunction ("copy", &Playlist::copy)
@@ -1312,6 +1329,7 @@ LuaBindings::common (lua_State* L)
                .endClass ()
 
                .beginStdVector <Plugin::PresetRecord> ("PresetVector").endClass ()
+               .beginStdList <boost::shared_ptr<ARDOUR::PluginInfo> > ("PluginInfoList").endClass ()
 
                .deriveClass <ParameterDescriptor, Evoral::ParameterDescriptor> ("ParameterDescriptor")
                .addVoidConstructor ()
@@ -1335,9 +1353,10 @@ LuaBindings::common (lua_State* L)
                .addCast<PeakMeter> ("to_peakmeter")
                .addCast<MonitorProcessor> ("to_monitorprocessor")
                .addCast<Send> ("to_send")
+               .addCast<PolarityProcessor> ("to_polarityprocessor")
+               .addCast<DelayLine> ("to_delayline")
 #if 0 // those objects are not yet bound
                .addCast<CapturingProcessor> ("to_capturingprocessor")
-               .addCast<DelayLine> ("to_delayline")
 #endif
                .addCast<PeakMeter> ("to_meter")
                .addFunction ("display_name", &Processor::display_name)
@@ -1432,6 +1451,8 @@ LuaBindings::common (lua_State* L)
                .addFunction ("plugin", &PluginInsert::plugin)
                .addFunction ("activate", &PluginInsert::activate)
                .addFunction ("deactivate", &PluginInsert::deactivate)
+               .addFunction ("enable", &PluginInsert::enable)
+               .addFunction ("enabled", &PluginInsert::enabled)
                .addFunction ("strict_io_configured", &PluginInsert::strict_io_configured)
                .addFunction ("input_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::input_map)
                .addFunction ("output_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::output_map)
@@ -1440,6 +1461,15 @@ LuaBindings::common (lua_State* L)
                .addFunction ("natural_output_streams", &PluginInsert::natural_output_streams)
                .addFunction ("natural_input_streams", &PluginInsert::natural_input_streams)
                .addFunction ("reset_parameters_to_default", &PluginInsert::reset_parameters_to_default)
+               .addFunction ("has_sidechain", &PluginInsert::has_sidechain)
+               .addFunction ("is_instrument", &PluginInsert::is_instrument)
+               .addFunction ("type", &PluginInsert::type)
+               .addFunction ("signal_latency", &PluginInsert::signal_latency)
+               .addFunction ("get_count", &PluginInsert::get_count)
+               .addFunction ("is_channelstrip", &PluginInsert::is_channelstrip)
+               .addFunction ("is_nonbypassable", &PluginInsert::is_nonbypassable)
+               .addFunction ("clear_stats", &PluginInsert::clear_stats)
+               .addRefFunction ("get_stats", &PluginInsert::get_stats)
                .endClass ()
 
                .deriveWSPtrClass <ReadOnlyControl, PBD::StatefulDestructible> ("ReadOnlyControl")
@@ -1542,9 +1572,24 @@ LuaBindings::common (lua_State* L)
                .deriveWSPtrClass <UnknownProcessor, Processor> ("UnknownProcessor")
                .endClass ()
 
+               .deriveWSPtrClass <PolarityProcessor, Processor> ("PolarityProcessor")
+               .endClass ()
+
+               .deriveWSPtrClass <DelayLine, Processor> ("DelayLine")
+               .addFunction ("delay", &DelayLine::delay)
+               .endClass ()
+
                .deriveWSPtrClass <PluginInsert::PluginControl, AutomationControl> ("PluginControl")
                .endClass ()
 
+               .beginClass <RawMidiParser> ("RawMidiParser")
+               .addVoidConstructor ()
+               .addFunction ("reset", &RawMidiParser::reset)
+               .addFunction ("process_byte", &RawMidiParser::process_byte)
+               .addFunction ("buffer_size", &RawMidiParser::buffer_size)
+               .addFunction ("midi_buffer", &RawMidiParser::midi_buffer)
+               .endClass ()
+
                .deriveWSPtrClass <AudioSource, Source> ("AudioSource")
                .addFunction ("readable_length", &AudioSource::readable_length)
                .addFunction ("n_channels", &AudioSource::n_channels)
@@ -1736,6 +1781,7 @@ LuaBindings::common (lua_State* L)
                .addConst ("LV2", ARDOUR::PluginType(LV2))
                .addConst ("Windows_VST", ARDOUR::PluginType(Windows_VST))
                .addConst ("LXVST", ARDOUR::PluginType(LXVST))
+               .addConst ("MacVST", ARDOUR::PluginType(MacVST))
                .addConst ("Lua", ARDOUR::PluginType(Lua))
                .endNamespace ()
 
@@ -1902,6 +1948,7 @@ LuaBindings::common (lua_State* L)
                .addConst ("RF64", ARDOUR::HeaderFormat(RF64))
                .addConst ("RF64_WAV", ARDOUR::HeaderFormat(RF64_WAV))
                .addConst ("MBWF", ARDOUR::HeaderFormat(MBWF))
+               .addConst ("FLAC", ARDOUR::HeaderFormat(FLAC))
                .endNamespace ()
 
                .beginNamespace ("InsertMergePolicy")
@@ -2016,6 +2063,12 @@ LuaBindings::common (lua_State* L)
 
                .endNamespace (); // end ARDOUR
 
+       luabridge::getGlobalNamespace (L)
+               .beginNamespace ("ARDOUR")
+               .addFunction ("user_config_directory", &ARDOUR::user_config_directory)
+               .addFunction ("user_cache_directory", &ARDOUR::user_cache_directory)
+               .endNamespace (); // end ARDOUR
+
        luabridge::getGlobalNamespace (L)
                .beginNamespace ("ARDOUR")
                .beginClass <AudioBackendInfo> ("AudioBackendInfo")
@@ -2187,6 +2240,8 @@ LuaBindings::common (lua_State* L)
                .addFunction ("get_routes", &Session::get_routes)
                .addFunction ("get_tracks", &Session::get_tracks)
                .addFunction ("get_stripables", (StripableList (Session::*)() const)&Session::get_stripables)
+               .addFunction ("get_routelist", &Session::get_routelist)
+
                .addFunction ("name", &Session::name)
                .addFunction ("path", &Session::path)
                .addFunction ("record_status", &Session::record_status)
@@ -2270,6 +2325,7 @@ LuaBindings::common (lua_State* L)
                .beginNamespace ("LuaAPI")
                .addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor)
                .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
+               .addFunction ("list_plugins", ARDOUR::LuaAPI::list_plugins)
                .addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
                .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
                .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
@@ -2280,6 +2336,7 @@ LuaBindings::common (lua_State* L)
                .addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
                .addCFunction ("hsla_to_rgba", ARDOUR::LuaAPI::hsla_to_rgba)
                .addCFunction ("color_to_rgba", ARDOUR::LuaAPI::color_to_rgba)
+               .addFunction ("ascii_dtostr", ARDOUR::LuaAPI::ascii_dtostr)
                .addFunction ("usleep", Glib::usleep)
                .addFunction ("monotonic_time", ::g_get_monotonic_time)
                .addCFunction ("build_filename", ARDOUR::LuaAPI::build_filename)
@@ -2343,6 +2400,27 @@ LuaBindings::common (lua_State* L)
                .addFunction ("power_at_bin", &DSP::FFTSpectrum::power_at_bin)
                .addFunction ("freq_at_bin", &DSP::FFTSpectrum::freq_at_bin)
                .endClass ()
+               .beginClass <DSP::Generator> ("Generator")
+               .addVoidConstructor ()
+               .addFunction ("run", &DSP::Generator::run)
+               .addFunction ("set_type", &DSP::Generator::set_type)
+               .endClass ()
+
+               .beginClass <ARDOUR::LTCReader> ("LTCReader")
+               .addConstructor <void (*) (int, LTC_TV_STANDARD)> ()
+               .addFunction ("write", &ARDOUR::LTCReader::write)
+               .addRefFunction ("read", &ARDOUR::LTCReader::read)
+               .endClass ()
+
+               .beginClass <DSP::Convolver> ("Convolver")
+               .addConstructor <void (*) (Session&, std::string const&, DSP::Convolver::IRChannelConfig, uint32_t)> ()
+               .addFunction ("run", &ARDOUR::DSP::Convolver::run)
+               .addFunction ("run_stereo", &ARDOUR::DSP::Convolver::run_stereo)
+               .addFunction ("latency", &ARDOUR::DSP::Convolver::latency)
+               .addFunction ("n_inputs", &ARDOUR::DSP::Convolver::n_inputs)
+               .addFunction ("n_outputs", &ARDOUR::DSP::Convolver::n_outputs)
+               .addFunction ("ready", &ARDOUR::DSP::Convolver::ready)
+               .endClass ()
 
                /* DSP enums */
                .beginNamespace ("BiquadType")
@@ -2357,6 +2435,25 @@ LuaBindings::common (lua_State* L)
                .addConst ("HighShelf", ARDOUR::DSP::Biquad::HighShelf)
                .endNamespace ()
 
+               .beginNamespace ("NoiseType")
+               .addConst ("UniformWhiteNoise", ARDOUR::DSP::Generator::UniformWhiteNoise)
+               .addConst ("GaussianWhiteNoise", ARDOUR::DSP::Generator::GaussianWhiteNoise)
+               .addConst ("PinkNoise", ARDOUR::DSP::Generator::PinkNoise)
+               .endNamespace ()
+
+               .beginNamespace ("LTC_TV_STANDARD")
+               .addConst ("LTC_TV_525_60", LTC_TV_525_60)
+               .addConst ("LTC_TV_625_50", LTC_TV_625_50)
+               .addConst ("LTC_TV_1125_60", LTC_TV_1125_60)
+               .addConst ("LTC_TV_FILM_24", LTC_TV_FILM_24)
+               .endNamespace ()
+
+               .beginNamespace ("IRChannelConfig")
+               .addConst ("Mono", DSP::Convolver::Mono)
+               .addConst ("MonoToStereo", DSP::Convolver::MonoToStereo)
+               .addConst ("Stereo", DSP::Convolver::Stereo)
+               .endNamespace ()
+
                .beginClass <DSP::DspShm> ("DspShm")
                .addConstructor<void (*) (size_t)> ()
                .addFunction ("allocate", &DSP::DspShm::allocate)
@@ -2383,7 +2480,7 @@ LuaBindings::dsp (lua_State* L)
                .addFunction ("silence", &AudioBuffer::silence)
                .addFunction ("apply_gain", &AudioBuffer::apply_gain)
                .addFunction ("check_silence", &AudioBuffer::check_silence)
-               .addFunction ("read_from", (void (AudioBuffer::*)(const Sample*, samplecnt_t, samplecnt_t, samplecnt_t))&AudioBuffer::check_silence)
+               .addFunction ("read_from", (void (AudioBuffer::*)(const Sample*, samplecnt_t, samplecnt_t, samplecnt_t))&AudioBuffer::read_from)
                .endClass()
 
                .beginClass <MidiBuffer> ("MidiBuffer")