extensive changes to PresentationInfo API
[ardour.git] / libs / ardour / luabindings.cc
index 8d46d9e762e444690bd0e2a4be772431cdd0a459..3c7dd670e003815123bd9fa71def2861d6e59ead 100644 (file)
@@ -42,6 +42,7 @@
 #include "ardour/meter.h"
 #include "ardour/midi_track.h"
 #include "ardour/midi_port.h"
+#include "ardour/phase_control.h"
 #include "ardour/playlist.h"
 #include "ardour/plugin.h"
 #include "ardour/plugin_insert.h"
@@ -53,6 +54,9 @@
 #include "ardour/session.h"
 #include "ardour/session_object.h"
 #include "ardour/sidechain.h"
+#include "ardour/solo_isolate_control.h"
+#include "ardour/solo_safe_control.h"
+#include "ardour/stripable.h"
 #include "ardour/track.h"
 #include "ardour/tempo.h"
 
@@ -143,7 +147,7 @@ namespace Cairo {
 CLASSKEYS(Cairo::Context);
 CLASSKEYS(std::vector<double>);
 CLASSKEYS(std::list<ArdourMarker*>);
-CLASSKEYS(std::bitset<47ul>); // LuaSignal::LAST_SIGNAL
+CLASSKEYS(std::bitset<46ul>); // LuaSignal::LAST_SIGNAL
 CLASSKEYS(ArdourMarker*);
 CLASSKEYS(ARDOUR::RouteGroup);
 CLASSKEYS(ARDOUR::LuaProc);
@@ -171,6 +175,7 @@ CLASSKEYS(boost::weak_ptr<ARDOUR::Route>);
 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Region> >);
 CLASSKEYS(std::list<ARDOUR::AudioRange>);
 CLASSKEYS(Evoral::Beats);
+CLASSKEYS(ARDOUR::PortEngine);
 CLASSKEYS(ARDOUR::PortManager);
 CLASSKEYS(ARDOUR::AudioEngine);
 CLASSKEYS(void);
@@ -234,6 +239,8 @@ LuaBindings::common (lua_State* L)
                .addFunction ("to_s", &PBD::ID::to_s) // TODO special case LUA __tostring ?
                .endClass ()
 
+               .beginStdVector <PBD::ID> ("IdVector").endClass ()
+
                .beginClass <XMLNode> ("XMLNode")
                .addFunction ("name", &XMLNode::name)
                .endClass ()
@@ -459,6 +466,8 @@ LuaBindings::common (lua_State* L)
                .endClass ()
 
                .beginWSPtrClass <Port> ("Port")
+               .addCast<MidiPort> ("to_midiport")
+               .addCast<AudioPort> ("to_audioport")
                .addFunction ("name", &Port::name)
                .addFunction ("pretty_name", &Port::pretty_name)
                .addFunction ("receives_input", &Port::receives_input)
@@ -471,6 +480,7 @@ LuaBindings::common (lua_State* L)
                .addFunction ("connected_to", (bool (Port::*)(Port*)const)&Port::connected_to)
                .addFunction ("connect", (int (Port::*)(Port*))&Port::connect)
                .addFunction ("disconnect", (int (Port::*)(Port*))&Port::disconnect)
+               //.addStaticFunction ("port_offset", &Port::port_offset) // static
                .endClass ()
 
                .deriveWSPtrClass <AudioPort, Port> ("AudioPort")
@@ -479,6 +489,7 @@ LuaBindings::common (lua_State* L)
                .deriveWSPtrClass <MidiPort, Port> ("MidiPort")
                .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 ()
 
                .beginWSPtrClass <PortSet> ("PortSet")
@@ -510,7 +521,25 @@ LuaBindings::common (lua_State* L)
                // stub RouteGroup* is needed for new_audio_track()
                .endClass ()
 
-               .deriveWSPtrClass <Route, SessionObject> ("Route")
+               .deriveWSPtrClass <Stripable, SessionObject> ("Stripable")
+               .addCast<Route> ("to_route")
+               .addFunction ("is_auditioner", &Stripable::is_auditioner)
+               .addFunction ("is_master", &Stripable::is_master)
+               .addFunction ("is_monitor", &Stripable::is_monitor)
+               .addFunction ("is_hidden", &Stripable::is_hidden)
+               .addFunction ("is_selected", &Stripable::is_selected)
+               .addFunction ("gain_control", &Stripable::gain_control)
+               .addFunction ("solo_control", &Stripable::solo_control)
+               .addFunction ("solo_isolate_control", &Stripable::solo_isolate_control)
+               .addFunction ("solo_safe_control", &Stripable::solo_safe_control)
+               .addFunction ("mute_control", &Stripable::mute_control)
+               .addFunction ("phase_control", &Stripable::phase_control)
+               .addFunction ("trim_control", &Stripable::trim_control)
+               .addFunction ("rec_enable_control", &Stripable::rec_enable_control)
+               .addFunction ("rec_safe_control", &Stripable::rec_safe_control)
+               .endClass ()
+
+               .deriveWSPtrClass <Route, Stripable> ("Route")
                .addCast<Track> ("to_track")
                .addFunction ("set_name", &Route::set_name)
                .addFunction ("comment", &Route::comment)
@@ -578,10 +607,6 @@ LuaBindings::common (lua_State* L)
                .addCast<MidiTrack> ("to_midi_track")
                .addFunction ("set_name", &Track::set_name)
                .addFunction ("can_record", &Track::can_record)
-               .addFunction ("record_enabled", &Track::record_enabled)
-               .addFunction ("record_safe", &Track::record_safe)
-               .addFunction ("set_record_enabled", &Track::set_record_enabled)
-               .addFunction ("set_record_safe", &Track::set_record_safe)
                .addFunction ("bounceable", &Track::bounceable)
                .addFunction ("bounce", &Track::bounce)
                .addFunction ("bounce_range", &Track::bounce_range)
@@ -686,8 +711,6 @@ LuaBindings::common (lua_State* L)
                .addFunction ("active", &Processor::active)
                .addFunction ("activate", &Processor::activate)
                .addFunction ("deactivate", &Processor::deactivate)
-               .addFunction ("control", (boost::shared_ptr<Evoral::Control>(Evoral::ControlSet::*)(const Evoral::Parameter&, bool))&Evoral::ControlSet::control)
-               .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
                .endClass ()
 
                .deriveWSPtrClass <IOProcessor, Processor> ("IOProcessor")
@@ -744,7 +767,43 @@ LuaBindings::common (lua_State* L)
                .addFunction ("alist", &AutomationControl::alist)
                .endClass ()
 
-               .deriveWSPtrClass <GainControl, AutomationControl> ("GainControl")
+               .deriveWSPtrClass <SlavableAutomationControl, AutomationControl> ("SlavableAutomationControl,")
+               .addFunction ("add_master", &SlavableAutomationControl::add_master)
+               .addFunction ("remove_master", &SlavableAutomationControl::remove_master)
+               .addFunction ("clear_masters", &SlavableAutomationControl::clear_masters)
+               .addFunction ("slaved_to", &SlavableAutomationControl::slaved_to)
+               .addFunction ("slaved", &SlavableAutomationControl::slaved)
+               .addFunction ("get_masters_value", &SlavableAutomationControl::get_masters_value)
+               .addFunction ("get_boolean_masters", &SlavableAutomationControl::get_boolean_masters)
+               //.addFunction ("masters", &SlavableAutomationControl::masters) // not implemented
+               .endClass ()
+
+               .deriveWSPtrClass <PhaseControl, AutomationControl> ("PhaseControl")
+               .addFunction ("set_phase_invert", (void(PhaseControl::*)(uint32_t, bool))&PhaseControl::set_phase_invert)
+               .addFunction ("inverted", &PhaseControl::inverted)
+               .endClass ()
+
+               .deriveWSPtrClass <GainControl, SlavableAutomationControl> ("GainControl")
+               .endClass ()
+
+               .deriveWSPtrClass <SoloControl, SlavableAutomationControl> ("SoloControl")
+               .addFunction ("can_solo", &SoloControl::can_solo)
+               .addFunction ("soloed", &SoloControl::soloed)
+               .addFunction ("self_soloed", &SoloControl::self_soloed)
+               .endClass ()
+
+               .deriveWSPtrClass <MuteControl, SlavableAutomationControl> ("MuteControl")
+               .addFunction ("muted", &MuteControl::muted)
+               .addFunction ("muted_by_self", &MuteControl::muted_by_self)
+               .endClass ()
+
+               .deriveWSPtrClass <SoloIsolateControl, SlavableAutomationControl> ("SoloIsolateControl")
+               .addFunction ("solo_isolated", &SoloIsolateControl::solo_isolated)
+               .addFunction ("self_solo_isolated", &SoloIsolateControl::self_solo_isolated)
+               .endClass ()
+
+               .deriveWSPtrClass <SoloSafeControl, SlavableAutomationControl> ("SoloSafeControl")
+               .addFunction ("solo_safe", &SoloSafeControl::solo_safe)
                .endClass ()
 
                .deriveWSPtrClass <Amp, Processor> ("Amp")
@@ -832,10 +891,26 @@ LuaBindings::common (lua_State* L)
                .endClass ()
 
                .beginClass <TempoMap> ("TempoMap")
-               .addFunction ("add_tempo_pulse", &TempoMap::add_tempo_pulse)
-               .addFunction ("add_tempo_frame", &TempoMap::add_tempo_frame)
-               .addFunction ("add_meter_beat", &TempoMap::add_meter_beat)
-               .addFunction ("add_meter_frame", &TempoMap::add_meter_frame)
+               .addFunction ("add_tempo", &TempoMap::add_tempo)
+               .addFunction ("add_meter", &TempoMap::add_meter)
+               .addFunction ("tempo_section_at_frame", &TempoMap::tempo_section_at_frame)
+               .addFunction ("meter_section_at_frame", &TempoMap::meter_section_at_frame)
+               .addFunction ("meter_section_at_beat", &TempoMap::meter_section_at_beat)
+               .endClass ()
+
+               .beginClass <MetricSection> ("MetricSection")
+               .addFunction ("pulse", &MetricSection::pulse)
+               .addFunction ("set_pulse", &MetricSection::set_pulse)
+               .endClass ()
+
+               .deriveClass <TempoSection, MetricSection> ("TempoSection")
+               .addFunction ("c_func", (double(TempoSection::*)()const)&TempoSection::c_func)
+               .endClass ()
+
+               .deriveClass <MeterSection, MetricSection> ("MeterSection")
+               .addCast<Meter> ("to_meter")
+               .addFunction ("set_pulse", &MeterSection::set_pulse)
+               .addFunction ("set_beat", (void(MeterSection::*)(double))&MeterSection::set_beat)
                .endClass ()
 
                .beginClass <ChanCount> ("ChanCount")
@@ -867,6 +942,23 @@ LuaBindings::common (lua_State* L)
                .addConst ("Lua", ARDOUR::PluginType(Lua))
                .endNamespace ()
 
+               .beginNamespace ("PresentationInfo")
+               .beginNamespace ("Flag")
+               .addConst ("AudioTrack", ARDOUR::PresentationInfo::Flag(PresentationInfo::AudioTrack))
+               .addConst ("MidiTrack", ARDOUR::PresentationInfo::Flag(PresentationInfo::MidiTrack))
+               .addConst ("AudioBus", ARDOUR::PresentationInfo::Flag(PresentationInfo::AudioBus))
+               .addConst ("MidiBus", ARDOUR::PresentationInfo::Flag(PresentationInfo::MidiBus))
+               .addConst ("VCA", ARDOUR::PresentationInfo::Flag(PresentationInfo::VCA))
+               .addConst ("MasterOut", ARDOUR::PresentationInfo::Flag(PresentationInfo::MasterOut))
+               .addConst ("MonitorOut", ARDOUR::PresentationInfo::Flag(PresentationInfo::MonitorOut))
+               .addConst ("Auditioner", ARDOUR::PresentationInfo::Flag(PresentationInfo::Auditioner))
+               .addConst ("Selected", ARDOUR::PresentationInfo::Flag(PresentationInfo::Selected))
+               .addConst ("Hidden", ARDOUR::PresentationInfo::Flag(PresentationInfo::Hidden))
+               .addConst ("GroupOrderSet", ARDOUR::PresentationInfo::Flag(PresentationInfo::OrderSet))
+               .addConst ("StatusMask", ARDOUR::PresentationInfo::Flag(PresentationInfo::StatusMask))
+               .endNamespace ()
+               .endNamespace ()
+
                .beginNamespace ("AutoStyle")
                .addConst ("Absolute", ARDOUR::AutoStyle(Absolute))
                .addConst ("Trim", ARDOUR::AutoStyle(Trim))
@@ -880,9 +972,16 @@ LuaBindings::common (lua_State* L)
                .endNamespace ()
 
                .beginNamespace ("AutomationType")
+               .addConst ("GainAutomation", ARDOUR::AutomationType(GainAutomation))
                .addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation))
-               .addConst ("PluginAutomation", ARDOUR::AutomationType(GainAutomation))
-               .addConst ("PluginAutomation", ARDOUR::AutomationType(TrimAutomation))
+               .addConst ("SoloAutomation", ARDOUR::AutomationType(SoloAutomation))
+               .addConst ("SoloIsolateAutomation", ARDOUR::AutomationType(SoloIsolateAutomation))
+               .addConst ("SoloSafeAutomation", ARDOUR::AutomationType(SoloSafeAutomation))
+               .addConst ("MuteAutomation", ARDOUR::AutomationType(MuteAutomation))
+               .addConst ("RecEnableAutomation", ARDOUR::AutomationType(RecEnableAutomation))
+               .addConst ("RecSafeAutomation", ARDOUR::AutomationType(RecSafeAutomation))
+               .addConst ("TrimAutomation", ARDOUR::AutomationType(TrimAutomation))
+               .addConst ("PhaseAutomation", ARDOUR::AutomationType(PhaseAutomation))
                .endNamespace ()
 
                .beginNamespace ("SrcQuality")
@@ -909,6 +1008,20 @@ LuaBindings::common (lua_State* L)
                .addConst ("SyncPoint", ARDOUR::RegionPoint(SyncPoint))
                .endNamespace ()
 
+               .beginNamespace ("TempoSection")
+               .beginNamespace ("PositionLockStyle")
+               .addConst ("AudioTime", ARDOUR::PositionLockStyle(AudioTime))
+               .addConst ("MusicTime", ARDOUR::PositionLockStyle(MusicTime))
+               .endNamespace ()
+               .endNamespace ()
+
+               .beginNamespace ("TempoSection")
+               .beginNamespace ("Type")
+               .addConst ("Ramp", ARDOUR::TempoSection::Type(TempoSection::Ramp))
+               .addConst ("Constant", ARDOUR::TempoSection::Type(TempoSection::Constant))
+               .endNamespace ()
+               .endNamespace ()
+
                .beginNamespace ("TrackMode")
                .addConst ("Normal", ARDOUR::TrackMode(Start))
                .addConst ("NonLayered", ARDOUR::TrackMode(NonLayered))
@@ -958,6 +1071,9 @@ LuaBindings::common (lua_State* L)
                .addFunction ("set_output_device_name", &AudioBackend::set_output_device_name)
                .endClass()
 
+               .beginClass <PortEngine> ("PortEngine")
+               .endClass()
+
                .beginClass <PortManager> ("PortManager")
                .addFunction ("port_engine", &PortManager::port_engine)
                .addFunction ("connected", &PortManager::connected)
@@ -1027,7 +1143,9 @@ LuaBindings::common (lua_State* L)
                .addFunction ("record_status", &Session::record_status)
                .addFunction ("route_by_id", &Session::route_by_id)
                .addFunction ("route_by_name", &Session::route_by_name)
-               .addFunction ("route_by_remote_id", &Session::route_by_remote_id)
+               .addFunction ("get_remote_nth_stripable", &Session::get_remote_nth_stripable)
+               .addFunction ("get_remote_nth_route", &Session::get_remote_nth_route)
+               .addFunction ("route_by_selected_count", &Session::route_by_selected_count)
                .addFunction ("track_by_diskstream_id", &Session::track_by_diskstream_id)
                .addFunction ("source_by_id", &Session::source_by_id)
                .addFunction ("controllable_by_id", &Session::controllable_by_id)
@@ -1109,8 +1227,10 @@ LuaBindings::dsp (lua_State* L)
                .beginClass <MidiBuffer> ("MidiBuffer")
                .addEqualCheck ()
                .addFunction ("silence", &MidiBuffer::silence)
-               .addFunction ("empty", &MidiBuffer::empty)
+               .addFunction ("push_event", (bool (MidiBuffer::*)(const Evoral::MIDIEvent<framepos_t>&))&MidiBuffer::push_back)
+               .addFunction ("push_back", (bool (MidiBuffer::*)(framepos_t, size_t, const uint8_t*))&MidiBuffer::push_back)
                // TODO iterators..
+               .addExtCFunction ("table", &luabridge::CFunc::listToTable<const Evoral::MIDIEvent<framepos_t>, MidiBuffer>)
                .endClass()
 
                .beginClass <BufferSet> ("BufferSet")
@@ -1137,8 +1257,8 @@ LuaBindings::dsp (lua_State* L)
                // add Ctor?
                .addFunction ("type", &Evoral::MIDIEvent<framepos_t>::type)
                .addFunction ("channel", &Evoral::MIDIEvent<framepos_t>::channel)
-               .addFunction ("set_type", &Evoral::MIDIEvent<framepos_t>::type)
-               .addFunction ("set_channel", &Evoral::MIDIEvent<framepos_t>::channel)
+               .addFunction ("set_type", &Evoral::MIDIEvent<framepos_t>::set_type)
+               .addFunction ("set_channel", &Evoral::MIDIEvent<framepos_t>::set_channel)
                .endClass ()
                .endNamespace ();