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::PortManager);
175 CLASSKEYS(ARDOUR::AudioEngine);
179 #endif // end windows special case
181 /* Some notes on Lua bindings for libardour and friends
183 * - Prefer factory methods over Contructors whenever possible.
184 * Don't expose the constructor method unless required.
186 * e.g. Don't allow the script to construct a "Track" Object directly
187 * but do allow to create a "BBT_TIME" object.
189 * - Do not dereference Shared or Weak Pointers. Pass the pointer to Lua.
190 * - Define Objects as boost:shared_ptr Object whenever possible.
192 * Storing a boost::shared_ptr in a Lua-variable keeps the reference
193 * until that variable is set to 'nil'.
194 * (if the script were to keep a direct pointer to the object instance, the
195 * behaviour is undefined if the actual object goes away)
197 * Methods of the actual class are indirectly exposed,
198 * boost::*_ptr get() and ::lock() is implicit when the class is exported
199 * as LuaBridge's "WSPtrClass".
202 using namespace ARDOUR;
205 LuaBindings::stddef (lua_State* L)
207 // std::list<std::string>
208 luabridge::getGlobalNamespace (L)
209 .beginNamespace ("C")
210 .beginStdList <std::string> ("StringList")
213 // std::vector<std::string>
214 .beginStdVector <std::string> ("StringVector")
217 // register float array (float*)
218 .registerArray <float> ("FloatArray")
220 // register float array (int32_t*)
221 .registerArray <int32_t> ("IntArray")
228 LuaBindings::common (lua_State* L)
230 luabridge::getGlobalNamespace (L)
231 .beginNamespace ("PBD")
232 .beginClass <PBD::ID> ("ID")
233 .addConstructor <void (*) (std::string)> ()
234 .addFunction ("to_s", &PBD::ID::to_s) // TODO special case LUA __tostring ?
237 .beginClass <XMLNode> ("XMLNode")
238 .addFunction ("name", &XMLNode::name)
241 .beginClass <PBD::Stateful> ("Stateful")
242 .addFunction ("id", &PBD::Stateful::id)
243 .addFunction ("properties", &PBD::Stateful::properties)
244 .addFunction ("clear_changes", &PBD::Stateful::clear_changes)
247 .beginWSPtrClass <PBD::Stateful> ("StatefulPtr")
248 .addFunction ("id", &PBD::Stateful::id)
249 .addFunction ("properties", &PBD::Stateful::properties)
250 .addFunction ("clear_changes", &PBD::Stateful::clear_changes)
253 .deriveClass <PBD::StatefulDestructible, PBD::Stateful> ("StatefulDestructible")
256 .deriveWSPtrClass <PBD::StatefulDestructible, PBD::Stateful> ("StatefulDestructiblePtr")
259 .deriveClass <Command, PBD::StatefulDestructible> ("Command")
260 .addFunction ("set_name", &Command::set_name)
261 .addFunction ("name", &Command::name)
264 /* UndoTransaction::add_command() subscribes to DropReferences()
265 * and deletes the object.
267 * This object cannot be constructed by lua because lua would manage lifetime
268 * and delete the object leading to a double free.
270 * use Session::add_stateful_diff_command()
271 * and Session::abort_reversible_command()
273 .deriveClass <PBD::StatefulDiffCommand, Command> ("StatefulDiffCommand")
274 .addFunction ("undo", &PBD::StatefulDiffCommand::undo)
275 .addFunction ("empty", &PBD::StatefulDiffCommand::empty)
278 .deriveWSPtrClass <PBD::Controllable, PBD::StatefulDestructible> ("Controllable")
279 .addFunction ("name", &PBD::Controllable::name)
280 .addFunction ("get_value", &PBD::Controllable::get_value)
284 .beginNamespace ("GroupControlDisposition")
285 .addConst ("InverseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::InverseGroup))
286 .addConst ("NoGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::NoGroup))
287 .addConst ("UseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::UseGroup))
290 .endNamespace (); // PBD
292 luabridge::getGlobalNamespace (L)
293 .beginNamespace ("Timecode")
294 .beginClass <Timecode::BBT_Time> ("BBT_TIME")
295 .addConstructor <void (*) (uint32_t, uint32_t, uint32_t)> ()
299 luabridge::getGlobalNamespace (L)
301 .beginNamespace ("Evoral")
302 .beginClass <Evoral::Parameter> ("Parameter")
303 .addConstructor <void (*) (uint32_t, uint8_t, uint32_t)> ()
304 .addFunction ("type", &Evoral::Parameter::type)
305 .addFunction ("channel", &Evoral::Parameter::channel)
306 .addFunction ("id", &Evoral::Parameter::id)
309 .beginWSPtrClass <Evoral::ControlList> ("ControlList")
310 .addFunction ("add", &Evoral::ControlList::add)
311 .addFunction ("thin", &Evoral::ControlList::thin)
312 .addFunction ("eval", &Evoral::ControlList::eval)
313 .addRefFunction ("rt_safe_eval", &Evoral::ControlList::rt_safe_eval)
314 .addFunction ("interpolation", &Evoral::ControlList::interpolation)
315 .addFunction ("set_interpolation", &Evoral::ControlList::set_interpolation)
316 .addFunction ("truncate_end", &Evoral::ControlList::truncate_end)
317 .addFunction ("truncate_start", &Evoral::ControlList::truncate_start)
318 .addFunction ("clear", (void (Evoral::ControlList::*)(double, double))&Evoral::ControlList::clear)
319 .addFunction ("in_write_pass", &Evoral::ControlList::in_write_pass)
322 .beginWSPtrClass <Evoral::ControlSet> ("ControlSet")
325 .beginWSPtrClass <Evoral::Control> ("Control")
326 .addFunction ("list", (boost::shared_ptr<Evoral::ControlList>(Evoral::Control::*)())&Evoral::Control::list)
329 .beginClass <Evoral::ParameterDescriptor> ("ParameterDescriptor")
330 .addVoidConstructor ()
331 .addData ("lower", &Evoral::ParameterDescriptor::lower)
332 .addData ("upper", &Evoral::ParameterDescriptor::upper)
333 .addData ("normal", &Evoral::ParameterDescriptor::normal)
334 .addData ("toggled", &Evoral::ParameterDescriptor::toggled)
337 .beginClass <Evoral::Range<framepos_t> > ("Range")
338 .addConstructor <void (*) (framepos_t, framepos_t)> ()
339 .addData ("from", &Evoral::Range<framepos_t>::from)
340 .addData ("to", &Evoral::Range<framepos_t>::to)
343 /* libevoral enums */
344 .beginNamespace ("InterpolationStyle")
345 .addConst ("Discrete", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Discrete))
346 .addConst ("Linear", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Linear))
347 .addConst ("Curved", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Curved))
350 .endNamespace () // Evoral
352 .beginNamespace ("ARDOUR")
354 .beginClass <InterThreadInfo> ("InterThreadInfo")
355 .addVoidConstructor ()
356 .addData ("done", const_cast<bool InterThreadInfo::*>(&InterThreadInfo::done))
357 #if 0 // currently unused, lua is single-threaded, no custom UIs.
358 .addData ("cancel", (bool InterThreadInfo::*)&InterThreadInfo::cancel)
360 .addData ("progress", const_cast<float InterThreadInfo::*>(&InterThreadInfo::progress))
363 .beginClass <AudioRange> ("AudioRange")
364 .addConstructor <void (*) (framepos_t, framepos_t, uint32_t)> ()
365 .addFunction ("length", &AudioRange::length)
366 .addFunction ("equal", &AudioRange::equal)
367 .addData ("start", &AudioRange::start)
368 .addData ("_end", &AudioRange::end) // XXX "end" is a lua reserved word
369 .addData ("id", &AudioRange::id)
372 .beginWSPtrClass <PluginInfo> ("PluginInfo")
373 .addVoidConstructor ()
376 .beginNamespace ("Route")
377 .beginClass <Route::ProcessorStreams> ("ProcessorStreams")
378 .addVoidConstructor ()
382 .beginClass <ChanMapping> ("ChanMapping")
383 .addVoidConstructor ()
384 .addFunction ("get", static_cast<uint32_t(ChanMapping::*)(DataType, uint32_t) const>(&ChanMapping::get))
385 .addFunction ("set", &ChanMapping::set)
386 .addConst ("Invalid", 4294967295U) // UINT32_MAX
389 .beginNamespace ("Properties")
390 // templated class definitions
391 .beginClass <PBD::PropertyDescriptor<bool> > ("BoolProperty").endClass ()
392 .beginClass <PBD::PropertyDescriptor<float> > ("FloatProperty").endClass ()
393 .beginClass <PBD::PropertyDescriptor<framepos_t> > ("FrameposProperty").endClass ()
394 // actual references (TODO: also expose GQuark for std::set)
396 .addConst ("Start", &ARDOUR::Properties::start)
397 .addConst ("Length", &ARDOUR::Properties::length)
398 .addConst ("Position", &ARDOUR::Properties::position)
401 .beginClass <PBD::PropertyChange> ("PropertyChange")
402 // TODO add special handling (std::set<PropertyID>), PropertyID is a GQuark.
403 // -> direct map to lua table beginStdSet()A
405 // expand templated PropertyDescriptor<T>
406 .addFunction ("containsBool", &PBD::PropertyChange::contains<bool>)
407 .addFunction ("containsFloat", &PBD::PropertyChange::contains<float>)
408 .addFunction ("containsFramePos", &PBD::PropertyChange::contains<framepos_t>)
411 .beginClass <PBD::PropertyList> ("PropertyList")
412 // is-a std::map<PropertyID, PropertyBase*>
415 .deriveClass <PBD::OwnedPropertyList, PBD::PropertyList> ("OwnedPropertyList")
418 .beginWSPtrClass <AutomationList> ("AutomationList")
419 .addCast<PBD::Stateful> ("to_stateful")
420 .addCast<PBD::StatefulDestructible> ("to_statefuldestructible")
421 .addCast<Evoral::ControlList> ("list")
422 .addFunction ("get_state", &AutomationList::get_state)
423 .addFunction ("memento_command", &AutomationList::memento_command)
424 .addFunction ("touching", &AutomationList::touching)
425 .addFunction ("writing", &AutomationList::writing)
426 .addFunction ("touch_enabled", &AutomationList::touch_enabled)
429 .deriveClass <Location, PBD::StatefulDestructible> ("Location")
430 .addFunction ("locked", &Location::locked)
431 .addFunction ("lock", &Location::lock)
432 .addFunction ("start", &Location::start)
433 .addFunction ("_end", &Location::end) // XXX "end" is a lua reserved word
434 .addFunction ("length", &Location::length)
435 .addFunction ("set_start", &Location::set_start)
436 .addFunction ("set_end", &Location::set_end)
437 .addFunction ("set_length", &Location::set)
438 .addFunction ("move_to", &Location::move_to)
441 .deriveClass <Locations, PBD::StatefulDestructible> ("Locations")
442 .addFunction ("auto_loop_location", &Locations::auto_loop_location)
443 .addFunction ("auto_punch_location", &Locations::auto_punch_location)
444 .addFunction ("session_range_location", &Locations::session_range_location)
445 .addFunction ("first_mark_after", &Locations::first_mark_after)
446 .addFunction ("first_mark_before", &Locations::first_mark_before)
447 .addFunction ("first_mark_at", &Locations::mark_at)
448 .addRefFunction ("marks_either_side", &Locations::marks_either_side)
449 .addRefFunction ("find_all_between", &Locations::find_all_between)
452 .beginWSPtrClass <SessionObject> ("SessionObject")
453 /* SessionObject is-a PBD::StatefulDestructible,
454 * but multiple inheritance is not covered by luabridge,
455 * we need explicit casts */
456 .addCast<PBD::Stateful> ("to_stateful")
457 .addCast<PBD::StatefulDestructible> ("to_statefuldestructible")
458 .addFunction ("name", &SessionObject::name)
461 .beginWSPtrClass <Port> ("Port")
462 .addFunction ("name", &Port::name)
463 .addFunction ("pretty_name", &Port::pretty_name)
464 .addFunction ("receives_input", &Port::receives_input)
465 .addFunction ("sends_output", &Port::sends_output)
466 .addFunction ("connected", &Port::connected)
467 .addFunction ("disconnect_all", &Port::disconnect_all)
468 .addFunction ("connected_to_name", (bool (Port::*)(std::string const &)const)&Port::connected_to)
469 .addFunction ("connect_by_name", (int (Port::*)(std::string const &))&Port::connect)
470 .addFunction ("disconnect_by_name", (int (Port::*)(std::string const &))&Port::disconnect)
471 .addFunction ("connected_to", (bool (Port::*)(Port*)const)&Port::connected_to)
472 .addFunction ("connect", (int (Port::*)(Port*))&Port::connect)
473 .addFunction ("disconnect", (int (Port::*)(Port*))&Port::disconnect)
476 .deriveWSPtrClass <AudioPort, Port> ("AudioPort")
479 .deriveWSPtrClass <MidiPort, Port> ("MidiPort")
480 .addFunction ("input_active", &MidiPort::input_active)
481 .addFunction ("set_input_active", &MidiPort::set_input_active)
484 .beginWSPtrClass <PortSet> ("PortSet")
485 .addFunction ("num_ports", (size_t (PortSet::*)(DataType)const)&PortSet::num_ports)
486 .addFunction ("add", &PortSet::add)
487 .addFunction ("remove", &PortSet::remove)
488 .addFunction ("port", (boost::shared_ptr<Port> (PortSet::*)(DataType, size_t)const)&PortSet::port)
489 .addFunction ("contains", &PortSet::contains)
490 .addFunction ("clear", &PortSet::clear)
491 .addFunction ("empty", &PortSet::empty)
494 .deriveWSPtrClass <IO, SessionObject> ("IO")
495 .addFunction ("active", &IO::active)
496 .addFunction ("add_port", &IO::add_port)
497 .addFunction ("remove_port", &IO::remove_port)
498 .addFunction ("connect", &IO::connect)
499 .addFunction ("disconnect", (int (IO::*)(boost::shared_ptr<Port>, std::string, void *))&IO::disconnect)
500 .addFunction ("physically_connected", &IO::physically_connected)
501 .addFunction ("has_port", &IO::has_port)
502 .addFunction ("nth", &IO::nth)
503 .addFunction ("audio", &IO::audio)
504 .addFunction ("midi", &IO::midi)
505 .addFunction ("port_by_name", &IO::nth)
506 .addFunction ("n_ports", &IO::n_ports)
509 .beginClass <RouteGroup> ("RouteGroup")
510 // stub RouteGroup* is needed for new_audio_track()
513 .deriveWSPtrClass <Route, SessionObject> ("Route")
514 .addCast<Track> ("to_track")
515 .addFunction ("set_name", &Route::set_name)
516 .addFunction ("comment", &Route::comment)
517 .addFunction ("active", &Route::active)
518 .addFunction ("set_active", &Route::set_active)
519 .addFunction ("nth_plugin", &Route::nth_plugin)
520 .addFunction ("nth_processor", &Route::nth_processor)
521 .addFunction ("nth_send", &Route::nth_send)
522 .addFunction ("add_processor_by_index", &Route::add_processor_by_index)
523 .addFunction ("remove_processor", &Route::remove_processor)
524 .addFunction ("replace_processor", &Route::replace_processor)
525 .addFunction ("n_inputs", &Route::n_inputs)
526 .addFunction ("n_outputs", &Route::n_outputs)
527 .addFunction ("set_comment", &Route::set_comment)
528 .addFunction ("strict_io", &Route::strict_io)
529 .addFunction ("set_strict_io", &Route::set_strict_io)
530 .addFunction ("reset_plugin_insert", &Route::reset_plugin_insert)
531 .addFunction ("customize_plugin_insert", &Route::customize_plugin_insert)
532 .addFunction ("add_sidechain", &Route::add_sidechain)
533 .addFunction ("remove_sidechain", &Route::remove_sidechain)
534 .addFunction ("main_outs", &Route::main_outs)
535 .addFunction ("muted", &Route::muted)
536 .addFunction ("soloed", &Route::soloed)
537 .addFunction ("amp", &Route::amp)
538 .addFunction ("trim", &Route::trim)
541 .deriveWSPtrClass <Playlist, SessionObject> ("Playlist")
542 .addFunction ("region_by_id", &Playlist::region_by_id)
543 .addFunction ("data_type", &Playlist::data_type)
544 .addFunction ("n_regions", &Playlist::n_regions)
545 //.addFunction ("get_extent", &Playlist::get_extent) // pair<framepos_t, framepos_t>
546 //.addFunction ("region_list", &Playlist::region_list) // RegionListProperty&
547 .addFunction ("add_region", &Playlist::add_region)
548 .addFunction ("remove_region", &Playlist::remove_region)
549 .addFunction ("regions_at", &Playlist::regions_at)
550 .addFunction ("top_region_at", &Playlist::top_region_at)
551 .addFunction ("top_unmuted_region_at", &Playlist::top_unmuted_region_at)
552 .addFunction ("find_next_region", &Playlist::find_next_region)
553 .addFunction ("find_next_region_boundary", &Playlist::find_next_region_boundary)
554 .addFunction ("count_regions_at", &Playlist::count_regions_at)
555 .addFunction ("regions_touched", &Playlist::regions_touched)
556 .addFunction ("regions_with_start_within", &Playlist::regions_with_start_within)
557 .addFunction ("regions_with_end_within", &Playlist::regions_with_end_within)
558 .addFunction ("raise_region", &Playlist::raise_region)
559 .addFunction ("lower_region", &Playlist::lower_region)
560 .addFunction ("raise_region_to_top", &Playlist::raise_region_to_top)
561 .addFunction ("lower_region_to_bottom", &Playlist::lower_region_to_bottom)
562 .addFunction ("duplicate", (void (Playlist::*)(boost::shared_ptr<Region>, framepos_t, framecnt_t, float))&Playlist::duplicate)
563 .addFunction ("duplicate_until", &Playlist::duplicate_until)
564 .addFunction ("duplicate_range", &Playlist::duplicate_range)
565 .addFunction ("combine", &Playlist::combine)
566 .addFunction ("uncombine", &Playlist::uncombine)
567 .addFunction ("split_region", &Playlist::split_region)
568 .addFunction ("split", (void (Playlist::*)(framepos_t))&Playlist::split)
569 .addFunction ("cut", (boost::shared_ptr<Playlist> (Playlist::*)(std::list<AudioRange>&, bool))&Playlist::cut)
571 .addFunction ("copy", &Playlist::copy)
572 .addFunction ("paste", &Playlist::paste)
576 .deriveWSPtrClass <Track, Route> ("Track")
577 .addCast<AudioTrack> ("to_audio_track")
578 .addCast<MidiTrack> ("to_midi_track")
579 .addFunction ("set_name", &Track::set_name)
580 .addFunction ("can_record", &Track::can_record)
581 .addFunction ("record_enabled", &Track::record_enabled)
582 .addFunction ("record_safe", &Track::record_safe)
583 .addFunction ("set_record_enabled", &Track::set_record_enabled)
584 .addFunction ("set_record_safe", &Track::set_record_safe)
585 .addFunction ("bounceable", &Track::bounceable)
586 .addFunction ("bounce", &Track::bounce)
587 .addFunction ("bounce_range", &Track::bounce_range)
588 .addFunction ("playlist", &Track::playlist)
591 .deriveWSPtrClass <AudioTrack, Track> ("AudioTrack")
594 .deriveWSPtrClass <MidiTrack, Track> ("MidiTrack")
597 .deriveWSPtrClass <Region, SessionObject> ("Region")
599 .addFunction ("position", &Region::position)
600 .addFunction ("start", &Region::start)
601 .addFunction ("length", &Region::length)
602 .addFunction ("layer", &Region::layer)
603 .addFunction ("data_type", &Region::data_type)
604 .addFunction ("stretch", &Region::stretch)
605 .addFunction ("shift", &Region::shift)
606 .addRefFunction ("sync_offset", &Region::sync_offset)
607 .addFunction ("sync_position", &Region::sync_position)
608 .addFunction ("hidden", &Region::hidden)
609 .addFunction ("muted", &Region::muted)
610 .addFunction ("opaque", &Region::opaque)
611 .addFunction ("locked", &Region::locked)
612 .addFunction ("position_locked", &Region::position_locked)
613 .addFunction ("video_locked", &Region::video_locked)
614 .addFunction ("automatic", &Region::automatic)
615 .addFunction ("whole_file", &Region::whole_file)
616 .addFunction ("captured", &Region::captured)
617 .addFunction ("can_move", &Region::can_move)
618 .addFunction ("sync_marked", &Region::sync_marked)
619 .addFunction ("external", &Region::external)
620 .addFunction ("import", &Region::import)
621 .addFunction ("covers", &Region::covers)
622 .addFunction ("at_natural_position", &Region::at_natural_position)
623 .addFunction ("is_compound", &Region::is_compound)
624 /* editing operations */
625 .addFunction ("set_length", &Region::set_length)
626 .addFunction ("set_start", &Region::set_start)
627 .addFunction ("set_position", &Region::set_position)
628 .addFunction ("set_initial_position", &Region::set_initial_position)
629 .addFunction ("nudge_position", &Region::nudge_position)
630 .addFunction ("move_to_natural_position", &Region::move_to_natural_position)
631 .addFunction ("move_start", &Region::move_start)
632 .addFunction ("trim_front", &Region::trim_front)
633 .addFunction ("trim_end", &Region::trim_end)
634 .addFunction ("trim_to", &Region::trim_to)
635 .addFunction ("cut_front", &Region::cut_front)
636 .addFunction ("cut_end", &Region::cut_end)
637 .addFunction ("raise", &Region::raise)
638 .addFunction ("lower", &Region::lower)
639 .addFunction ("raise_to_top", &Region::raise_to_top)
640 .addFunction ("lower_to_bottom", &Region::lower_to_bottom)
641 .addFunction ("set_sync_position", &Region::set_sync_position)
642 .addFunction ("clear_sync_position", &Region::clear_sync_position)
643 .addFunction ("set_hidden", &Region::set_hidden)
644 .addFunction ("set_muted", &Region::set_muted)
645 .addFunction ("set_opaque", &Region::set_opaque)
646 .addFunction ("set_locked", &Region::set_locked)
647 .addFunction ("set_video_locked", &Region::set_video_locked)
648 .addFunction ("set_position_locked", &Region::set_position_locked)
651 .beginWSPtrClass <Source> ("Source")
654 .beginClass <Plugin::PresetRecord> ("PresetRecord")
655 .addVoidConstructor ()
656 .addData ("uri", &Plugin::PresetRecord::uri, false)
657 .addData ("label", &Plugin::PresetRecord::label, false)
658 .addData ("user", &Plugin::PresetRecord::user, false)
659 .addData ("valid", &Plugin::PresetRecord::valid, false)
662 .deriveWSPtrClass <Automatable, Evoral::ControlSet> ("Automatable")
663 .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
666 .deriveClass <ParameterDescriptor, Evoral::ParameterDescriptor> ("ParameterDescriptor")
667 .addVoidConstructor ()
668 .addData ("label", &ParameterDescriptor::label)
669 .addData ("logarithmic", &ParameterDescriptor::logarithmic)
672 .deriveWSPtrClass <Processor, SessionObject> ("Processor")
673 .addCast<Automatable> ("to_automatable")
674 .addCast<PluginInsert> ("to_insert")
675 .addCast<SideChain> ("to_sidechain")
676 .addCast<IOProcessor> ("to_ioprocessor")
677 .addCast<UnknownProcessor> ("to_unknownprocessor")
678 .addCast<Amp> ("to_amp")
679 #if 0 // those objects are not yet bound
680 .addCast<MonitorProcessor> ("to_monitorprocessor")
681 .addCast<CapturingProcessor> ("to_capturingprocessor")
682 .addCast<DelayLine> ("to_delayline")
683 .addCast<PeakMeter> ("to_meter")
685 .addFunction ("display_name", &Processor::display_name)
686 .addFunction ("active", &Processor::active)
687 .addFunction ("activate", &Processor::activate)
688 .addFunction ("deactivate", &Processor::deactivate)
689 .addFunction ("control", (boost::shared_ptr<Evoral::Control>(Evoral::ControlSet::*)(const Evoral::Parameter&, bool))&Evoral::ControlSet::control)
690 .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
693 .deriveWSPtrClass <IOProcessor, Processor> ("IOProcessor")
694 .addFunction ("natural_input_streams", &IOProcessor::natural_input_streams)
695 .addFunction ("natural_output_streams", &IOProcessor::natural_output_streams)
696 .addFunction ("input", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::input)
697 .addFunction ("output", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::output)
700 .deriveWSPtrClass <SideChain, IOProcessor> ("SideChain")
703 .deriveWSPtrClass <Delivery, IOProcessor> ("Delivery")
706 .deriveWSPtrClass <Plugin, PBD::StatefulDestructible> ("Plugin")
707 .addFunction ("label", &Plugin::label)
708 .addFunction ("name", &Plugin::name)
709 .addFunction ("maker", &Plugin::maker)
710 .addFunction ("parameter_count", &Plugin::parameter_count)
711 .addRefFunction ("nth_parameter", &Plugin::nth_parameter)
712 .addFunction ("preset_by_label", &Plugin::preset_by_label)
713 .addFunction ("preset_by_uri", &Plugin::preset_by_uri)
714 .addFunction ("load_preset", &Plugin::load_preset)
715 .addFunction ("parameter_is_input", &Plugin::parameter_is_input)
716 .addFunction ("get_docs", &Plugin::get_docs)
717 .addFunction ("get_parameter_docs", &Plugin::get_parameter_docs)
718 .addRefFunction ("get_parameter_descriptor", &Plugin::get_parameter_descriptor)
721 .deriveWSPtrClass <PluginInsert, Processor> ("PluginInsert")
722 .addFunction ("plugin", &PluginInsert::plugin)
723 .addFunction ("activate", &PluginInsert::activate)
724 .addFunction ("deactivate", &PluginInsert::deactivate)
725 .addFunction ("strict_io_configured", &PluginInsert::strict_io_configured)
726 .addFunction ("input_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::input_map)
727 .addFunction ("output_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::output_map)
728 .addFunction ("set_input_map", &PluginInsert::set_input_map)
729 .addFunction ("set_output_map", &PluginInsert::set_output_map)
730 .addFunction ("sidechain_input", &PluginInsert::sidechain_input)
733 .deriveWSPtrClass <AutomationControl, PBD::Controllable> ("AutomationControl")
734 .addCast<Evoral::Control> ("to_ctrl")
735 .addFunction ("automation_state", &AutomationControl::automation_state)
736 .addFunction ("automation_style", &AutomationControl::automation_style)
737 .addFunction ("set_automation_state", &AutomationControl::set_automation_state)
738 .addFunction ("set_automation_style", &AutomationControl::set_automation_style)
739 .addFunction ("start_touch", &AutomationControl::start_touch)
740 .addFunction ("stop_touch", &AutomationControl::stop_touch)
741 .addFunction ("get_value", &AutomationControl::get_value)
742 .addFunction ("set_value", &AutomationControl::set_value)
743 .addFunction ("writable", &AutomationControl::writable)
744 .addFunction ("alist", &AutomationControl::alist)
747 .deriveWSPtrClass <GainControl, AutomationControl> ("GainControl")
750 .deriveWSPtrClass <Amp, Processor> ("Amp")
751 .addFunction ("gain_control", (boost::shared_ptr<GainControl>(Amp::*)())&Amp::gain_control)
754 .deriveWSPtrClass <UnknownProcessor, Processor> ("UnknownProcessor")
757 .deriveWSPtrClass <PluginInsert::PluginControl, AutomationControl> ("PluginControl")
760 .deriveWSPtrClass <AudioSource, Source> ("AudioSource")
761 .addFunction ("readable_length", &AudioSource::readable_length)
762 .addFunction ("n_channels", &AudioSource::n_channels)
765 // <std::list<boost::shared_ptr <AudioTrack> >
766 .beginStdList <boost::shared_ptr<AudioTrack> > ("AudioTrackList")
769 // std::list<boost::shared_ptr <MidiTrack> >
770 .beginStdList <boost::shared_ptr<MidiTrack> > ("MidiTrackList")
773 // RouteList == std::list<boost::shared_ptr<Route> >
774 .beginConstStdList <boost::shared_ptr<Route> > ("RouteList")
777 // boost::shared_ptr<RouteList>
778 .beginPtrStdList <boost::shared_ptr<Route> > ("RouteListPtr")
781 // typedef std::list<boost::weak_ptr <Route> > WeakRouteList
782 .beginConstStdList <boost::weak_ptr<Route> > ("WeakRouteList")
785 // std::list< boost::weak_ptr <AudioSource> >
786 .beginConstStdList <boost::weak_ptr<AudioSource> > ("WeakAudioSourceList")
789 // typedef std::list<boost::shared_ptr<Region> > RegionList
790 .beginConstStdList <boost::shared_ptr<Region> > ("RegionList")
793 // boost::shared_ptr <std::list<boost::shared_ptr<Region> > >
794 .beginPtrStdList <boost::shared_ptr<Region> > ("RegionListPtr")
797 //std::list<boost::shared_ptr<Port> > PortList;
798 .beginConstStdList <boost::shared_ptr<Port> > ("PortList")
801 // used by Playlist::cut/copy
802 .beginConstStdList <AudioRange> ("AudioRangeList")
805 .beginConstStdList <Location*> ("LocationList")
808 #if 0 // depends on Evoal:: Note, Beats see note_fixer.h
809 // typedef Evoral::Note<Evoral::Beats> Note;
810 // std::set< boost::weak_ptr<Note> >
811 .beginStdSet <boost::weak_ptr<Note> > ("WeakNoteSet")
815 // std::list<boost::weak_ptr<Source> >
816 .beginConstStdList <boost::weak_ptr<Source> > ("WeakSourceList")
819 .beginClass <Tempo> ("Tempo")
820 .addConstructor <void (*) (double, double)> ()
821 .addFunction ("note_type", &Tempo::note_type)
822 .addFunction ("beats_per_minute", &Tempo::beats_per_minute)
823 .addFunction ("frames_per_beat", &Tempo::frames_per_beat)
826 .beginClass <Meter> ("Meter")
827 .addConstructor <void (*) (double, double)> ()
828 .addFunction ("divisions_per_bar", &Meter::divisions_per_bar)
829 .addFunction ("note_divisor", &Meter::note_divisor)
830 .addFunction ("frames_per_bar", &Meter::frames_per_bar)
831 .addFunction ("frames_per_grid", &Meter::frames_per_grid)
834 .beginClass <TempoMap> ("TempoMap")
835 .addFunction ("add_tempo", &TempoMap::add_tempo)
836 .addFunction ("add_meter", &TempoMap::add_meter)
839 .beginClass <ChanCount> ("ChanCount")
840 .addConstructor <void (*) (DataType, uint32_t)> ()
841 .addFunction ("get", &ChanCount::get)
842 .addFunction ("set", &ChanCount::set)
843 .addFunction ("n_audio", &ChanCount::n_audio)
844 .addFunction ("n_midi", &ChanCount::n_midi)
845 .addFunction ("n_total", &ChanCount::n_total)
846 .addFunction ("reset", &ChanCount::reset)
849 .beginClass <DataType> ("DataType")
850 .addConstructor <void (*) (std::string)> ()
851 .addStaticCFunction ("null", &LuaAPI::datatype_ctor_null) // "nil" is a lua reseved word
852 .addStaticCFunction ("audio", &LuaAPI::datatype_ctor_audio)
853 .addStaticCFunction ("midi", &LuaAPI::datatype_ctor_midi)
854 .addFunction ("to_string", &DataType::to_string) // TODO Lua __tostring
855 // TODO add uint32_t cast, add operator== !=
858 /* libardour enums */
859 .beginNamespace ("PluginType")
860 .addConst ("AudioUnit", ARDOUR::PluginType(AudioUnit))
861 .addConst ("LADSPA", ARDOUR::PluginType(LADSPA))
862 .addConst ("LV2", ARDOUR::PluginType(LV2))
863 .addConst ("Windows_VST", ARDOUR::PluginType(Windows_VST))
864 .addConst ("LXVST", ARDOUR::PluginType(LXVST))
865 .addConst ("Lua", ARDOUR::PluginType(Lua))
868 .beginNamespace ("AutoStyle")
869 .addConst ("Absolute", ARDOUR::AutoStyle(Absolute))
870 .addConst ("Trim", ARDOUR::AutoStyle(Trim))
873 .beginNamespace ("AutoState")
874 .addConst ("Off", ARDOUR::AutoState(Off))
875 .addConst ("Write", ARDOUR::AutoState(Write))
876 .addConst ("Touch", ARDOUR::AutoState(Touch))
877 .addConst ("Play", ARDOUR::AutoState(Play))
880 .beginNamespace ("AutomationType")
881 .addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation))
882 .addConst ("PluginAutomation", ARDOUR::AutomationType(GainAutomation))
883 .addConst ("PluginAutomation", ARDOUR::AutomationType(TrimAutomation))
886 .beginNamespace ("SrcQuality")
887 .addConst ("SrcBest", ARDOUR::SrcQuality(SrcBest))
890 .beginNamespace ("PortFlags")
891 .addConst ("IsInput", ARDOUR::PortFlags(IsInput))
892 .addConst ("IsOutput", ARDOUR::PortFlags(IsOutput))
893 .addConst ("IsPhysical", ARDOUR::PortFlags(IsPhysical))
894 .addConst ("CanMonitor", ARDOUR::PortFlags(CanMonitor))
895 .addConst ("IsTerminal", ARDOUR::PortFlags(IsTerminal))
898 .beginNamespace ("PlaylistDisposition")
899 .addConst ("CopyPlaylist", ARDOUR::PlaylistDisposition(CopyPlaylist))
900 .addConst ("NewPlaylist", ARDOUR::PlaylistDisposition(NewPlaylist))
901 .addConst ("SharePlaylist", ARDOUR::PlaylistDisposition(SharePlaylist))
904 .beginNamespace ("RegionPoint")
905 .addConst ("Start", ARDOUR::RegionPoint(Start))
906 .addConst ("End", ARDOUR::RegionPoint(End))
907 .addConst ("SyncPoint", ARDOUR::RegionPoint(SyncPoint))
910 .beginNamespace ("TrackMode")
911 .addConst ("Normal", ARDOUR::TrackMode(Start))
912 .addConst ("NonLayered", ARDOUR::TrackMode(NonLayered))
913 .addConst ("Destructive", ARDOUR::TrackMode(Destructive))
915 .endNamespace (); // end ARDOUR
917 luabridge::getGlobalNamespace (L)
918 .beginNamespace ("ARDOUR")
919 .beginClass <AudioBackendInfo> ("AudioBackendInfo")
920 .addData ("name", &AudioBackendInfo::name)
922 .beginStdVector <const AudioBackendInfo*> ("BackendVector").endClass ()
924 .beginClass <AudioBackend::DeviceStatus> ("DeviceStatus")
925 .addData ("name", &AudioBackend::DeviceStatus::name)
926 .addData ("available", &AudioBackend::DeviceStatus::available)
928 .beginStdVector <AudioBackend::DeviceStatus> ("DeviceStatusVector").endClass ()
930 .beginWSPtrClass <AudioBackend> ("AudioBackend")
931 .addFunction ("info", &AudioBackend::info)
932 .addFunction ("sample_rate", &AudioBackend::sample_rate)
933 .addFunction ("buffer_size", &AudioBackend::buffer_size)
934 .addFunction ("period_size", &AudioBackend::period_size)
935 .addFunction ("input_channels", &AudioBackend::input_channels)
936 .addFunction ("output_channels", &AudioBackend::output_channels)
937 .addFunction ("dsp_load", &AudioBackend::dsp_load)
939 .addFunction ("set_sample_rate", &AudioBackend::set_sample_rate)
940 .addFunction ("set_buffer_size", &AudioBackend::set_buffer_size)
941 .addFunction ("set_peridod_size", &AudioBackend::set_peridod_size)
943 .addFunction ("enumerate_drivers", &AudioBackend::enumerate_drivers)
944 .addFunction ("driver_name", &AudioBackend::driver_name)
945 .addFunction ("set_driver", &AudioBackend::set_driver)
947 .addFunction ("use_separate_input_and_output_devices", &AudioBackend::use_separate_input_and_output_devices)
948 .addFunction ("enumerate_devices", &AudioBackend::enumerate_devices)
949 .addFunction ("enumerate_input_devices", &AudioBackend::enumerate_input_devices)
950 .addFunction ("enumerate_output_devices", &AudioBackend::enumerate_output_devices)
951 .addFunction ("device_name", &AudioBackend::device_name)
952 .addFunction ("input_device_name", &AudioBackend::input_device_name)
953 .addFunction ("output_device_name", &AudioBackend::output_device_name)
954 .addFunction ("set_device_name", &AudioBackend::set_device_name)
955 .addFunction ("set_input_device_name", &AudioBackend::set_input_device_name)
956 .addFunction ("set_output_device_name", &AudioBackend::set_output_device_name)
959 .beginClass <PortManager> ("PortManager")
960 .addFunction ("port_engine", &PortManager::port_engine)
961 .addFunction ("connected", &PortManager::connected)
962 .addFunction ("connect", &PortManager::connect)
963 .addFunction ("physically_connected", &PortManager::physically_connected)
964 .addFunction ("disconnect", (int (PortManager::*)(const std::string&, const std::string&))&PortManager::disconnect)
965 .addFunction ("disconnect_port", (int (PortManager::*)(boost::shared_ptr<Port>))&PortManager::disconnect)
966 .addFunction ("get_port_by_name", &PortManager::get_port_by_name)
967 .addFunction ("get_pretty_name_by_name", &PortManager::get_pretty_name_by_name)
968 .addFunction ("port_is_physical", &PortManager::port_is_physical)
969 .addFunction ("get_physical_outputs", &PortManager::get_physical_outputs)
970 .addFunction ("get_physical_inputs", &PortManager::get_physical_inputs)
971 .addFunction ("n_physical_outputs", &PortManager::n_physical_outputs)
972 .addFunction ("n_physical_inputs", &PortManager::n_physical_inputs)
973 .addRefFunction ("get_connections", &PortManager::get_connections)
974 .addRefFunction ("get_ports", (int (PortManager::*)(DataType, PortManager::PortList&))&PortManager::get_ports)
975 .addRefFunction ("get_backend_ports", (int (PortManager::*)(const std::string&, DataType, PortFlags, std::vector<std::string>&))&PortManager::get_ports)
978 .deriveClass <AudioEngine, PortManager> ("AudioEngine")
979 .addFunction ("available_backends", &AudioEngine::available_backends)
980 .addFunction ("current_backend_name", &AudioEngine::current_backend_name)
981 .addFunction ("set_backend", &AudioEngine::set_backend)
982 .addFunction ("setup_required", &AudioEngine::setup_required)
983 .addFunction ("start", &AudioEngine::start)
984 .addFunction ("stop", &AudioEngine::stop)
985 .addFunction ("get_dsp_load", &AudioEngine::get_dsp_load)
986 .addFunction ("set_device_name", &AudioEngine::set_device_name)
987 .addFunction ("set_sample_rate", &AudioEngine::set_sample_rate)
988 .addFunction ("set_buffer_size", &AudioEngine::set_buffer_size)
989 .addFunction ("get_last_backend_error", &AudioEngine::get_last_backend_error)
993 // basic representation of Session
994 // functions which can be used from realtime and non-realtime contexts
995 luabridge::getGlobalNamespace (L)
996 .beginNamespace ("ARDOUR")
997 .beginClass <Session> ("Session")
998 .addFunction ("scripts_changed", &Session::scripts_changed) // used internally
999 .addFunction ("transport_rolling", &Session::transport_rolling)
1000 .addFunction ("request_transport_speed", &Session::request_transport_speed)
1001 .addFunction ("transport_frame", &Session::transport_frame)
1002 .addFunction ("transport_speed", &Session::transport_speed)
1003 .addFunction ("frame_rate", &Session::frame_rate)
1004 .addFunction ("nominal_frame_rate", &Session::nominal_frame_rate)
1005 .addFunction ("frames_per_timecode_frame", &Session::frames_per_timecode_frame)
1006 .addFunction ("timecode_frames_per_hour", &Session::timecode_frames_per_hour)
1007 .addFunction ("timecode_frames_per_second", &Session::timecode_frames_per_second)
1008 .addFunction ("timecode_drop_frames", &Session::timecode_drop_frames)
1009 .addFunction ("request_locate", &Session::request_locate)
1010 .addFunction ("request_stop", &Session::request_stop)
1011 .addFunction ("last_transport_start", &Session::last_transport_start)
1012 .addFunction ("goto_start", &Session::goto_start)
1013 .addFunction ("goto_end", &Session::goto_end)
1014 .addFunction ("current_start_frame", &Session::current_start_frame)
1015 .addFunction ("current_end_frame", &Session::current_end_frame)
1016 .addFunction ("actively_recording", &Session::actively_recording)
1017 .addFunction ("new_audio_track", &Session::new_audio_track)
1018 .addFunction ("new_audio_route", &Session::new_audio_route)
1019 .addFunction ("new_midi_track", &Session::new_midi_track)
1020 .addFunction ("new_midi_route", &Session::new_midi_route)
1021 .addFunction ("get_routes", &Session::get_routes)
1022 .addFunction ("get_tracks", &Session::get_tracks)
1023 .addFunction ("name", &Session::name)
1024 .addFunction ("path", &Session::path)
1025 .addFunction ("record_status", &Session::record_status)
1026 .addFunction ("route_by_id", &Session::route_by_id)
1027 .addFunction ("route_by_name", &Session::route_by_name)
1028 .addFunction ("route_by_remote_id", &Session::route_by_remote_id)
1029 .addFunction ("track_by_diskstream_id", &Session::track_by_diskstream_id)
1030 .addFunction ("source_by_id", &Session::source_by_id)
1031 .addFunction ("controllable_by_id", &Session::controllable_by_id)
1032 .addFunction ("processor_by_id", &Session::processor_by_id)
1033 .addFunction ("snap_name", &Session::snap_name)
1034 .addFunction ("monitor_out", &Session::monitor_out)
1035 .addFunction ("master_out", &Session::master_out)
1036 .addFunction ("tempo_map", (TempoMap& (Session::*)())&Session::tempo_map)
1037 .addFunction ("locations", &Session::locations)
1038 .addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command)
1039 .addFunction ("commit_reversible_command", &Session::commit_reversible_command)
1040 .addFunction ("abort_reversible_command", &Session::abort_reversible_command)
1041 .addFunction ("add_command", &Session::add_command)
1042 .addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command)
1043 .addFunction ("engine", (AudioEngine& (Session::*)())&Session::engine)
1044 .addFunction ("get_block_size", &Session::get_block_size)
1045 .addFunction ("worst_output_latency", &Session::worst_output_latency)
1046 .addFunction ("worst_input_latency", &Session::worst_input_latency)
1047 .addFunction ("worst_track_latency", &Session::worst_track_latency)
1048 .addFunction ("worst_playback_latency", &Session::worst_playback_latency)
1051 .beginClass <RegionFactory> ("RegionFactory")
1052 .addStaticFunction ("region_by_id", &RegionFactory::region_by_id)
1055 /* session enums (rt-safe, common) */
1056 .beginNamespace ("Session")
1058 .beginNamespace ("RecordState")
1059 .addConst ("Disabled", ARDOUR::Session::RecordState(Session::Disabled))
1060 .addConst ("Enabled", ARDOUR::Session::RecordState(Session::Enabled))
1061 .addConst ("Recording", ARDOUR::Session::RecordState(Session::Recording))
1064 .endNamespace () // end Session enums
1066 /* ardour enums (rt-safe, common) */
1067 .beginNamespace ("LocationFlags")
1068 .addConst ("IsMark", ARDOUR::Location::Flags(Location::IsMark))
1069 .addConst ("IsAutoPunch", ARDOUR::Location::Flags(Location::IsAutoPunch))
1070 .addConst ("IsAutoLoop", ARDOUR::Location::Flags(Location::IsAutoLoop))
1071 .addConst ("IsHidden", ARDOUR::Location::Flags(Location::IsHidden))
1072 .addConst ("IsCDMarker", ARDOUR::Location::Flags(Location::IsCDMarker))
1073 .addConst ("IsRangeMarker", ARDOUR::Location::Flags(Location::IsRangeMarker))
1074 .addConst ("IsSessionRange", ARDOUR::Location::Flags(Location::IsSessionRange))
1075 .addConst ("IsSkip", ARDOUR::Location::Flags(Location::IsSkip))
1076 .addConst ("IsSkipping", ARDOUR::Location::Flags(Location::IsSkipping))
1079 .beginNamespace ("LuaAPI")
1080 .addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor)
1081 .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
1082 .addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
1083 .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
1084 .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
1085 .addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
1086 .addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
1087 .addFunction ("usleep", Glib::usleep)
1088 .endNamespace () // end LuaAPI
1089 .endNamespace ();// end ARDOUR
1093 LuaBindings::dsp (lua_State* L)
1095 luabridge::getGlobalNamespace (L)
1096 .beginNamespace ("ARDOUR")
1098 .beginClass <AudioBuffer> ("AudioBuffer")
1100 .addFunction ("data", (Sample*(AudioBuffer::*)(framecnt_t))&AudioBuffer::data)
1101 .addFunction ("silence", &AudioBuffer::silence)
1102 .addFunction ("apply_gain", &AudioBuffer::apply_gain)
1103 .addFunction ("check_silence", &AudioBuffer::check_silence)
1104 .addFunction ("read_from", (void (AudioBuffer::*)(const Sample*, framecnt_t, framecnt_t, framecnt_t))&AudioBuffer::check_silence)
1107 .beginClass <MidiBuffer> ("MidiBuffer")
1109 .addFunction ("silence", &MidiBuffer::silence)
1110 .addFunction ("empty", &MidiBuffer::empty)
1114 .beginClass <BufferSet> ("BufferSet")
1116 .addFunction ("get_audio", static_cast<AudioBuffer&(BufferSet::*)(size_t)>(&BufferSet::get_audio))
1117 .addFunction ("count", static_cast<const ChanCount&(BufferSet::*)()const>(&BufferSet::count))
1121 luabridge::getGlobalNamespace (L)
1122 .beginNamespace ("Evoral")
1123 .beginClass <Evoral::Event<framepos_t> > ("Event")
1124 .addFunction ("clear", &Evoral::Event<framepos_t>::clear)
1125 .addFunction ("size", &Evoral::Event<framepos_t>::size)
1126 .addFunction ("set_buffer", &Evoral::Event<framepos_t>::set_buffer)
1127 .addFunction ("buffer", (uint8_t*(Evoral::Event<framepos_t>::*)())&Evoral::Event<framepos_t>::buffer)
1130 .beginClass <Evoral::Beats> ("Beats")
1131 .addFunction ("to_double", &Evoral::Beats::to_double)
1134 .deriveClass <Evoral::MIDIEvent<framepos_t>, Evoral::Event<framepos_t> > ("MidiEvent")
1136 .addFunction ("type", &Evoral::MIDIEvent<framepos_t>::type)
1137 .addFunction ("channel", &Evoral::MIDIEvent<framepos_t>::channel)
1138 .addFunction ("set_type", &Evoral::MIDIEvent<framepos_t>::type)
1139 .addFunction ("set_channel", &Evoral::MIDIEvent<framepos_t>::channel)
1143 // dsp releated session functions
1144 luabridge::getGlobalNamespace (L)
1145 .beginNamespace ("ARDOUR")
1146 .beginClass <Session> ("Session")
1147 .addFunction ("get_scratch_buffers", &Session::get_scratch_buffers)
1148 .addFunction ("get_silent_buffers", &Session::get_silent_buffers)
1152 luabridge::getGlobalNamespace (L)
1153 .beginNamespace ("ARDOUR")
1154 .beginNamespace ("DSP")
1155 .addFunction ("compute_peak", ARDOUR::compute_peak)
1156 .addFunction ("find_peaks", ARDOUR::find_peaks)
1157 .addFunction ("apply_gain_to_buffer", ARDOUR::apply_gain_to_buffer)
1158 .addFunction ("mix_buffers_no_gain", ARDOUR::mix_buffers_no_gain)
1159 .addFunction ("mix_buffers_with_gain", ARDOUR::mix_buffers_with_gain)
1160 .addFunction ("copy_vector", ARDOUR::copy_vector)
1161 .addFunction ("dB_to_coefficient", &dB_to_coefficient)
1162 .addFunction ("fast_coefficient_to_dB", &fast_coefficient_to_dB)
1163 .addFunction ("accurate_coefficient_to_dB", &accurate_coefficient_to_dB)
1164 .addFunction ("memset", &DSP::memset)
1165 .addFunction ("mmult", &DSP::mmult)
1166 .addFunction ("log_meter", &DSP::log_meter)
1167 .addFunction ("log_meter_coeff", &DSP::log_meter_coeff)
1168 .addRefFunction ("peaks", &DSP::peaks)
1170 .beginClass <DSP::LowPass> ("LowPass")
1171 .addConstructor <void (*) (double, float)> ()
1172 .addFunction ("proc", &DSP::LowPass::proc)
1173 .addFunction ("ctrl", &DSP::LowPass::ctrl)
1174 .addFunction ("set_cutoff", &DSP::LowPass::set_cutoff)
1175 .addFunction ("reset", &DSP::LowPass::reset)
1177 .beginClass <DSP::Biquad> ("Biquad")
1178 .addConstructor <void (*) (double)> ()
1179 .addFunction ("run", &DSP::Biquad::run)
1180 .addFunction ("compute", &DSP::Biquad::compute)
1181 .addFunction ("reset", &DSP::Biquad::reset)
1182 .addFunction ("dB_at_freq", &DSP::Biquad::dB_at_freq)
1186 .beginNamespace ("BiquadType")
1187 .addConst ("LowPass", ARDOUR::DSP::Biquad::LowPass)
1188 .addConst ("HighPass", ARDOUR::DSP::Biquad::HighPass)
1189 .addConst ("BandPassSkirt", ARDOUR::DSP::Biquad::BandPassSkirt)
1190 .addConst ("BandPass0dB", ARDOUR::DSP::Biquad::BandPass0dB)
1191 .addConst ("Notch", ARDOUR::DSP::Biquad::Notch)
1192 .addConst ("AllPass", ARDOUR::DSP::Biquad::AllPass)
1193 .addConst ("Peaking", ARDOUR::DSP::Biquad::Peaking)
1194 .addConst ("LowShelf", ARDOUR::DSP::Biquad::LowShelf)
1195 .addConst ("HighShelf", ARDOUR::DSP::Biquad::HighShelf)
1198 .beginClass <DSP::DspShm> ("DspShm")
1199 .addFunction ("allocate", &DSP::DspShm::allocate)
1200 .addFunction ("clear", &DSP::DspShm::clear)
1201 .addFunction ("to_float", &DSP::DspShm::to_float)
1202 .addFunction ("to_int", &DSP::DspShm::to_int)
1203 .addFunction ("atomic_set_int", &DSP::DspShm::atomic_set_int)
1204 .addFunction ("atomic_get_int", &DSP::DspShm::atomic_get_int)
1207 .endNamespace () // DSP
1208 .endNamespace (); // ARDOUR
1212 LuaBindings::session (lua_State* L)
1214 // non-realtime session functions
1215 luabridge::getGlobalNamespace (L)
1216 .beginNamespace ("ARDOUR")
1217 .beginClass <Session> ("Session")
1218 .addFunction ("save_state", &Session::save_state)
1219 .addFunction ("set_dirty", &Session::set_dirty)
1220 .addFunction ("unknown_processors", &Session::unknown_processors)
1222 .addFunction<RouteList (Session::*)(uint32_t, const std::string&, const std::string&, PlaylistDisposition)> ("new_route_from_template", &Session::new_route_from_template)
1223 // TODO session_add_audio_track session_add_midi_track session_add_mixed_track
1224 //.addFunction ("new_midi_track", &Session::new_midi_track)
1227 .endNamespace (); // ARDOUR
1231 LuaBindings::osc (lua_State* L)
1233 luabridge::getGlobalNamespace (L)
1234 .beginNamespace ("ARDOUR")
1235 .beginNamespace ("LuaOSC")
1236 .beginClass<LuaOSC::Address> ("Address")
1237 .addConstructor<void (*) (std::string)> ()
1238 .addCFunction ("send", &LuaOSC::Address::send)
1245 LuaBindings::set_session (lua_State* L, Session *s)
1247 /* LuaBridge uses unique keys to identify classes/c-types.
1249 * Those keys are "generated" by using the memory-address of a static
1250 * variable, templated for every Class.
1251 * (see libs/lua/LuaBridge/detail/ClassInfo.h)
1253 * When linking the final executable there must be exactly one static
1254 * function (static variable) for every templated class.
1255 * This works fine on OSX and Linux...
1257 * Windows (mingw and MSVC) however expand the template differently for libardour
1258 * AND gtk2_ardour. We end up with two identical static functions
1259 * at different addresses!!
1261 * The Solution: have gtk2_ardour never include LuaBridge headers directly
1262 * and always go via libardour function calls for classes that are registered
1263 * in libardour. (calling lua itself is fine, calling c-functions in the GUI
1264 * which expand the template is not)
1266 * (the actual cause: even static symbols in a .dll have no fixed address
1267 * and are mapped when loading the dll. static functions in .exe do have a fixed
1271 * 0000000000000000 I __imp__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1272 * 0000000000000000 I __nm__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1273 * 0000000000000000 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
1276 * 000000000104f560 d .data$_ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1277 * 000000000104f560 D _ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1278 * 0000000000e9baf0 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
1282 luabridge::push <Session *> (L, s);
1283 lua_setglobal (L, "Session");
1286 // call lua function.
1287 luabridge::LuaRef cb_ses = luabridge::getGlobal (L, "new_session");
1288 if (cb_ses.type() == LUA_TFUNCTION) { cb_ses(s->name()); } // TODO args