2 Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2 of the License, or (at your option)
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "timecode/bbt_time.h"
22 #include "pbd/stateful_diff_command.h"
23 #include "evoral/Control.hpp"
24 #include "evoral/ControlList.hpp"
25 #include "evoral/Range.hpp"
27 #include "ardour/amp.h"
28 #include "ardour/audioengine.h"
29 #include "ardour/audiosource.h"
30 #include "ardour/audio_backend.h"
31 #include "ardour/audio_buffer.h"
32 #include "ardour/audio_port.h"
33 #include "ardour/audio_track.h"
34 #include "ardour/buffer_set.h"
35 #include "ardour/chan_mapping.h"
36 #include "ardour/dB.h"
37 #include "ardour/dsp_filter.h"
38 #include "ardour/interthread_info.h"
39 #include "ardour/lua_api.h"
40 #include "ardour/luabindings.h"
41 #include "ardour/luaproc.h"
42 #include "ardour/meter.h"
43 #include "ardour/midi_track.h"
44 #include "ardour/midi_port.h"
45 #include "ardour/playlist.h"
46 #include "ardour/plugin.h"
47 #include "ardour/plugin_insert.h"
48 #include "ardour/port_manager.h"
49 #include "ardour/runtime_functions.h"
50 #include "ardour/region.h"
51 #include "ardour/region_factory.h"
52 #include "ardour/route_group.h"
53 #include "ardour/session.h"
54 #include "ardour/session_object.h"
55 #include "ardour/sidechain.h"
56 #include "ardour/track.h"
57 #include "ardour/tempo.h"
59 #include "LuaBridge/LuaBridge.h"
61 #ifdef PLATFORM_WINDOWS
62 /* luabridge uses addresses of static functions/variables to identify classes.
64 * Static symbols on windows (even identical symbols) are not
65 * mapped to the same address when mixing .dll + .exe.
66 * So we need a single point to define those static functions.
67 * (normally they're header-only in libs/lua/LuaBridge/detail/ClassInfo.h)
69 * Really!! A static function with a static variable in a library header
70 * should never ever be replicated, even if it is a template.
71 * But then again this is windows... what else can go wrong.
76 luabridge::ClassInfo<T>::getStaticKey ()
84 luabridge::ClassInfo<T>::getClassKey ()
92 luabridge::ClassInfo<T>::getConstKey ()
99 luabridge::getIdentityKey ()
105 /* ...and this is the ugly part of it.
107 * We need to foward declare classes from gtk2_ardour
108 * end explicily list classes which are used by gtk2_ardour's bindings.
110 * This is needed because some of the GUI classes use objects from libardour
111 * as function parameters and the .exe would re-create symbols for libardour
114 * Classes which don't use libardour symbols could be moved to
115 * gtk2_ardour/luainstance.cc, but keeping this here reduces code
116 * duplication and does not give the compiler a chance to even think
117 * about replicating the symbols.
120 #define CLASSKEYS(CLS) \
121 template void const* luabridge::ClassInfo< CLS >::getStaticKey(); \
122 template void const* luabridge::ClassInfo< CLS >::getClassKey(); \
123 template void const* luabridge::ClassInfo< CLS >::getConstKey();
125 #define CLASSINFO(CLS) \
127 template void const* luabridge::ClassInfo< CLS >::getStaticKey(); \
128 template void const* luabridge::ClassInfo< CLS >::getClassKey(); \
129 template void const* luabridge::ClassInfo< CLS >::getConstKey();
131 CLASSINFO(MarkerSelection);
132 CLASSINFO(TrackSelection);
133 CLASSINFO(TrackViewList);
134 CLASSINFO(TimeSelection);
135 CLASSINFO(RegionSelection);
136 CLASSINFO(PublicEditor);
137 CLASSINFO(Selection);
138 CLASSINFO(ArdourMarker);
143 CLASSKEYS(Cairo::Context);
144 CLASSKEYS(std::vector<double>);
145 CLASSKEYS(std::list<ArdourMarker*>);
146 CLASSKEYS(std::bitset<47ul>); // LuaSignal::LAST_SIGNAL
147 CLASSKEYS(ArdourMarker*);
148 CLASSKEYS(ARDOUR::RouteGroup);
149 CLASSKEYS(ARDOUR::LuaProc);
150 CLASSKEYS(ARDOUR::DataType);
151 CLASSKEYS(ARDOUR::ChanCount);
152 CLASSKEYS(boost::shared_ptr<ARDOUR::Processor>);
153 CLASSKEYS(ARDOUR::ParameterDescriptor);
154 CLASSKEYS(boost::shared_ptr<ARDOUR::AutomationList>);
155 CLASSKEYS(boost::shared_ptr<Evoral::ControlList>);
156 CLASSKEYS(ARDOUR::LuaOSC::Address);
157 CLASSKEYS(ARDOUR::Session);
158 CLASSKEYS(ARDOUR::BufferSet);
159 CLASSKEYS(ARDOUR::ChanMapping);
160 CLASSKEYS(ARDOUR::DSP::DspShm);
162 CLASSKEYS(ARDOUR::Location);
163 CLASSKEYS(ARDOUR::PluginInfo);
164 CLASSKEYS(PBD::PropertyChange);
165 CLASSKEYS(std::vector<std::string>);
166 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Route> >);
167 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Port> >);
168 CLASSKEYS(boost::shared_ptr<ARDOUR::PluginInfo>);
169 CLASSKEYS(boost::shared_ptr<ARDOUR::Region>);
170 CLASSKEYS(boost::weak_ptr<ARDOUR::Route>);
171 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Region> >);
172 CLASSKEYS(std::list<ARDOUR::AudioRange>);
173 CLASSKEYS(Evoral::Beats);
174 CLASSKEYS(ARDOUR::PortEngine);
175 CLASSKEYS(ARDOUR::PortManager);
176 CLASSKEYS(ARDOUR::AudioEngine);
180 #endif // end windows special case
182 /* Some notes on Lua bindings for libardour and friends
184 * - Prefer factory methods over Contructors whenever possible.
185 * Don't expose the constructor method unless required.
187 * e.g. Don't allow the script to construct a "Track" Object directly
188 * but do allow to create a "BBT_TIME" object.
190 * - Do not dereference Shared or Weak Pointers. Pass the pointer to Lua.
191 * - Define Objects as boost:shared_ptr Object whenever possible.
193 * Storing a boost::shared_ptr in a Lua-variable keeps the reference
194 * until that variable is set to 'nil'.
195 * (if the script were to keep a direct pointer to the object instance, the
196 * behaviour is undefined if the actual object goes away)
198 * Methods of the actual class are indirectly exposed,
199 * boost::*_ptr get() and ::lock() is implicit when the class is exported
200 * as LuaBridge's "WSPtrClass".
203 using namespace ARDOUR;
206 LuaBindings::stddef (lua_State* L)
208 // std::list<std::string>
209 luabridge::getGlobalNamespace (L)
210 .beginNamespace ("C")
211 .beginStdList <std::string> ("StringList")
214 // std::vector<std::string>
215 .beginStdVector <std::string> ("StringVector")
218 // register float array (float*)
219 .registerArray <float> ("FloatArray")
221 // register float array (int32_t*)
222 .registerArray <int32_t> ("IntArray")
229 LuaBindings::common (lua_State* L)
231 luabridge::getGlobalNamespace (L)
232 .beginNamespace ("PBD")
233 .beginClass <PBD::ID> ("ID")
234 .addConstructor <void (*) (std::string)> ()
235 .addFunction ("to_s", &PBD::ID::to_s) // TODO special case LUA __tostring ?
238 .beginClass <XMLNode> ("XMLNode")
239 .addFunction ("name", &XMLNode::name)
242 .beginClass <PBD::Stateful> ("Stateful")
243 .addFunction ("id", &PBD::Stateful::id)
244 .addFunction ("properties", &PBD::Stateful::properties)
245 .addFunction ("clear_changes", &PBD::Stateful::clear_changes)
248 .beginWSPtrClass <PBD::Stateful> ("StatefulPtr")
249 .addFunction ("id", &PBD::Stateful::id)
250 .addFunction ("properties", &PBD::Stateful::properties)
251 .addFunction ("clear_changes", &PBD::Stateful::clear_changes)
254 .deriveClass <PBD::StatefulDestructible, PBD::Stateful> ("StatefulDestructible")
257 .deriveWSPtrClass <PBD::StatefulDestructible, PBD::Stateful> ("StatefulDestructiblePtr")
260 .deriveClass <Command, PBD::StatefulDestructible> ("Command")
261 .addFunction ("set_name", &Command::set_name)
262 .addFunction ("name", &Command::name)
265 /* UndoTransaction::add_command() subscribes to DropReferences()
266 * and deletes the object.
268 * This object cannot be constructed by lua because lua would manage lifetime
269 * and delete the object leading to a double free.
271 * use Session::add_stateful_diff_command()
272 * and Session::abort_reversible_command()
274 .deriveClass <PBD::StatefulDiffCommand, Command> ("StatefulDiffCommand")
275 .addFunction ("undo", &PBD::StatefulDiffCommand::undo)
276 .addFunction ("empty", &PBD::StatefulDiffCommand::empty)
279 .deriveWSPtrClass <PBD::Controllable, PBD::StatefulDestructible> ("Controllable")
280 .addFunction ("name", &PBD::Controllable::name)
281 .addFunction ("get_value", &PBD::Controllable::get_value)
285 .beginNamespace ("GroupControlDisposition")
286 .addConst ("InverseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::InverseGroup))
287 .addConst ("NoGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::NoGroup))
288 .addConst ("UseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::UseGroup))
291 .endNamespace (); // PBD
293 luabridge::getGlobalNamespace (L)
294 .beginNamespace ("Timecode")
295 .beginClass <Timecode::BBT_Time> ("BBT_TIME")
296 .addConstructor <void (*) (uint32_t, uint32_t, uint32_t)> ()
300 luabridge::getGlobalNamespace (L)
302 .beginNamespace ("Evoral")
303 .beginClass <Evoral::Parameter> ("Parameter")
304 .addConstructor <void (*) (uint32_t, uint8_t, uint32_t)> ()
305 .addFunction ("type", &Evoral::Parameter::type)
306 .addFunction ("channel", &Evoral::Parameter::channel)
307 .addFunction ("id", &Evoral::Parameter::id)
310 .beginWSPtrClass <Evoral::ControlList> ("ControlList")
311 .addFunction ("add", &Evoral::ControlList::add)
312 .addFunction ("thin", &Evoral::ControlList::thin)
313 .addFunction ("eval", &Evoral::ControlList::eval)
314 .addRefFunction ("rt_safe_eval", &Evoral::ControlList::rt_safe_eval)
315 .addFunction ("interpolation", &Evoral::ControlList::interpolation)
316 .addFunction ("set_interpolation", &Evoral::ControlList::set_interpolation)
317 .addFunction ("truncate_end", &Evoral::ControlList::truncate_end)
318 .addFunction ("truncate_start", &Evoral::ControlList::truncate_start)
319 .addFunction ("clear", (void (Evoral::ControlList::*)(double, double))&Evoral::ControlList::clear)
320 .addFunction ("in_write_pass", &Evoral::ControlList::in_write_pass)
323 .beginWSPtrClass <Evoral::ControlSet> ("ControlSet")
326 .beginWSPtrClass <Evoral::Control> ("Control")
327 .addFunction ("list", (boost::shared_ptr<Evoral::ControlList>(Evoral::Control::*)())&Evoral::Control::list)
330 .beginClass <Evoral::ParameterDescriptor> ("ParameterDescriptor")
331 .addVoidConstructor ()
332 .addData ("lower", &Evoral::ParameterDescriptor::lower)
333 .addData ("upper", &Evoral::ParameterDescriptor::upper)
334 .addData ("normal", &Evoral::ParameterDescriptor::normal)
335 .addData ("toggled", &Evoral::ParameterDescriptor::toggled)
338 .beginClass <Evoral::Range<framepos_t> > ("Range")
339 .addConstructor <void (*) (framepos_t, framepos_t)> ()
340 .addData ("from", &Evoral::Range<framepos_t>::from)
341 .addData ("to", &Evoral::Range<framepos_t>::to)
344 /* libevoral enums */
345 .beginNamespace ("InterpolationStyle")
346 .addConst ("Discrete", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Discrete))
347 .addConst ("Linear", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Linear))
348 .addConst ("Curved", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Curved))
351 .endNamespace () // Evoral
353 .beginNamespace ("ARDOUR")
355 .beginClass <InterThreadInfo> ("InterThreadInfo")
356 .addVoidConstructor ()
357 .addData ("done", const_cast<bool InterThreadInfo::*>(&InterThreadInfo::done))
358 #if 0 // currently unused, lua is single-threaded, no custom UIs.
359 .addData ("cancel", (bool InterThreadInfo::*)&InterThreadInfo::cancel)
361 .addData ("progress", const_cast<float InterThreadInfo::*>(&InterThreadInfo::progress))
364 .beginClass <AudioRange> ("AudioRange")
365 .addConstructor <void (*) (framepos_t, framepos_t, uint32_t)> ()
366 .addFunction ("length", &AudioRange::length)
367 .addFunction ("equal", &AudioRange::equal)
368 .addData ("start", &AudioRange::start)
369 .addData ("_end", &AudioRange::end) // XXX "end" is a lua reserved word
370 .addData ("id", &AudioRange::id)
373 .beginWSPtrClass <PluginInfo> ("PluginInfo")
374 .addVoidConstructor ()
377 .beginNamespace ("Route")
378 .beginClass <Route::ProcessorStreams> ("ProcessorStreams")
379 .addVoidConstructor ()
383 .beginClass <ChanMapping> ("ChanMapping")
384 .addVoidConstructor ()
385 .addFunction ("get", static_cast<uint32_t(ChanMapping::*)(DataType, uint32_t) const>(&ChanMapping::get))
386 .addFunction ("set", &ChanMapping::set)
387 .addConst ("Invalid", 4294967295U) // UINT32_MAX
390 .beginNamespace ("Properties")
391 // templated class definitions
392 .beginClass <PBD::PropertyDescriptor<bool> > ("BoolProperty").endClass ()
393 .beginClass <PBD::PropertyDescriptor<float> > ("FloatProperty").endClass ()
394 .beginClass <PBD::PropertyDescriptor<framepos_t> > ("FrameposProperty").endClass ()
395 // actual references (TODO: also expose GQuark for std::set)
397 .addConst ("Start", &ARDOUR::Properties::start)
398 .addConst ("Length", &ARDOUR::Properties::length)
399 .addConst ("Position", &ARDOUR::Properties::position)
402 .beginClass <PBD::PropertyChange> ("PropertyChange")
403 // TODO add special handling (std::set<PropertyID>), PropertyID is a GQuark.
404 // -> direct map to lua table beginStdSet()A
406 // expand templated PropertyDescriptor<T>
407 .addFunction ("containsBool", &PBD::PropertyChange::contains<bool>)
408 .addFunction ("containsFloat", &PBD::PropertyChange::contains<float>)
409 .addFunction ("containsFramePos", &PBD::PropertyChange::contains<framepos_t>)
412 .beginClass <PBD::PropertyList> ("PropertyList")
413 // is-a std::map<PropertyID, PropertyBase*>
416 .deriveClass <PBD::OwnedPropertyList, PBD::PropertyList> ("OwnedPropertyList")
419 .beginWSPtrClass <AutomationList> ("AutomationList")
420 .addCast<PBD::Stateful> ("to_stateful")
421 .addCast<PBD::StatefulDestructible> ("to_statefuldestructible")
422 .addCast<Evoral::ControlList> ("list")
423 .addFunction ("get_state", &AutomationList::get_state)
424 .addFunction ("memento_command", &AutomationList::memento_command)
425 .addFunction ("touching", &AutomationList::touching)
426 .addFunction ("writing", &AutomationList::writing)
427 .addFunction ("touch_enabled", &AutomationList::touch_enabled)
430 .deriveClass <Location, PBD::StatefulDestructible> ("Location")
431 .addFunction ("locked", &Location::locked)
432 .addFunction ("lock", &Location::lock)
433 .addFunction ("start", &Location::start)
434 .addFunction ("_end", &Location::end) // XXX "end" is a lua reserved word
435 .addFunction ("length", &Location::length)
436 .addFunction ("set_start", &Location::set_start)
437 .addFunction ("set_end", &Location::set_end)
438 .addFunction ("set_length", &Location::set)
439 .addFunction ("move_to", &Location::move_to)
442 .deriveClass <Locations, PBD::StatefulDestructible> ("Locations")
443 .addFunction ("auto_loop_location", &Locations::auto_loop_location)
444 .addFunction ("auto_punch_location", &Locations::auto_punch_location)
445 .addFunction ("session_range_location", &Locations::session_range_location)
446 .addFunction ("first_mark_after", &Locations::first_mark_after)
447 .addFunction ("first_mark_before", &Locations::first_mark_before)
448 .addFunction ("first_mark_at", &Locations::mark_at)
449 .addRefFunction ("marks_either_side", &Locations::marks_either_side)
450 .addRefFunction ("find_all_between", &Locations::find_all_between)
453 .beginWSPtrClass <SessionObject> ("SessionObject")
454 /* SessionObject is-a PBD::StatefulDestructible,
455 * but multiple inheritance is not covered by luabridge,
456 * we need explicit casts */
457 .addCast<PBD::Stateful> ("to_stateful")
458 .addCast<PBD::StatefulDestructible> ("to_statefuldestructible")
459 .addFunction ("name", &SessionObject::name)
462 .beginWSPtrClass <Port> ("Port")
463 .addCast<MidiPort> ("to_midiport")
464 .addCast<AudioPort> ("to_audioport")
465 .addFunction ("name", &Port::name)
466 .addFunction ("pretty_name", &Port::pretty_name)
467 .addFunction ("receives_input", &Port::receives_input)
468 .addFunction ("sends_output", &Port::sends_output)
469 .addFunction ("connected", &Port::connected)
470 .addFunction ("disconnect_all", &Port::disconnect_all)
471 .addFunction ("connected_to_name", (bool (Port::*)(std::string const &)const)&Port::connected_to)
472 .addFunction ("connect_by_name", (int (Port::*)(std::string const &))&Port::connect)
473 .addFunction ("disconnect_by_name", (int (Port::*)(std::string const &))&Port::disconnect)
474 .addFunction ("connected_to", (bool (Port::*)(Port*)const)&Port::connected_to)
475 .addFunction ("connect", (int (Port::*)(Port*))&Port::connect)
476 .addFunction ("disconnect", (int (Port::*)(Port*))&Port::disconnect)
477 //.addStaticFunction ("port_offset", &Port::port_offset) // static
480 .deriveWSPtrClass <AudioPort, Port> ("AudioPort")
483 .deriveWSPtrClass <MidiPort, Port> ("MidiPort")
484 .addFunction ("input_active", &MidiPort::input_active)
485 .addFunction ("set_input_active", &MidiPort::set_input_active)
486 .addFunction ("get_midi_buffer", &MidiPort::get_midi_buffer) // DSP only
489 .beginWSPtrClass <PortSet> ("PortSet")
490 .addFunction ("num_ports", (size_t (PortSet::*)(DataType)const)&PortSet::num_ports)
491 .addFunction ("add", &PortSet::add)
492 .addFunction ("remove", &PortSet::remove)
493 .addFunction ("port", (boost::shared_ptr<Port> (PortSet::*)(DataType, size_t)const)&PortSet::port)
494 .addFunction ("contains", &PortSet::contains)
495 .addFunction ("clear", &PortSet::clear)
496 .addFunction ("empty", &PortSet::empty)
499 .deriveWSPtrClass <IO, SessionObject> ("IO")
500 .addFunction ("active", &IO::active)
501 .addFunction ("add_port", &IO::add_port)
502 .addFunction ("remove_port", &IO::remove_port)
503 .addFunction ("connect", &IO::connect)
504 .addFunction ("disconnect", (int (IO::*)(boost::shared_ptr<Port>, std::string, void *))&IO::disconnect)
505 .addFunction ("physically_connected", &IO::physically_connected)
506 .addFunction ("has_port", &IO::has_port)
507 .addFunction ("nth", &IO::nth)
508 .addFunction ("audio", &IO::audio)
509 .addFunction ("midi", &IO::midi)
510 .addFunction ("port_by_name", &IO::nth)
511 .addFunction ("n_ports", &IO::n_ports)
514 .beginClass <RouteGroup> ("RouteGroup")
515 // stub RouteGroup* is needed for new_audio_track()
518 .deriveWSPtrClass <Route, SessionObject> ("Route")
519 .addCast<Track> ("to_track")
520 .addFunction ("set_name", &Route::set_name)
521 .addFunction ("comment", &Route::comment)
522 .addFunction ("active", &Route::active)
523 .addFunction ("set_active", &Route::set_active)
524 .addFunction ("nth_plugin", &Route::nth_plugin)
525 .addFunction ("nth_processor", &Route::nth_processor)
526 .addFunction ("nth_send", &Route::nth_send)
527 .addFunction ("add_processor_by_index", &Route::add_processor_by_index)
528 .addFunction ("remove_processor", &Route::remove_processor)
529 .addFunction ("replace_processor", &Route::replace_processor)
530 .addFunction ("n_inputs", &Route::n_inputs)
531 .addFunction ("n_outputs", &Route::n_outputs)
532 .addFunction ("set_comment", &Route::set_comment)
533 .addFunction ("strict_io", &Route::strict_io)
534 .addFunction ("set_strict_io", &Route::set_strict_io)
535 .addFunction ("reset_plugin_insert", &Route::reset_plugin_insert)
536 .addFunction ("customize_plugin_insert", &Route::customize_plugin_insert)
537 .addFunction ("add_sidechain", &Route::add_sidechain)
538 .addFunction ("remove_sidechain", &Route::remove_sidechain)
539 .addFunction ("main_outs", &Route::main_outs)
540 .addFunction ("muted", &Route::muted)
541 .addFunction ("soloed", &Route::soloed)
542 .addFunction ("amp", &Route::amp)
543 .addFunction ("trim", &Route::trim)
546 .deriveWSPtrClass <Playlist, SessionObject> ("Playlist")
547 .addFunction ("region_by_id", &Playlist::region_by_id)
548 .addFunction ("data_type", &Playlist::data_type)
549 .addFunction ("n_regions", &Playlist::n_regions)
550 //.addFunction ("get_extent", &Playlist::get_extent) // pair<framepos_t, framepos_t>
551 //.addFunction ("region_list", &Playlist::region_list) // RegionListProperty&
552 .addFunction ("add_region", &Playlist::add_region)
553 .addFunction ("remove_region", &Playlist::remove_region)
554 .addFunction ("regions_at", &Playlist::regions_at)
555 .addFunction ("top_region_at", &Playlist::top_region_at)
556 .addFunction ("top_unmuted_region_at", &Playlist::top_unmuted_region_at)
557 .addFunction ("find_next_region", &Playlist::find_next_region)
558 .addFunction ("find_next_region_boundary", &Playlist::find_next_region_boundary)
559 .addFunction ("count_regions_at", &Playlist::count_regions_at)
560 .addFunction ("regions_touched", &Playlist::regions_touched)
561 .addFunction ("regions_with_start_within", &Playlist::regions_with_start_within)
562 .addFunction ("regions_with_end_within", &Playlist::regions_with_end_within)
563 .addFunction ("raise_region", &Playlist::raise_region)
564 .addFunction ("lower_region", &Playlist::lower_region)
565 .addFunction ("raise_region_to_top", &Playlist::raise_region_to_top)
566 .addFunction ("lower_region_to_bottom", &Playlist::lower_region_to_bottom)
567 .addFunction ("duplicate", (void (Playlist::*)(boost::shared_ptr<Region>, framepos_t, framecnt_t, float))&Playlist::duplicate)
568 .addFunction ("duplicate_until", &Playlist::duplicate_until)
569 .addFunction ("duplicate_range", &Playlist::duplicate_range)
570 .addFunction ("combine", &Playlist::combine)
571 .addFunction ("uncombine", &Playlist::uncombine)
572 .addFunction ("split_region", &Playlist::split_region)
573 .addFunction ("split", (void (Playlist::*)(framepos_t))&Playlist::split)
574 .addFunction ("cut", (boost::shared_ptr<Playlist> (Playlist::*)(std::list<AudioRange>&, bool))&Playlist::cut)
576 .addFunction ("copy", &Playlist::copy)
577 .addFunction ("paste", &Playlist::paste)
581 .deriveWSPtrClass <Track, Route> ("Track")
582 .addCast<AudioTrack> ("to_audio_track")
583 .addCast<MidiTrack> ("to_midi_track")
584 .addFunction ("set_name", &Track::set_name)
585 .addFunction ("can_record", &Track::can_record)
586 //.addFunction ("record_enabled", &Track::record_enabled)
587 //.addFunction ("record_safe", &Track::record_safe)
588 //.addFunction ("set_record_enabled", &Track::set_record_enabled)
589 //.addFunction ("set_record_safe", &Track::set_record_safe)
590 .addFunction ("bounceable", &Track::bounceable)
591 .addFunction ("bounce", &Track::bounce)
592 .addFunction ("bounce_range", &Track::bounce_range)
593 .addFunction ("playlist", &Track::playlist)
596 .deriveWSPtrClass <AudioTrack, Track> ("AudioTrack")
599 .deriveWSPtrClass <MidiTrack, Track> ("MidiTrack")
602 .deriveWSPtrClass <Region, SessionObject> ("Region")
604 .addFunction ("position", &Region::position)
605 .addFunction ("start", &Region::start)
606 .addFunction ("length", &Region::length)
607 .addFunction ("layer", &Region::layer)
608 .addFunction ("data_type", &Region::data_type)
609 .addFunction ("stretch", &Region::stretch)
610 .addFunction ("shift", &Region::shift)
611 .addRefFunction ("sync_offset", &Region::sync_offset)
612 .addFunction ("sync_position", &Region::sync_position)
613 .addFunction ("hidden", &Region::hidden)
614 .addFunction ("muted", &Region::muted)
615 .addFunction ("opaque", &Region::opaque)
616 .addFunction ("locked", &Region::locked)
617 .addFunction ("position_locked", &Region::position_locked)
618 .addFunction ("video_locked", &Region::video_locked)
619 .addFunction ("automatic", &Region::automatic)
620 .addFunction ("whole_file", &Region::whole_file)
621 .addFunction ("captured", &Region::captured)
622 .addFunction ("can_move", &Region::can_move)
623 .addFunction ("sync_marked", &Region::sync_marked)
624 .addFunction ("external", &Region::external)
625 .addFunction ("import", &Region::import)
626 .addFunction ("covers", &Region::covers)
627 .addFunction ("at_natural_position", &Region::at_natural_position)
628 .addFunction ("is_compound", &Region::is_compound)
629 /* editing operations */
630 .addFunction ("set_length", &Region::set_length)
631 .addFunction ("set_start", &Region::set_start)
632 .addFunction ("set_position", &Region::set_position)
633 .addFunction ("set_initial_position", &Region::set_initial_position)
634 .addFunction ("nudge_position", &Region::nudge_position)
635 .addFunction ("move_to_natural_position", &Region::move_to_natural_position)
636 .addFunction ("move_start", &Region::move_start)
637 .addFunction ("trim_front", &Region::trim_front)
638 .addFunction ("trim_end", &Region::trim_end)
639 .addFunction ("trim_to", &Region::trim_to)
640 .addFunction ("cut_front", &Region::cut_front)
641 .addFunction ("cut_end", &Region::cut_end)
642 .addFunction ("raise", &Region::raise)
643 .addFunction ("lower", &Region::lower)
644 .addFunction ("raise_to_top", &Region::raise_to_top)
645 .addFunction ("lower_to_bottom", &Region::lower_to_bottom)
646 .addFunction ("set_sync_position", &Region::set_sync_position)
647 .addFunction ("clear_sync_position", &Region::clear_sync_position)
648 .addFunction ("set_hidden", &Region::set_hidden)
649 .addFunction ("set_muted", &Region::set_muted)
650 .addFunction ("set_opaque", &Region::set_opaque)
651 .addFunction ("set_locked", &Region::set_locked)
652 .addFunction ("set_video_locked", &Region::set_video_locked)
653 .addFunction ("set_position_locked", &Region::set_position_locked)
656 .beginWSPtrClass <Source> ("Source")
659 .beginClass <Plugin::PresetRecord> ("PresetRecord")
660 .addVoidConstructor ()
661 .addData ("uri", &Plugin::PresetRecord::uri, false)
662 .addData ("label", &Plugin::PresetRecord::label, false)
663 .addData ("user", &Plugin::PresetRecord::user, false)
664 .addData ("valid", &Plugin::PresetRecord::valid, false)
667 .deriveWSPtrClass <Automatable, Evoral::ControlSet> ("Automatable")
668 .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
671 .deriveClass <ParameterDescriptor, Evoral::ParameterDescriptor> ("ParameterDescriptor")
672 .addVoidConstructor ()
673 .addData ("label", &ParameterDescriptor::label)
674 .addData ("logarithmic", &ParameterDescriptor::logarithmic)
677 .deriveWSPtrClass <Processor, SessionObject> ("Processor")
678 .addCast<Automatable> ("to_automatable")
679 .addCast<PluginInsert> ("to_insert")
680 .addCast<SideChain> ("to_sidechain")
681 .addCast<IOProcessor> ("to_ioprocessor")
682 .addCast<UnknownProcessor> ("to_unknownprocessor")
683 .addCast<Amp> ("to_amp")
684 #if 0 // those objects are not yet bound
685 .addCast<MonitorProcessor> ("to_monitorprocessor")
686 .addCast<CapturingProcessor> ("to_capturingprocessor")
687 .addCast<DelayLine> ("to_delayline")
688 .addCast<PeakMeter> ("to_meter")
690 .addFunction ("display_name", &Processor::display_name)
691 .addFunction ("active", &Processor::active)
692 .addFunction ("activate", &Processor::activate)
693 .addFunction ("deactivate", &Processor::deactivate)
694 .addFunction ("control", (boost::shared_ptr<Evoral::Control>(Evoral::ControlSet::*)(const Evoral::Parameter&, bool))&Evoral::ControlSet::control)
695 .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
698 .deriveWSPtrClass <IOProcessor, Processor> ("IOProcessor")
699 .addFunction ("natural_input_streams", &IOProcessor::natural_input_streams)
700 .addFunction ("natural_output_streams", &IOProcessor::natural_output_streams)
701 .addFunction ("input", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::input)
702 .addFunction ("output", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::output)
705 .deriveWSPtrClass <SideChain, IOProcessor> ("SideChain")
708 .deriveWSPtrClass <Delivery, IOProcessor> ("Delivery")
711 .deriveWSPtrClass <Plugin, PBD::StatefulDestructible> ("Plugin")
712 .addFunction ("label", &Plugin::label)
713 .addFunction ("name", &Plugin::name)
714 .addFunction ("maker", &Plugin::maker)
715 .addFunction ("parameter_count", &Plugin::parameter_count)
716 .addRefFunction ("nth_parameter", &Plugin::nth_parameter)
717 .addFunction ("preset_by_label", &Plugin::preset_by_label)
718 .addFunction ("preset_by_uri", &Plugin::preset_by_uri)
719 .addFunction ("load_preset", &Plugin::load_preset)
720 .addFunction ("parameter_is_input", &Plugin::parameter_is_input)
721 .addFunction ("get_docs", &Plugin::get_docs)
722 .addFunction ("get_parameter_docs", &Plugin::get_parameter_docs)
723 .addRefFunction ("get_parameter_descriptor", &Plugin::get_parameter_descriptor)
726 .deriveWSPtrClass <PluginInsert, Processor> ("PluginInsert")
727 .addFunction ("plugin", &PluginInsert::plugin)
728 .addFunction ("activate", &PluginInsert::activate)
729 .addFunction ("deactivate", &PluginInsert::deactivate)
730 .addFunction ("strict_io_configured", &PluginInsert::strict_io_configured)
731 .addFunction ("input_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::input_map)
732 .addFunction ("output_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::output_map)
733 .addFunction ("set_input_map", &PluginInsert::set_input_map)
734 .addFunction ("set_output_map", &PluginInsert::set_output_map)
735 .addFunction ("sidechain_input", &PluginInsert::sidechain_input)
738 .deriveWSPtrClass <AutomationControl, PBD::Controllable> ("AutomationControl")
739 .addCast<Evoral::Control> ("to_ctrl")
740 .addFunction ("automation_state", &AutomationControl::automation_state)
741 .addFunction ("automation_style", &AutomationControl::automation_style)
742 .addFunction ("set_automation_state", &AutomationControl::set_automation_state)
743 .addFunction ("set_automation_style", &AutomationControl::set_automation_style)
744 .addFunction ("start_touch", &AutomationControl::start_touch)
745 .addFunction ("stop_touch", &AutomationControl::stop_touch)
746 .addFunction ("get_value", &AutomationControl::get_value)
747 .addFunction ("set_value", &AutomationControl::set_value)
748 .addFunction ("writable", &AutomationControl::writable)
749 .addFunction ("alist", &AutomationControl::alist)
752 .deriveWSPtrClass <GainControl, AutomationControl> ("GainControl")
755 .deriveWSPtrClass <Amp, Processor> ("Amp")
756 .addFunction ("gain_control", (boost::shared_ptr<GainControl>(Amp::*)())&Amp::gain_control)
759 .deriveWSPtrClass <UnknownProcessor, Processor> ("UnknownProcessor")
762 .deriveWSPtrClass <PluginInsert::PluginControl, AutomationControl> ("PluginControl")
765 .deriveWSPtrClass <AudioSource, Source> ("AudioSource")
766 .addFunction ("readable_length", &AudioSource::readable_length)
767 .addFunction ("n_channels", &AudioSource::n_channels)
770 // <std::list<boost::shared_ptr <AudioTrack> >
771 .beginStdList <boost::shared_ptr<AudioTrack> > ("AudioTrackList")
774 // std::list<boost::shared_ptr <MidiTrack> >
775 .beginStdList <boost::shared_ptr<MidiTrack> > ("MidiTrackList")
778 // RouteList == std::list<boost::shared_ptr<Route> >
779 .beginConstStdList <boost::shared_ptr<Route> > ("RouteList")
782 // boost::shared_ptr<RouteList>
783 .beginPtrStdList <boost::shared_ptr<Route> > ("RouteListPtr")
786 // typedef std::list<boost::weak_ptr <Route> > WeakRouteList
787 .beginConstStdList <boost::weak_ptr<Route> > ("WeakRouteList")
790 // std::list< boost::weak_ptr <AudioSource> >
791 .beginConstStdList <boost::weak_ptr<AudioSource> > ("WeakAudioSourceList")
794 // typedef std::list<boost::shared_ptr<Region> > RegionList
795 .beginConstStdList <boost::shared_ptr<Region> > ("RegionList")
798 // boost::shared_ptr <std::list<boost::shared_ptr<Region> > >
799 .beginPtrStdList <boost::shared_ptr<Region> > ("RegionListPtr")
802 //std::list<boost::shared_ptr<Port> > PortList;
803 .beginConstStdList <boost::shared_ptr<Port> > ("PortList")
806 // used by Playlist::cut/copy
807 .beginConstStdList <AudioRange> ("AudioRangeList")
810 .beginConstStdList <Location*> ("LocationList")
813 #if 0 // depends on Evoal:: Note, Beats see note_fixer.h
814 // typedef Evoral::Note<Evoral::Beats> Note;
815 // std::set< boost::weak_ptr<Note> >
816 .beginStdSet <boost::weak_ptr<Note> > ("WeakNoteSet")
820 // std::list<boost::weak_ptr<Source> >
821 .beginConstStdList <boost::weak_ptr<Source> > ("WeakSourceList")
824 .beginClass <Tempo> ("Tempo")
825 .addConstructor <void (*) (double, double)> ()
826 .addFunction ("note_type", &Tempo::note_type)
827 .addFunction ("beats_per_minute", &Tempo::beats_per_minute)
828 .addFunction ("frames_per_beat", &Tempo::frames_per_beat)
831 .beginClass <Meter> ("Meter")
832 .addConstructor <void (*) (double, double)> ()
833 .addFunction ("divisions_per_bar", &Meter::divisions_per_bar)
834 .addFunction ("note_divisor", &Meter::note_divisor)
835 .addFunction ("frames_per_bar", &Meter::frames_per_bar)
836 .addFunction ("frames_per_grid", &Meter::frames_per_grid)
839 .beginClass <TempoMap> ("TempoMap")
840 .addFunction ("add_tempo", &TempoMap::add_tempo)
841 .addFunction ("add_meter", &TempoMap::add_meter)
844 .beginClass <ChanCount> ("ChanCount")
845 .addConstructor <void (*) (DataType, uint32_t)> ()
846 .addFunction ("get", &ChanCount::get)
847 .addFunction ("set", &ChanCount::set)
848 .addFunction ("n_audio", &ChanCount::n_audio)
849 .addFunction ("n_midi", &ChanCount::n_midi)
850 .addFunction ("n_total", &ChanCount::n_total)
851 .addFunction ("reset", &ChanCount::reset)
854 .beginClass <DataType> ("DataType")
855 .addConstructor <void (*) (std::string)> ()
856 .addStaticCFunction ("null", &LuaAPI::datatype_ctor_null) // "nil" is a lua reseved word
857 .addStaticCFunction ("audio", &LuaAPI::datatype_ctor_audio)
858 .addStaticCFunction ("midi", &LuaAPI::datatype_ctor_midi)
859 .addFunction ("to_string", &DataType::to_string) // TODO Lua __tostring
860 // TODO add uint32_t cast, add operator== !=
863 /* libardour enums */
864 .beginNamespace ("PluginType")
865 .addConst ("AudioUnit", ARDOUR::PluginType(AudioUnit))
866 .addConst ("LADSPA", ARDOUR::PluginType(LADSPA))
867 .addConst ("LV2", ARDOUR::PluginType(LV2))
868 .addConst ("Windows_VST", ARDOUR::PluginType(Windows_VST))
869 .addConst ("LXVST", ARDOUR::PluginType(LXVST))
870 .addConst ("Lua", ARDOUR::PluginType(Lua))
873 .beginNamespace ("AutoStyle")
874 .addConst ("Absolute", ARDOUR::AutoStyle(Absolute))
875 .addConst ("Trim", ARDOUR::AutoStyle(Trim))
878 .beginNamespace ("AutoState")
879 .addConst ("Off", ARDOUR::AutoState(Off))
880 .addConst ("Write", ARDOUR::AutoState(Write))
881 .addConst ("Touch", ARDOUR::AutoState(Touch))
882 .addConst ("Play", ARDOUR::AutoState(Play))
885 .beginNamespace ("AutomationType")
886 .addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation))
887 .addConst ("PluginAutomation", ARDOUR::AutomationType(GainAutomation))
888 .addConst ("PluginAutomation", ARDOUR::AutomationType(TrimAutomation))
891 .beginNamespace ("SrcQuality")
892 .addConst ("SrcBest", ARDOUR::SrcQuality(SrcBest))
895 .beginNamespace ("PortFlags")
896 .addConst ("IsInput", ARDOUR::PortFlags(IsInput))
897 .addConst ("IsOutput", ARDOUR::PortFlags(IsOutput))
898 .addConst ("IsPhysical", ARDOUR::PortFlags(IsPhysical))
899 .addConst ("CanMonitor", ARDOUR::PortFlags(CanMonitor))
900 .addConst ("IsTerminal", ARDOUR::PortFlags(IsTerminal))
903 .beginNamespace ("PlaylistDisposition")
904 .addConst ("CopyPlaylist", ARDOUR::PlaylistDisposition(CopyPlaylist))
905 .addConst ("NewPlaylist", ARDOUR::PlaylistDisposition(NewPlaylist))
906 .addConst ("SharePlaylist", ARDOUR::PlaylistDisposition(SharePlaylist))
909 .beginNamespace ("RegionPoint")
910 .addConst ("Start", ARDOUR::RegionPoint(Start))
911 .addConst ("End", ARDOUR::RegionPoint(End))
912 .addConst ("SyncPoint", ARDOUR::RegionPoint(SyncPoint))
915 .beginNamespace ("TrackMode")
916 .addConst ("Normal", ARDOUR::TrackMode(Start))
917 .addConst ("NonLayered", ARDOUR::TrackMode(NonLayered))
918 .addConst ("Destructive", ARDOUR::TrackMode(Destructive))
920 .endNamespace (); // end ARDOUR
922 luabridge::getGlobalNamespace (L)
923 .beginNamespace ("ARDOUR")
924 .beginClass <AudioBackendInfo> ("AudioBackendInfo")
925 .addData ("name", &AudioBackendInfo::name)
927 .beginStdVector <const AudioBackendInfo*> ("BackendVector").endClass ()
929 .beginClass <AudioBackend::DeviceStatus> ("DeviceStatus")
930 .addData ("name", &AudioBackend::DeviceStatus::name)
931 .addData ("available", &AudioBackend::DeviceStatus::available)
933 .beginStdVector <AudioBackend::DeviceStatus> ("DeviceStatusVector").endClass ()
935 .beginWSPtrClass <AudioBackend> ("AudioBackend")
936 .addFunction ("info", &AudioBackend::info)
937 .addFunction ("sample_rate", &AudioBackend::sample_rate)
938 .addFunction ("buffer_size", &AudioBackend::buffer_size)
939 .addFunction ("period_size", &AudioBackend::period_size)
940 .addFunction ("input_channels", &AudioBackend::input_channels)
941 .addFunction ("output_channels", &AudioBackend::output_channels)
942 .addFunction ("dsp_load", &AudioBackend::dsp_load)
944 .addFunction ("set_sample_rate", &AudioBackend::set_sample_rate)
945 .addFunction ("set_buffer_size", &AudioBackend::set_buffer_size)
946 .addFunction ("set_peridod_size", &AudioBackend::set_peridod_size)
948 .addFunction ("enumerate_drivers", &AudioBackend::enumerate_drivers)
949 .addFunction ("driver_name", &AudioBackend::driver_name)
950 .addFunction ("set_driver", &AudioBackend::set_driver)
952 .addFunction ("use_separate_input_and_output_devices", &AudioBackend::use_separate_input_and_output_devices)
953 .addFunction ("enumerate_devices", &AudioBackend::enumerate_devices)
954 .addFunction ("enumerate_input_devices", &AudioBackend::enumerate_input_devices)
955 .addFunction ("enumerate_output_devices", &AudioBackend::enumerate_output_devices)
956 .addFunction ("device_name", &AudioBackend::device_name)
957 .addFunction ("input_device_name", &AudioBackend::input_device_name)
958 .addFunction ("output_device_name", &AudioBackend::output_device_name)
959 .addFunction ("set_device_name", &AudioBackend::set_device_name)
960 .addFunction ("set_input_device_name", &AudioBackend::set_input_device_name)
961 .addFunction ("set_output_device_name", &AudioBackend::set_output_device_name)
964 .beginClass <PortEngine> ("PortEngine")
967 .beginClass <PortManager> ("PortManager")
968 .addFunction ("port_engine", &PortManager::port_engine)
969 .addFunction ("connected", &PortManager::connected)
970 .addFunction ("connect", &PortManager::connect)
971 .addFunction ("physically_connected", &PortManager::physically_connected)
972 .addFunction ("disconnect", (int (PortManager::*)(const std::string&, const std::string&))&PortManager::disconnect)
973 .addFunction ("disconnect_port", (int (PortManager::*)(boost::shared_ptr<Port>))&PortManager::disconnect)
974 .addFunction ("get_port_by_name", &PortManager::get_port_by_name)
975 .addFunction ("get_pretty_name_by_name", &PortManager::get_pretty_name_by_name)
976 .addFunction ("port_is_physical", &PortManager::port_is_physical)
977 .addFunction ("get_physical_outputs", &PortManager::get_physical_outputs)
978 .addFunction ("get_physical_inputs", &PortManager::get_physical_inputs)
979 .addFunction ("n_physical_outputs", &PortManager::n_physical_outputs)
980 .addFunction ("n_physical_inputs", &PortManager::n_physical_inputs)
981 .addRefFunction ("get_connections", &PortManager::get_connections)
982 .addRefFunction ("get_ports", (int (PortManager::*)(DataType, PortManager::PortList&))&PortManager::get_ports)
983 .addRefFunction ("get_backend_ports", (int (PortManager::*)(const std::string&, DataType, PortFlags, std::vector<std::string>&))&PortManager::get_ports)
986 .deriveClass <AudioEngine, PortManager> ("AudioEngine")
987 .addFunction ("available_backends", &AudioEngine::available_backends)
988 .addFunction ("current_backend_name", &AudioEngine::current_backend_name)
989 .addFunction ("set_backend", &AudioEngine::set_backend)
990 .addFunction ("setup_required", &AudioEngine::setup_required)
991 .addFunction ("start", &AudioEngine::start)
992 .addFunction ("stop", &AudioEngine::stop)
993 .addFunction ("get_dsp_load", &AudioEngine::get_dsp_load)
994 .addFunction ("set_device_name", &AudioEngine::set_device_name)
995 .addFunction ("set_sample_rate", &AudioEngine::set_sample_rate)
996 .addFunction ("set_buffer_size", &AudioEngine::set_buffer_size)
997 .addFunction ("get_last_backend_error", &AudioEngine::get_last_backend_error)
1001 // basic representation of Session
1002 // functions which can be used from realtime and non-realtime contexts
1003 luabridge::getGlobalNamespace (L)
1004 .beginNamespace ("ARDOUR")
1005 .beginClass <Session> ("Session")
1006 .addFunction ("scripts_changed", &Session::scripts_changed) // used internally
1007 .addFunction ("transport_rolling", &Session::transport_rolling)
1008 .addFunction ("request_transport_speed", &Session::request_transport_speed)
1009 .addFunction ("transport_frame", &Session::transport_frame)
1010 .addFunction ("transport_speed", &Session::transport_speed)
1011 .addFunction ("frame_rate", &Session::frame_rate)
1012 .addFunction ("nominal_frame_rate", &Session::nominal_frame_rate)
1013 .addFunction ("frames_per_timecode_frame", &Session::frames_per_timecode_frame)
1014 .addFunction ("timecode_frames_per_hour", &Session::timecode_frames_per_hour)
1015 .addFunction ("timecode_frames_per_second", &Session::timecode_frames_per_second)
1016 .addFunction ("timecode_drop_frames", &Session::timecode_drop_frames)
1017 .addFunction ("request_locate", &Session::request_locate)
1018 .addFunction ("request_stop", &Session::request_stop)
1019 .addFunction ("last_transport_start", &Session::last_transport_start)
1020 .addFunction ("goto_start", &Session::goto_start)
1021 .addFunction ("goto_end", &Session::goto_end)
1022 .addFunction ("current_start_frame", &Session::current_start_frame)
1023 .addFunction ("current_end_frame", &Session::current_end_frame)
1024 .addFunction ("actively_recording", &Session::actively_recording)
1025 .addFunction ("new_audio_track", &Session::new_audio_track)
1026 .addFunction ("new_audio_route", &Session::new_audio_route)
1027 .addFunction ("new_midi_track", &Session::new_midi_track)
1028 .addFunction ("new_midi_route", &Session::new_midi_route)
1029 .addFunction ("get_routes", &Session::get_routes)
1030 .addFunction ("get_tracks", &Session::get_tracks)
1031 .addFunction ("name", &Session::name)
1032 .addFunction ("path", &Session::path)
1033 .addFunction ("record_status", &Session::record_status)
1034 .addFunction ("route_by_id", &Session::route_by_id)
1035 .addFunction ("route_by_name", &Session::route_by_name)
1036 // STRIPABLE .addFunction ("route_by_remote_id", &Session::route_by_remote_id)
1037 .addFunction ("track_by_diskstream_id", &Session::track_by_diskstream_id)
1038 .addFunction ("source_by_id", &Session::source_by_id)
1039 .addFunction ("controllable_by_id", &Session::controllable_by_id)
1040 .addFunction ("processor_by_id", &Session::processor_by_id)
1041 .addFunction ("snap_name", &Session::snap_name)
1042 .addFunction ("monitor_out", &Session::monitor_out)
1043 .addFunction ("master_out", &Session::master_out)
1044 .addFunction ("tempo_map", (TempoMap& (Session::*)())&Session::tempo_map)
1045 .addFunction ("locations", &Session::locations)
1046 .addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command)
1047 .addFunction ("commit_reversible_command", &Session::commit_reversible_command)
1048 .addFunction ("abort_reversible_command", &Session::abort_reversible_command)
1049 .addFunction ("add_command", &Session::add_command)
1050 .addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command)
1051 .addFunction ("engine", (AudioEngine& (Session::*)())&Session::engine)
1052 .addFunction ("get_block_size", &Session::get_block_size)
1053 .addFunction ("worst_output_latency", &Session::worst_output_latency)
1054 .addFunction ("worst_input_latency", &Session::worst_input_latency)
1055 .addFunction ("worst_track_latency", &Session::worst_track_latency)
1056 .addFunction ("worst_playback_latency", &Session::worst_playback_latency)
1059 .beginClass <RegionFactory> ("RegionFactory")
1060 .addStaticFunction ("region_by_id", &RegionFactory::region_by_id)
1063 /* session enums (rt-safe, common) */
1064 .beginNamespace ("Session")
1066 .beginNamespace ("RecordState")
1067 .addConst ("Disabled", ARDOUR::Session::RecordState(Session::Disabled))
1068 .addConst ("Enabled", ARDOUR::Session::RecordState(Session::Enabled))
1069 .addConst ("Recording", ARDOUR::Session::RecordState(Session::Recording))
1072 .endNamespace () // end Session enums
1074 /* ardour enums (rt-safe, common) */
1075 .beginNamespace ("LocationFlags")
1076 .addConst ("IsMark", ARDOUR::Location::Flags(Location::IsMark))
1077 .addConst ("IsAutoPunch", ARDOUR::Location::Flags(Location::IsAutoPunch))
1078 .addConst ("IsAutoLoop", ARDOUR::Location::Flags(Location::IsAutoLoop))
1079 .addConst ("IsHidden", ARDOUR::Location::Flags(Location::IsHidden))
1080 .addConst ("IsCDMarker", ARDOUR::Location::Flags(Location::IsCDMarker))
1081 .addConst ("IsRangeMarker", ARDOUR::Location::Flags(Location::IsRangeMarker))
1082 .addConst ("IsSessionRange", ARDOUR::Location::Flags(Location::IsSessionRange))
1083 .addConst ("IsSkip", ARDOUR::Location::Flags(Location::IsSkip))
1084 .addConst ("IsSkipping", ARDOUR::Location::Flags(Location::IsSkipping))
1087 .beginNamespace ("LuaAPI")
1088 .addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor)
1089 .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
1090 .addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
1091 .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
1092 .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
1093 .addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
1094 .addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
1095 .addFunction ("usleep", Glib::usleep)
1096 .endNamespace () // end LuaAPI
1097 .endNamespace ();// end ARDOUR
1101 LuaBindings::dsp (lua_State* L)
1103 luabridge::getGlobalNamespace (L)
1104 .beginNamespace ("ARDOUR")
1106 .beginClass <AudioBuffer> ("AudioBuffer")
1108 .addFunction ("data", (Sample*(AudioBuffer::*)(framecnt_t))&AudioBuffer::data)
1109 .addFunction ("silence", &AudioBuffer::silence)
1110 .addFunction ("apply_gain", &AudioBuffer::apply_gain)
1111 .addFunction ("check_silence", &AudioBuffer::check_silence)
1112 .addFunction ("read_from", (void (AudioBuffer::*)(const Sample*, framecnt_t, framecnt_t, framecnt_t))&AudioBuffer::check_silence)
1115 .beginClass <MidiBuffer> ("MidiBuffer")
1117 .addFunction ("silence", &MidiBuffer::silence)
1118 .addFunction ("push_event", (bool (MidiBuffer::*)(const Evoral::MIDIEvent<framepos_t>&))&MidiBuffer::push_back)
1119 .addFunction ("push_back", (bool (MidiBuffer::*)(framepos_t, size_t, const uint8_t*))&MidiBuffer::push_back)
1121 .addExtCFunction ("table", &luabridge::CFunc::listToTable<const Evoral::MIDIEvent<framepos_t>, MidiBuffer>)
1124 .beginClass <BufferSet> ("BufferSet")
1126 .addFunction ("get_audio", static_cast<AudioBuffer&(BufferSet::*)(size_t)>(&BufferSet::get_audio))
1127 .addFunction ("count", static_cast<const ChanCount&(BufferSet::*)()const>(&BufferSet::count))
1131 luabridge::getGlobalNamespace (L)
1132 .beginNamespace ("Evoral")
1133 .beginClass <Evoral::Event<framepos_t> > ("Event")
1134 .addFunction ("clear", &Evoral::Event<framepos_t>::clear)
1135 .addFunction ("size", &Evoral::Event<framepos_t>::size)
1136 .addFunction ("set_buffer", &Evoral::Event<framepos_t>::set_buffer)
1137 .addFunction ("buffer", (uint8_t*(Evoral::Event<framepos_t>::*)())&Evoral::Event<framepos_t>::buffer)
1140 .beginClass <Evoral::Beats> ("Beats")
1141 .addFunction ("to_double", &Evoral::Beats::to_double)
1144 .deriveClass <Evoral::MIDIEvent<framepos_t>, Evoral::Event<framepos_t> > ("MidiEvent")
1146 .addFunction ("type", &Evoral::MIDIEvent<framepos_t>::type)
1147 .addFunction ("channel", &Evoral::MIDIEvent<framepos_t>::channel)
1148 .addFunction ("set_type", &Evoral::MIDIEvent<framepos_t>::set_type)
1149 .addFunction ("set_channel", &Evoral::MIDIEvent<framepos_t>::set_channel)
1153 // dsp releated session functions
1154 luabridge::getGlobalNamespace (L)
1155 .beginNamespace ("ARDOUR")
1156 .beginClass <Session> ("Session")
1157 .addFunction ("get_scratch_buffers", &Session::get_scratch_buffers)
1158 .addFunction ("get_silent_buffers", &Session::get_silent_buffers)
1162 luabridge::getGlobalNamespace (L)
1163 .beginNamespace ("ARDOUR")
1164 .beginNamespace ("DSP")
1165 .addFunction ("compute_peak", ARDOUR::compute_peak)
1166 .addFunction ("find_peaks", ARDOUR::find_peaks)
1167 .addFunction ("apply_gain_to_buffer", ARDOUR::apply_gain_to_buffer)
1168 .addFunction ("mix_buffers_no_gain", ARDOUR::mix_buffers_no_gain)
1169 .addFunction ("mix_buffers_with_gain", ARDOUR::mix_buffers_with_gain)
1170 .addFunction ("copy_vector", ARDOUR::copy_vector)
1171 .addFunction ("dB_to_coefficient", &dB_to_coefficient)
1172 .addFunction ("fast_coefficient_to_dB", &fast_coefficient_to_dB)
1173 .addFunction ("accurate_coefficient_to_dB", &accurate_coefficient_to_dB)
1174 .addFunction ("memset", &DSP::memset)
1175 .addFunction ("mmult", &DSP::mmult)
1176 .addFunction ("log_meter", &DSP::log_meter)
1177 .addFunction ("log_meter_coeff", &DSP::log_meter_coeff)
1178 .addRefFunction ("peaks", &DSP::peaks)
1180 .beginClass <DSP::LowPass> ("LowPass")
1181 .addConstructor <void (*) (double, float)> ()
1182 .addFunction ("proc", &DSP::LowPass::proc)
1183 .addFunction ("ctrl", &DSP::LowPass::ctrl)
1184 .addFunction ("set_cutoff", &DSP::LowPass::set_cutoff)
1185 .addFunction ("reset", &DSP::LowPass::reset)
1187 .beginClass <DSP::Biquad> ("Biquad")
1188 .addConstructor <void (*) (double)> ()
1189 .addFunction ("run", &DSP::Biquad::run)
1190 .addFunction ("compute", &DSP::Biquad::compute)
1191 .addFunction ("reset", &DSP::Biquad::reset)
1192 .addFunction ("dB_at_freq", &DSP::Biquad::dB_at_freq)
1196 .beginNamespace ("BiquadType")
1197 .addConst ("LowPass", ARDOUR::DSP::Biquad::LowPass)
1198 .addConst ("HighPass", ARDOUR::DSP::Biquad::HighPass)
1199 .addConst ("BandPassSkirt", ARDOUR::DSP::Biquad::BandPassSkirt)
1200 .addConst ("BandPass0dB", ARDOUR::DSP::Biquad::BandPass0dB)
1201 .addConst ("Notch", ARDOUR::DSP::Biquad::Notch)
1202 .addConst ("AllPass", ARDOUR::DSP::Biquad::AllPass)
1203 .addConst ("Peaking", ARDOUR::DSP::Biquad::Peaking)
1204 .addConst ("LowShelf", ARDOUR::DSP::Biquad::LowShelf)
1205 .addConst ("HighShelf", ARDOUR::DSP::Biquad::HighShelf)
1208 .beginClass <DSP::DspShm> ("DspShm")
1209 .addFunction ("allocate", &DSP::DspShm::allocate)
1210 .addFunction ("clear", &DSP::DspShm::clear)
1211 .addFunction ("to_float", &DSP::DspShm::to_float)
1212 .addFunction ("to_int", &DSP::DspShm::to_int)
1213 .addFunction ("atomic_set_int", &DSP::DspShm::atomic_set_int)
1214 .addFunction ("atomic_get_int", &DSP::DspShm::atomic_get_int)
1217 .endNamespace () // DSP
1218 .endNamespace (); // ARDOUR
1222 LuaBindings::session (lua_State* L)
1224 // non-realtime session functions
1225 luabridge::getGlobalNamespace (L)
1226 .beginNamespace ("ARDOUR")
1227 .beginClass <Session> ("Session")
1228 .addFunction ("save_state", &Session::save_state)
1229 .addFunction ("set_dirty", &Session::set_dirty)
1230 .addFunction ("unknown_processors", &Session::unknown_processors)
1232 .addFunction<RouteList (Session::*)(uint32_t, const std::string&, const std::string&, PlaylistDisposition)> ("new_route_from_template", &Session::new_route_from_template)
1233 // TODO session_add_audio_track session_add_midi_track session_add_mixed_track
1234 //.addFunction ("new_midi_track", &Session::new_midi_track)
1237 .endNamespace (); // ARDOUR
1241 LuaBindings::osc (lua_State* L)
1243 luabridge::getGlobalNamespace (L)
1244 .beginNamespace ("ARDOUR")
1245 .beginNamespace ("LuaOSC")
1246 .beginClass<LuaOSC::Address> ("Address")
1247 .addConstructor<void (*) (std::string)> ()
1248 .addCFunction ("send", &LuaOSC::Address::send)
1255 LuaBindings::set_session (lua_State* L, Session *s)
1257 /* LuaBridge uses unique keys to identify classes/c-types.
1259 * Those keys are "generated" by using the memory-address of a static
1260 * variable, templated for every Class.
1261 * (see libs/lua/LuaBridge/detail/ClassInfo.h)
1263 * When linking the final executable there must be exactly one static
1264 * function (static variable) for every templated class.
1265 * This works fine on OSX and Linux...
1267 * Windows (mingw and MSVC) however expand the template differently for libardour
1268 * AND gtk2_ardour. We end up with two identical static functions
1269 * at different addresses!!
1271 * The Solution: have gtk2_ardour never include LuaBridge headers directly
1272 * and always go via libardour function calls for classes that are registered
1273 * in libardour. (calling lua itself is fine, calling c-functions in the GUI
1274 * which expand the template is not)
1276 * (the actual cause: even static symbols in a .dll have no fixed address
1277 * and are mapped when loading the dll. static functions in .exe do have a fixed
1281 * 0000000000000000 I __imp__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1282 * 0000000000000000 I __nm__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1283 * 0000000000000000 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
1286 * 000000000104f560 d .data$_ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1287 * 000000000104f560 D _ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1288 * 0000000000e9baf0 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
1292 luabridge::push <Session *> (L, s);
1293 lua_setglobal (L, "Session");
1296 // call lua function.
1297 luabridge::LuaRef cb_ses = luabridge::getGlobal (L, "new_session");
1298 if (cb_ses.type() == LUA_TFUNCTION) { cb_ses(s->name()); } // TODO args