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 ("add_processor_by_index", &Route::add_processor_by_index)
521 .addFunction ("remove_processor", &Route::remove_processor)
522 .addFunction ("replace_processor", &Route::replace_processor)
523 .addFunction ("n_inputs", &Route::n_inputs)
524 .addFunction ("n_outputs", &Route::n_outputs)
525 .addFunction ("set_comment", &Route::set_comment)
526 .addFunction ("strict_io", &Route::strict_io)
527 .addFunction ("set_strict_io", &Route::set_strict_io)
528 .addFunction ("reset_plugin_insert", &Route::reset_plugin_insert)
529 .addFunction ("customize_plugin_insert", &Route::customize_plugin_insert)
530 .addFunction ("add_sidechain", &Route::add_sidechain)
531 .addFunction ("remove_sidechain", &Route::remove_sidechain)
532 .addFunction ("main_outs", &Route::main_outs)
533 .addFunction ("muted", &Route::muted)
534 .addFunction ("soloed", &Route::soloed)
535 .addFunction ("amp", &Route::amp)
536 .addFunction ("trim", &Route::trim)
539 .deriveWSPtrClass <Playlist, SessionObject> ("Playlist")
540 .addFunction ("region_by_id", &Playlist::region_by_id)
541 .addFunction ("data_type", &Playlist::data_type)
542 .addFunction ("n_regions", &Playlist::n_regions)
543 //.addFunction ("get_extent", &Playlist::get_extent) // pair<framepos_t, framepos_t>
544 //.addFunction ("region_list", &Playlist::region_list) // RegionListProperty&
545 .addFunction ("add_region", &Playlist::add_region)
546 .addFunction ("remove_region", &Playlist::remove_region)
547 .addFunction ("regions_at", &Playlist::regions_at)
548 .addFunction ("top_region_at", &Playlist::top_region_at)
549 .addFunction ("top_unmuted_region_at", &Playlist::top_unmuted_region_at)
550 .addFunction ("find_next_region", &Playlist::find_next_region)
551 .addFunction ("find_next_region_boundary", &Playlist::find_next_region_boundary)
552 .addFunction ("count_regions_at", &Playlist::count_regions_at)
553 .addFunction ("regions_touched", &Playlist::regions_touched)
554 .addFunction ("regions_with_start_within", &Playlist::regions_with_start_within)
555 .addFunction ("regions_with_end_within", &Playlist::regions_with_end_within)
556 .addFunction ("raise_region", &Playlist::raise_region)
557 .addFunction ("lower_region", &Playlist::lower_region)
558 .addFunction ("raise_region_to_top", &Playlist::raise_region_to_top)
559 .addFunction ("lower_region_to_bottom", &Playlist::lower_region_to_bottom)
560 .addFunction ("duplicate", (void (Playlist::*)(boost::shared_ptr<Region>, framepos_t, framecnt_t, float))&Playlist::duplicate)
561 .addFunction ("duplicate_until", &Playlist::duplicate_until)
562 .addFunction ("duplicate_range", &Playlist::duplicate_range)
563 .addFunction ("combine", &Playlist::combine)
564 .addFunction ("uncombine", &Playlist::uncombine)
565 .addFunction ("split_region", &Playlist::split_region)
566 .addFunction ("split", (void (Playlist::*)(framepos_t))&Playlist::split)
567 .addFunction ("cut", (boost::shared_ptr<Playlist> (Playlist::*)(std::list<AudioRange>&, bool))&Playlist::cut)
569 .addFunction ("copy", &Playlist::copy)
570 .addFunction ("paste", &Playlist::paste)
574 .deriveWSPtrClass <Track, Route> ("Track")
575 .addCast<AudioTrack> ("to_audio_track")
576 .addCast<MidiTrack> ("to_midi_track")
577 .addFunction ("set_name", &Track::set_name)
578 .addFunction ("can_record", &Track::can_record)
579 .addFunction ("record_enabled", &Track::record_enabled)
580 .addFunction ("record_safe", &Track::record_safe)
581 .addFunction ("set_record_enabled", &Track::set_record_enabled)
582 .addFunction ("set_record_safe", &Track::set_record_safe)
583 .addFunction ("bounceable", &Track::bounceable)
584 .addFunction ("bounce", &Track::bounce)
585 .addFunction ("bounce_range", &Track::bounce_range)
586 .addFunction ("playlist", &Track::playlist)
589 .deriveWSPtrClass <AudioTrack, Track> ("AudioTrack")
592 .deriveWSPtrClass <MidiTrack, Track> ("MidiTrack")
595 .deriveWSPtrClass <Region, SessionObject> ("Region")
597 .addFunction ("position", &Region::position)
598 .addFunction ("start", &Region::start)
599 .addFunction ("length", &Region::length)
600 .addFunction ("layer", &Region::layer)
601 .addFunction ("data_type", &Region::data_type)
602 .addFunction ("stretch", &Region::stretch)
603 .addFunction ("shift", &Region::shift)
604 .addRefFunction ("sync_offset", &Region::sync_offset)
605 .addFunction ("sync_position", &Region::sync_position)
606 .addFunction ("hidden", &Region::hidden)
607 .addFunction ("muted", &Region::muted)
608 .addFunction ("opaque", &Region::opaque)
609 .addFunction ("locked", &Region::locked)
610 .addFunction ("position_locked", &Region::position_locked)
611 .addFunction ("video_locked", &Region::video_locked)
612 .addFunction ("automatic", &Region::automatic)
613 .addFunction ("whole_file", &Region::whole_file)
614 .addFunction ("captured", &Region::captured)
615 .addFunction ("can_move", &Region::can_move)
616 .addFunction ("sync_marked", &Region::sync_marked)
617 .addFunction ("external", &Region::external)
618 .addFunction ("import", &Region::import)
619 .addFunction ("covers", &Region::covers)
620 .addFunction ("at_natural_position", &Region::at_natural_position)
621 .addFunction ("is_compound", &Region::is_compound)
622 /* editing operations */
623 .addFunction ("set_length", &Region::set_length)
624 .addFunction ("set_start", &Region::set_start)
625 .addFunction ("set_position", &Region::set_position)
626 .addFunction ("set_initial_position", &Region::set_initial_position)
627 .addFunction ("nudge_position", &Region::nudge_position)
628 .addFunction ("move_to_natural_position", &Region::move_to_natural_position)
629 .addFunction ("move_start", &Region::move_start)
630 .addFunction ("trim_front", &Region::trim_front)
631 .addFunction ("trim_end", &Region::trim_end)
632 .addFunction ("trim_to", &Region::trim_to)
633 .addFunction ("cut_front", &Region::cut_front)
634 .addFunction ("cut_end", &Region::cut_end)
635 .addFunction ("raise", &Region::raise)
636 .addFunction ("lower", &Region::lower)
637 .addFunction ("raise_to_top", &Region::raise_to_top)
638 .addFunction ("lower_to_bottom", &Region::lower_to_bottom)
639 .addFunction ("set_sync_position", &Region::set_sync_position)
640 .addFunction ("clear_sync_position", &Region::clear_sync_position)
641 .addFunction ("set_hidden", &Region::set_hidden)
642 .addFunction ("set_muted", &Region::set_muted)
643 .addFunction ("set_opaque", &Region::set_opaque)
644 .addFunction ("set_locked", &Region::set_locked)
645 .addFunction ("set_video_locked", &Region::set_video_locked)
646 .addFunction ("set_position_locked", &Region::set_position_locked)
649 .beginWSPtrClass <Source> ("Source")
652 .beginClass <Plugin::PresetRecord> ("PresetRecord")
653 .addVoidConstructor ()
654 .addData ("uri", &Plugin::PresetRecord::uri, false)
655 .addData ("label", &Plugin::PresetRecord::label, false)
656 .addData ("user", &Plugin::PresetRecord::user, false)
657 .addData ("valid", &Plugin::PresetRecord::valid, false)
660 .deriveWSPtrClass <Automatable, Evoral::ControlSet> ("Automatable")
661 .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
664 .deriveClass <ParameterDescriptor, Evoral::ParameterDescriptor> ("ParameterDescriptor")
665 .addVoidConstructor ()
666 .addData ("label", &ParameterDescriptor::label)
667 .addData ("logarithmic", &ParameterDescriptor::logarithmic)
670 .deriveWSPtrClass <Processor, SessionObject> ("Processor")
671 .addCast<Automatable> ("to_automatable")
672 .addCast<PluginInsert> ("to_insert")
673 .addCast<SideChain> ("to_sidechain")
674 .addCast<IOProcessor> ("to_ioprocessor")
675 .addFunction ("display_name", &Processor::display_name)
676 .addFunction ("active", &Processor::active)
677 .addFunction ("activate", &Processor::activate)
678 .addFunction ("deactivate", &Processor::deactivate)
679 .addFunction ("control", (boost::shared_ptr<Evoral::Control>(Evoral::ControlSet::*)(const Evoral::Parameter&, bool))&Evoral::ControlSet::control)
680 .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
683 .deriveWSPtrClass <IOProcessor, Processor> ("IOProcessor")
684 .addFunction ("natural_input_streams", &IOProcessor::natural_input_streams)
685 .addFunction ("natural_output_streams", &IOProcessor::natural_output_streams)
686 .addFunction ("input", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::input)
687 .addFunction ("output", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::output)
690 .deriveWSPtrClass <SideChain, IOProcessor> ("SideChain")
693 .deriveWSPtrClass <Delivery, IOProcessor> ("Delivery")
696 .deriveWSPtrClass <Plugin, PBD::StatefulDestructible> ("Plugin")
697 .addFunction ("label", &Plugin::label)
698 .addFunction ("name", &Plugin::name)
699 .addFunction ("maker", &Plugin::maker)
700 .addFunction ("parameter_count", &Plugin::parameter_count)
701 .addRefFunction ("nth_parameter", &Plugin::nth_parameter)
702 .addFunction ("preset_by_label", &Plugin::preset_by_label)
703 .addFunction ("preset_by_uri", &Plugin::preset_by_uri)
704 .addFunction ("load_preset", &Plugin::load_preset)
705 .addFunction ("parameter_is_input", &Plugin::parameter_is_input)
706 .addFunction ("get_docs", &Plugin::get_docs)
707 .addFunction ("get_parameter_docs", &Plugin::get_parameter_docs)
708 .addRefFunction ("get_parameter_descriptor", &Plugin::get_parameter_descriptor)
711 .deriveWSPtrClass <PluginInsert, Processor> ("PluginInsert")
712 .addFunction ("plugin", &PluginInsert::plugin)
713 .addFunction ("activate", &PluginInsert::activate)
714 .addFunction ("deactivate", &PluginInsert::deactivate)
715 .addFunction ("strict_io_configured", &PluginInsert::strict_io_configured)
716 .addFunction ("input_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::input_map)
717 .addFunction ("output_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::output_map)
718 .addFunction ("set_input_map", &PluginInsert::set_input_map)
719 .addFunction ("set_output_map", &PluginInsert::set_output_map)
720 .addFunction ("sidechain_input", &PluginInsert::sidechain_input)
723 .deriveWSPtrClass <AutomationControl, PBD::Controllable> ("AutomationControl")
724 .addCast<Evoral::Control> ("to_ctrl")
725 .addFunction ("automation_state", &AutomationControl::automation_state)
726 .addFunction ("automation_style", &AutomationControl::automation_style)
727 .addFunction ("set_automation_state", &AutomationControl::set_automation_state)
728 .addFunction ("set_automation_style", &AutomationControl::set_automation_style)
729 .addFunction ("start_touch", &AutomationControl::start_touch)
730 .addFunction ("stop_touch", &AutomationControl::stop_touch)
731 .addFunction ("get_value", &AutomationControl::get_value)
732 .addFunction ("set_value", &AutomationControl::set_value)
733 .addFunction ("writable", &AutomationControl::writable)
734 .addFunction ("alist", &AutomationControl::alist)
737 .deriveWSPtrClass <GainControl, AutomationControl> ("GainControl")
740 .deriveWSPtrClass <Amp, Processor> ("Amp")
741 .addFunction ("gain_control", (boost::shared_ptr<GainControl>(Amp::*)())&Amp::gain_control)
744 .deriveWSPtrClass <PluginInsert::PluginControl, AutomationControl> ("PluginControl")
747 .deriveWSPtrClass <AudioSource, Source> ("AudioSource")
748 .addFunction ("readable_length", &AudioSource::readable_length)
749 .addFunction ("n_channels", &AudioSource::n_channels)
752 // <std::list<boost::shared_ptr <AudioTrack> >
753 .beginStdList <boost::shared_ptr<AudioTrack> > ("AudioTrackList")
756 // std::list<boost::shared_ptr <MidiTrack> >
757 .beginStdList <boost::shared_ptr<MidiTrack> > ("MidiTrackList")
760 // RouteList == std::list<boost::shared_ptr<Route> >
761 .beginConstStdList <boost::shared_ptr<Route> > ("RouteList")
764 // boost::shared_ptr<RouteList>
765 .beginPtrStdList <boost::shared_ptr<Route> > ("RouteListPtr")
768 // typedef std::list<boost::weak_ptr <Route> > WeakRouteList
769 .beginConstStdList <boost::weak_ptr<Route> > ("WeakRouteList")
772 // std::list< boost::weak_ptr <AudioSource> >
773 .beginConstStdList <boost::weak_ptr<AudioSource> > ("WeakAudioSourceList")
776 // typedef std::list<boost::shared_ptr<Region> > RegionList
777 .beginConstStdList <boost::shared_ptr<Region> > ("RegionList")
780 // boost::shared_ptr <std::list<boost::shared_ptr<Region> > >
781 .beginPtrStdList <boost::shared_ptr<Region> > ("RegionListPtr")
784 //std::list<boost::shared_ptr<Port> > PortList;
785 .beginConstStdList <boost::shared_ptr<Port> > ("PortList")
788 // used by Playlist::cut/copy
789 .beginConstStdList <AudioRange> ("AudioRangeList")
792 .beginConstStdList <Location*> ("LocationList")
795 #if 0 // depends on Evoal:: Note, Beats see note_fixer.h
796 // typedef Evoral::Note<Evoral::Beats> Note;
797 // std::set< boost::weak_ptr<Note> >
798 .beginStdSet <boost::weak_ptr<Note> > ("WeakNoteSet")
802 // std::list<boost::weak_ptr<Source> >
803 .beginConstStdList <boost::weak_ptr<Source> > ("WeakSourceList")
806 .beginClass <Tempo> ("Tempo")
807 .addConstructor <void (*) (double, double)> ()
808 .addFunction ("note_type", &Tempo::note_type)
809 .addFunction ("beats_per_minute", &Tempo::beats_per_minute)
810 .addFunction ("frames_per_beat", &Tempo::frames_per_beat)
813 .beginClass <Meter> ("Meter")
814 .addConstructor <void (*) (double, double)> ()
815 .addFunction ("divisions_per_bar", &Meter::divisions_per_bar)
816 .addFunction ("note_divisor", &Meter::note_divisor)
817 .addFunction ("frames_per_bar", &Meter::frames_per_bar)
818 .addFunction ("frames_per_grid", &Meter::frames_per_grid)
821 .beginClass <TempoMap> ("TempoMap")
822 .addFunction ("add_tempo", &TempoMap::add_tempo)
823 .addFunction ("add_meter", &TempoMap::add_meter)
826 .beginClass <ChanCount> ("ChanCount")
827 .addConstructor <void (*) (DataType, uint32_t)> ()
828 .addFunction ("get", &ChanCount::get)
829 .addFunction ("set", &ChanCount::set)
830 .addFunction ("n_audio", &ChanCount::n_audio)
831 .addFunction ("n_midi", &ChanCount::n_midi)
832 .addFunction ("n_total", &ChanCount::n_total)
833 .addFunction ("reset", &ChanCount::reset)
836 .beginClass <DataType> ("DataType")
837 .addConstructor <void (*) (std::string)> ()
838 .addStaticCFunction ("null", &LuaAPI::datatype_ctor_null) // "nil" is a lua reseved word
839 .addStaticCFunction ("audio", &LuaAPI::datatype_ctor_audio)
840 .addStaticCFunction ("midi", &LuaAPI::datatype_ctor_midi)
841 .addFunction ("to_string", &DataType::to_string) // TODO Lua __tostring
842 // TODO add uint32_t cast, add operator== !=
845 /* libardour enums */
846 .beginNamespace ("PluginType")
847 .addConst ("AudioUnit", ARDOUR::PluginType(AudioUnit))
848 .addConst ("LADSPA", ARDOUR::PluginType(LADSPA))
849 .addConst ("LV2", ARDOUR::PluginType(LV2))
850 .addConst ("Windows_VST", ARDOUR::PluginType(Windows_VST))
851 .addConst ("LXVST", ARDOUR::PluginType(LXVST))
852 .addConst ("Lua", ARDOUR::PluginType(Lua))
855 .beginNamespace ("AutoStyle")
856 .addConst ("Absolute", ARDOUR::AutoStyle(Absolute))
857 .addConst ("Trim", ARDOUR::AutoStyle(Trim))
860 .beginNamespace ("AutoState")
861 .addConst ("Off", ARDOUR::AutoState(Off))
862 .addConst ("Write", ARDOUR::AutoState(Write))
863 .addConst ("Touch", ARDOUR::AutoState(Touch))
864 .addConst ("Play", ARDOUR::AutoState(Play))
867 .beginNamespace ("AutomationType")
868 .addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation))
869 .addConst ("PluginAutomation", ARDOUR::AutomationType(GainAutomation))
870 .addConst ("PluginAutomation", ARDOUR::AutomationType(TrimAutomation))
873 .beginNamespace ("SrcQuality")
874 .addConst ("SrcBest", ARDOUR::SrcQuality(SrcBest))
877 .beginNamespace ("PortFlags")
878 .addConst ("IsInput", ARDOUR::PortFlags(IsInput))
879 .addConst ("IsOutput", ARDOUR::PortFlags(IsOutput))
880 .addConst ("IsPhysical", ARDOUR::PortFlags(IsPhysical))
881 .addConst ("CanMonitor", ARDOUR::PortFlags(CanMonitor))
882 .addConst ("IsTerminal", ARDOUR::PortFlags(IsTerminal))
885 .beginNamespace ("PlaylistDisposition")
886 .addConst ("CopyPlaylist", ARDOUR::PlaylistDisposition(CopyPlaylist))
887 .addConst ("NewPlaylist", ARDOUR::PlaylistDisposition(NewPlaylist))
888 .addConst ("SharePlaylist", ARDOUR::PlaylistDisposition(SharePlaylist))
891 .beginNamespace ("RegionPoint")
892 .addConst ("Start", ARDOUR::RegionPoint(Start))
893 .addConst ("End", ARDOUR::RegionPoint(End))
894 .addConst ("SyncPoint", ARDOUR::RegionPoint(SyncPoint))
897 .beginNamespace ("TrackMode")
898 .addConst ("Normal", ARDOUR::TrackMode(Start))
899 .addConst ("NonLayered", ARDOUR::TrackMode(NonLayered))
900 .addConst ("Destructive", ARDOUR::TrackMode(Destructive))
902 .endNamespace (); // end ARDOUR
904 luabridge::getGlobalNamespace (L)
905 .beginNamespace ("ARDOUR")
906 .beginClass <AudioBackendInfo> ("AudioBackendInfo")
907 .addData ("name", &AudioBackendInfo::name)
909 .beginStdVector <const AudioBackendInfo*> ("BackendVector").endClass ()
911 .beginClass <AudioBackend::DeviceStatus> ("DeviceStatus")
912 .addData ("name", &AudioBackend::DeviceStatus::name)
913 .addData ("available", &AudioBackend::DeviceStatus::available)
915 .beginStdVector <AudioBackend::DeviceStatus> ("DeviceStatusVector").endClass ()
917 .beginWSPtrClass <AudioBackend> ("AudioBackend")
918 .addFunction ("info", &AudioBackend::info)
919 .addFunction ("sample_rate", &AudioBackend::sample_rate)
920 .addFunction ("buffer_size", &AudioBackend::buffer_size)
921 .addFunction ("period_size", &AudioBackend::period_size)
922 .addFunction ("input_channels", &AudioBackend::input_channels)
923 .addFunction ("output_channels", &AudioBackend::output_channels)
924 .addFunction ("dsp_load", &AudioBackend::dsp_load)
926 .addFunction ("set_sample_rate", &AudioBackend::set_sample_rate)
927 .addFunction ("set_buffer_size", &AudioBackend::set_buffer_size)
928 .addFunction ("set_peridod_size", &AudioBackend::set_peridod_size)
930 .addFunction ("enumerate_drivers", &AudioBackend::enumerate_drivers)
931 .addFunction ("driver_name", &AudioBackend::driver_name)
932 .addFunction ("set_driver", &AudioBackend::set_driver)
934 .addFunction ("use_separate_input_and_output_devices", &AudioBackend::use_separate_input_and_output_devices)
935 .addFunction ("enumerate_devices", &AudioBackend::enumerate_devices)
936 .addFunction ("enumerate_input_devices", &AudioBackend::enumerate_input_devices)
937 .addFunction ("enumerate_output_devices", &AudioBackend::enumerate_output_devices)
938 .addFunction ("device_name", &AudioBackend::device_name)
939 .addFunction ("input_device_name", &AudioBackend::input_device_name)
940 .addFunction ("output_device_name", &AudioBackend::output_device_name)
941 .addFunction ("set_device_name", &AudioBackend::set_device_name)
942 .addFunction ("set_input_device_name", &AudioBackend::set_input_device_name)
943 .addFunction ("set_output_device_name", &AudioBackend::set_output_device_name)
946 .beginClass <PortManager> ("PortManager")
947 .addFunction ("port_engine", &PortManager::port_engine)
948 .addFunction ("connected", &PortManager::connected)
949 .addFunction ("connect", &PortManager::connect)
950 .addFunction ("physically_connected", &PortManager::physically_connected)
951 .addFunction ("disconnect", (int (PortManager::*)(const std::string&, const std::string&))&PortManager::disconnect)
952 .addFunction ("disconnect_port", (int (PortManager::*)(boost::shared_ptr<Port>))&PortManager::disconnect)
953 .addFunction ("get_port_by_name", &PortManager::get_port_by_name)
954 .addFunction ("get_pretty_name_by_name", &PortManager::get_pretty_name_by_name)
955 .addFunction ("port_is_physical", &PortManager::port_is_physical)
956 .addFunction ("get_physical_outputs", &PortManager::get_physical_outputs)
957 .addFunction ("get_physical_inputs", &PortManager::get_physical_inputs)
958 .addFunction ("n_physical_outputs", &PortManager::n_physical_outputs)
959 .addFunction ("n_physical_inputs", &PortManager::n_physical_inputs)
960 .addRefFunction ("get_connections", &PortManager::get_connections)
961 .addRefFunction ("get_ports", (int (PortManager::*)(DataType, PortManager::PortList&))&PortManager::get_ports)
962 .addRefFunction ("get_backend_ports", (int (PortManager::*)(const std::string&, DataType, PortFlags, std::vector<std::string>&))&PortManager::get_ports)
965 .deriveClass <AudioEngine, PortManager> ("AudioEngine")
966 .addFunction ("available_backends", &AudioEngine::available_backends)
967 .addFunction ("current_backend_name", &AudioEngine::current_backend_name)
968 .addFunction ("set_backend", &AudioEngine::set_backend)
969 .addFunction ("setup_required", &AudioEngine::setup_required)
970 .addFunction ("start", &AudioEngine::start)
971 .addFunction ("stop", &AudioEngine::stop)
972 .addFunction ("get_dsp_load", &AudioEngine::get_dsp_load)
973 .addFunction ("set_device_name", &AudioEngine::set_device_name)
974 .addFunction ("set_sample_rate", &AudioEngine::set_sample_rate)
975 .addFunction ("set_buffer_size", &AudioEngine::set_buffer_size)
976 .addFunction ("get_last_backend_error", &AudioEngine::get_last_backend_error)
980 // basic representation of Session
981 // functions which can be used from realtime and non-realtime contexts
982 luabridge::getGlobalNamespace (L)
983 .beginNamespace ("ARDOUR")
984 .beginClass <Session> ("Session")
985 .addFunction ("scripts_changed", &Session::scripts_changed) // used internally
986 .addFunction ("transport_rolling", &Session::transport_rolling)
987 .addFunction ("request_transport_speed", &Session::request_transport_speed)
988 .addFunction ("transport_frame", &Session::transport_frame)
989 .addFunction ("transport_speed", &Session::transport_speed)
990 .addFunction ("frame_rate", &Session::frame_rate)
991 .addFunction ("nominal_frame_rate", &Session::nominal_frame_rate)
992 .addFunction ("frames_per_timecode_frame", &Session::frames_per_timecode_frame)
993 .addFunction ("timecode_frames_per_hour", &Session::timecode_frames_per_hour)
994 .addFunction ("timecode_frames_per_second", &Session::timecode_frames_per_second)
995 .addFunction ("timecode_drop_frames", &Session::timecode_drop_frames)
996 .addFunction ("request_locate", &Session::request_locate)
997 .addFunction ("request_stop", &Session::request_stop)
998 .addFunction ("last_transport_start", &Session::last_transport_start)
999 .addFunction ("goto_start", &Session::goto_start)
1000 .addFunction ("goto_end", &Session::goto_end)
1001 .addFunction ("current_start_frame", &Session::current_start_frame)
1002 .addFunction ("current_end_frame", &Session::current_end_frame)
1003 .addFunction ("actively_recording", &Session::actively_recording)
1004 .addFunction ("new_audio_track", &Session::new_audio_track)
1005 .addFunction ("new_audio_route", &Session::new_audio_route)
1006 .addFunction ("new_midi_track", &Session::new_midi_track)
1007 .addFunction ("new_midi_route", &Session::new_midi_route)
1008 .addFunction ("get_routes", &Session::get_routes)
1009 .addFunction ("get_tracks", &Session::get_tracks)
1010 .addFunction ("name", &Session::name)
1011 .addFunction ("path", &Session::path)
1012 .addFunction ("record_status", &Session::record_status)
1013 .addFunction ("route_by_id", &Session::route_by_id)
1014 .addFunction ("route_by_name", &Session::route_by_name)
1015 .addFunction ("route_by_remote_id", &Session::route_by_remote_id)
1016 .addFunction ("track_by_diskstream_id", &Session::track_by_diskstream_id)
1017 .addFunction ("source_by_id", &Session::source_by_id)
1018 .addFunction ("controllable_by_id", &Session::controllable_by_id)
1019 .addFunction ("processor_by_id", &Session::processor_by_id)
1020 .addFunction ("snap_name", &Session::snap_name)
1021 .addFunction ("monitor_out", &Session::monitor_out)
1022 .addFunction ("master_out", &Session::master_out)
1023 .addFunction ("tempo_map", (TempoMap& (Session::*)())&Session::tempo_map)
1024 .addFunction ("locations", &Session::locations)
1025 .addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command)
1026 .addFunction ("commit_reversible_command", &Session::commit_reversible_command)
1027 .addFunction ("abort_reversible_command", &Session::abort_reversible_command)
1028 .addFunction ("add_command", &Session::add_command)
1029 .addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command)
1030 .addFunction ("engine", (AudioEngine& (Session::*)())&Session::engine)
1031 .addFunction ("get_block_size", &Session::get_block_size)
1032 .addFunction ("worst_output_latency", &Session::worst_output_latency)
1033 .addFunction ("worst_input_latency", &Session::worst_input_latency)
1034 .addFunction ("worst_track_latency", &Session::worst_track_latency)
1035 .addFunction ("worst_playback_latency", &Session::worst_playback_latency)
1038 .beginClass <RegionFactory> ("RegionFactory")
1039 .addStaticFunction ("region_by_id", &RegionFactory::region_by_id)
1042 /* session enums (rt-safe, common) */
1043 .beginNamespace ("Session")
1045 .beginNamespace ("RecordState")
1046 .addConst ("Disabled", ARDOUR::Session::RecordState(Session::Disabled))
1047 .addConst ("Enabled", ARDOUR::Session::RecordState(Session::Enabled))
1048 .addConst ("Recording", ARDOUR::Session::RecordState(Session::Recording))
1051 .endNamespace () // end Session enums
1053 /* ardour enums (rt-safe, common) */
1054 .beginNamespace ("LocationFlags")
1055 .addConst ("IsMark", ARDOUR::Location::Flags(Location::IsMark))
1056 .addConst ("IsAutoPunch", ARDOUR::Location::Flags(Location::IsAutoPunch))
1057 .addConst ("IsAutoLoop", ARDOUR::Location::Flags(Location::IsAutoLoop))
1058 .addConst ("IsHidden", ARDOUR::Location::Flags(Location::IsHidden))
1059 .addConst ("IsCDMarker", ARDOUR::Location::Flags(Location::IsCDMarker))
1060 .addConst ("IsRangeMarker", ARDOUR::Location::Flags(Location::IsRangeMarker))
1061 .addConst ("IsSessionRange", ARDOUR::Location::Flags(Location::IsSessionRange))
1062 .addConst ("IsSkip", ARDOUR::Location::Flags(Location::IsSkip))
1063 .addConst ("IsSkipping", ARDOUR::Location::Flags(Location::IsSkipping))
1066 .beginNamespace ("LuaAPI")
1067 .addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor)
1068 .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
1069 .addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
1070 .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
1071 .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
1072 .addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
1073 .addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
1074 .addFunction ("usleep", Glib::usleep)
1075 .endNamespace () // end LuaAPI
1076 .endNamespace ();// end ARDOUR
1080 LuaBindings::dsp (lua_State* L)
1082 luabridge::getGlobalNamespace (L)
1083 .beginNamespace ("ARDOUR")
1085 .beginClass <AudioBuffer> ("AudioBuffer")
1087 .addFunction ("data", (Sample*(AudioBuffer::*)(framecnt_t))&AudioBuffer::data)
1088 .addFunction ("silence", &AudioBuffer::silence)
1089 .addFunction ("apply_gain", &AudioBuffer::apply_gain)
1090 .addFunction ("check_silence", &AudioBuffer::check_silence)
1091 .addFunction ("read_from", (void (AudioBuffer::*)(const Sample*, framecnt_t, framecnt_t, framecnt_t))&AudioBuffer::check_silence)
1094 .beginClass <MidiBuffer> ("MidiBuffer")
1096 .addFunction ("silence", &MidiBuffer::silence)
1097 .addFunction ("empty", &MidiBuffer::empty)
1101 .beginClass <BufferSet> ("BufferSet")
1103 .addFunction ("get_audio", static_cast<AudioBuffer&(BufferSet::*)(size_t)>(&BufferSet::get_audio))
1104 .addFunction ("count", static_cast<const ChanCount&(BufferSet::*)()const>(&BufferSet::count))
1108 luabridge::getGlobalNamespace (L)
1109 .beginNamespace ("Evoral")
1110 .beginClass <Evoral::Event<framepos_t> > ("Event")
1111 .addFunction ("clear", &Evoral::Event<framepos_t>::clear)
1112 .addFunction ("size", &Evoral::Event<framepos_t>::size)
1113 .addFunction ("set_buffer", &Evoral::Event<framepos_t>::set_buffer)
1114 .addFunction ("buffer", (uint8_t*(Evoral::Event<framepos_t>::*)())&Evoral::Event<framepos_t>::buffer)
1117 .beginClass <Evoral::Beats> ("Beats")
1118 .addFunction ("to_double", &Evoral::Beats::to_double)
1121 .deriveClass <Evoral::MIDIEvent<framepos_t>, Evoral::Event<framepos_t> > ("MidiEvent")
1123 .addFunction ("type", &Evoral::MIDIEvent<framepos_t>::type)
1124 .addFunction ("channel", &Evoral::MIDIEvent<framepos_t>::channel)
1125 .addFunction ("set_type", &Evoral::MIDIEvent<framepos_t>::type)
1126 .addFunction ("set_channel", &Evoral::MIDIEvent<framepos_t>::channel)
1130 // dsp releated session functions
1131 luabridge::getGlobalNamespace (L)
1132 .beginNamespace ("ARDOUR")
1133 .beginClass <Session> ("Session")
1134 .addFunction ("get_scratch_buffers", &Session::get_scratch_buffers)
1135 .addFunction ("get_silent_buffers", &Session::get_silent_buffers)
1139 luabridge::getGlobalNamespace (L)
1140 .beginNamespace ("ARDOUR")
1141 .beginNamespace ("DSP")
1142 .addFunction ("compute_peak", ARDOUR::compute_peak)
1143 .addFunction ("find_peaks", ARDOUR::find_peaks)
1144 .addFunction ("apply_gain_to_buffer", ARDOUR::apply_gain_to_buffer)
1145 .addFunction ("mix_buffers_no_gain", ARDOUR::mix_buffers_no_gain)
1146 .addFunction ("mix_buffers_with_gain", ARDOUR::mix_buffers_with_gain)
1147 .addFunction ("copy_vector", ARDOUR::copy_vector)
1148 .addFunction ("dB_to_coefficient", &dB_to_coefficient)
1149 .addFunction ("fast_coefficient_to_dB", &fast_coefficient_to_dB)
1150 .addFunction ("accurate_coefficient_to_dB", &accurate_coefficient_to_dB)
1151 .addFunction ("memset", &DSP::memset)
1152 .addFunction ("mmult", &DSP::mmult)
1153 .addFunction ("log_meter", &DSP::log_meter)
1154 .addFunction ("log_meter_coeff", &DSP::log_meter_coeff)
1155 .addRefFunction ("peaks", &DSP::peaks)
1157 .beginClass <DSP::LowPass> ("LowPass")
1158 .addConstructor <void (*) (double, float)> ()
1159 .addFunction ("proc", &DSP::LowPass::proc)
1160 .addFunction ("ctrl", &DSP::LowPass::ctrl)
1161 .addFunction ("set_cutoff", &DSP::LowPass::set_cutoff)
1162 .addFunction ("reset", &DSP::LowPass::reset)
1164 .beginClass <DSP::BiQuad> ("Biquad")
1165 .addConstructor <void (*) (double)> ()
1166 .addFunction ("run", &DSP::BiQuad::run)
1167 .addFunction ("compute", &DSP::BiQuad::compute)
1168 .addFunction ("reset", &DSP::BiQuad::reset)
1172 .beginNamespace ("BiQuadType")
1173 .addConst ("LowPass", ARDOUR::DSP::BiQuad::LowPass)
1174 .addConst ("HighPass", ARDOUR::DSP::BiQuad::HighPass)
1175 .addConst ("BandPassSkirt", ARDOUR::DSP::BiQuad::BandPassSkirt)
1176 .addConst ("BandPass0dB", ARDOUR::DSP::BiQuad::BandPass0dB)
1177 .addConst ("Notch", ARDOUR::DSP::BiQuad::Notch)
1178 .addConst ("AllPass", ARDOUR::DSP::BiQuad::AllPass)
1179 .addConst ("Peaking", ARDOUR::DSP::BiQuad::Peaking)
1180 .addConst ("LowShelf", ARDOUR::DSP::BiQuad::LowShelf)
1181 .addConst ("HighShelf", ARDOUR::DSP::BiQuad::HighShelf)
1184 .beginClass <DSP::DspShm> ("DspShm")
1185 .addFunction ("allocate", &DSP::DspShm::allocate)
1186 .addFunction ("clear", &DSP::DspShm::clear)
1187 .addFunction ("to_float", &DSP::DspShm::to_float)
1188 .addFunction ("to_int", &DSP::DspShm::to_int)
1189 .addFunction ("atomic_set_int", &DSP::DspShm::atomic_set_int)
1190 .addFunction ("atomic_get_int", &DSP::DspShm::atomic_get_int)
1193 .endNamespace () // DSP
1194 .endNamespace (); // ARDOUR
1198 LuaBindings::session (lua_State* L)
1200 // non-realtime session functions
1201 luabridge::getGlobalNamespace (L)
1202 .beginNamespace ("ARDOUR")
1203 .beginClass <Session> ("Session")
1204 .addFunction ("save_state", &Session::save_state)
1205 .addFunction ("set_dirty", &Session::set_dirty)
1206 .addFunction ("unknown_processors", &Session::unknown_processors)
1208 .addFunction<RouteList (Session::*)(uint32_t, const std::string&, const std::string&, PlaylistDisposition)> ("new_route_from_template", &Session::new_route_from_template)
1209 // TODO session_add_audio_track session_add_midi_track session_add_mixed_track
1210 //.addFunction ("new_midi_track", &Session::new_midi_track)
1213 .endNamespace (); // ARDOUR
1217 LuaBindings::osc (lua_State* L)
1219 luabridge::getGlobalNamespace (L)
1220 .beginNamespace ("ARDOUR")
1221 .beginNamespace ("LuaOSC")
1222 .beginClass<LuaOSC::Address> ("Address")
1223 .addConstructor<void (*) (std::string)> ()
1224 .addCFunction ("send", &LuaOSC::Address::send)
1231 LuaBindings::set_session (lua_State* L, Session *s)
1233 /* LuaBridge uses unique keys to identify classes/c-types.
1235 * Those keys are "generated" by using the memory-address of a static
1236 * variable, templated for every Class.
1237 * (see libs/lua/LuaBridge/detail/ClassInfo.h)
1239 * When linking the final executable there must be exactly one static
1240 * function (static variable) for every templated class.
1241 * This works fine on OSX and Linux...
1243 * Windows (mingw and MSVC) however expand the template differently for libardour
1244 * AND gtk2_ardour. We end up with two identical static functions
1245 * at different addresses!!
1247 * The Solution: have gtk2_ardour never include LuaBridge headers directly
1248 * and always go via libardour function calls for classes that are registered
1249 * in libardour. (calling lua itself is fine, calling c-functions in the GUI
1250 * which expand the template is not)
1252 * (the actual cause: even static symbols in a .dll have no fixed address
1253 * and are mapped when loading the dll. static functions in .exe do have a fixed
1257 * 0000000000000000 I __imp__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1258 * 0000000000000000 I __nm__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1259 * 0000000000000000 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
1262 * 000000000104f560 d .data$_ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1263 * 000000000104f560 D _ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
1264 * 0000000000e9baf0 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
1268 luabridge::push <Session *> (L, s);
1269 lua_setglobal (L, "Session");
1272 // call lua function.
1273 luabridge::LuaRef cb_ses = luabridge::getGlobal (L, "new_session");
1274 if (cb_ses.type() == LUA_TFUNCTION) { cb_ses(s->name()); } // TODO args