Add Lua API to list all available plugins
[ardour.git] / libs / ardour / luabindings.cc
1 /*
2     Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3
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)
7     any later version.
8
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
12     for more details.
13
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.
17 */
18
19 #include <glibmm.h>
20
21 #include "pbd/stateful_diff_command.h"
22 #include "pbd/openuri.h"
23
24 #include "temporal/bbt_time.h"
25
26 #include "evoral/Control.hpp"
27 #include "evoral/ControlList.hpp"
28 #include "evoral/Range.hpp"
29
30 #include "ardour/amp.h"
31 #include "ardour/async_midi_port.h"
32 #include "ardour/audioengine.h"
33 #include "ardour/audioregion.h"
34 #include "ardour/audiosource.h"
35 #include "ardour/audio_backend.h"
36 #include "ardour/audio_buffer.h"
37 #include "ardour/audio_port.h"
38 #include "ardour/audio_track.h"
39 #include "ardour/audioplaylist.h"
40 #include "ardour/buffer_set.h"
41 #include "ardour/beats_samples_converter.h"
42 #include "ardour/chan_mapping.h"
43 #include "ardour/dB.h"
44 #include "ardour/delayline.h"
45 #include "ardour/disk_reader.h"
46 #include "ardour/disk_writer.h"
47 #include "ardour/dsp_filter.h"
48 #include "ardour/file_source.h"
49 #include "ardour/fluid_synth.h"
50 #include "ardour/interthread_info.h"
51 #include "ardour/lua_api.h"
52 #include "ardour/luabindings.h"
53 #include "ardour/luaproc.h"
54 #include "ardour/meter.h"
55 #include "ardour/midi_model.h"
56 #include "ardour/midi_track.h"
57 #include "ardour/midi_playlist.h"
58 #include "ardour/midi_port.h"
59 #include "ardour/midi_region.h"
60 #include "ardour/midi_source.h"
61 #include "ardour/panner_shell.h"
62 #include "ardour/phase_control.h"
63 #include "ardour/playlist.h"
64 #include "ardour/plugin.h"
65 #include "ardour/plugin_insert.h"
66 #include "ardour/polarity_processor.h"
67 #include "ardour/port_manager.h"
68 #include "ardour/progress.h"
69 #include "ardour/raw_midi_parser.h"
70 #include "ardour/runtime_functions.h"
71 #include "ardour/region.h"
72 #include "ardour/region_factory.h"
73 #include "ardour/return.h"
74 #include "ardour/route_group.h"
75 #include "ardour/send.h"
76 #include "ardour/session.h"
77 #include "ardour/session_object.h"
78 #include "ardour/sidechain.h"
79 #include "ardour/solo_isolate_control.h"
80 #include "ardour/solo_safe_control.h"
81 #include "ardour/stripable.h"
82 #include "ardour/track.h"
83 #include "ardour/tempo.h"
84 #include "ardour/vca.h"
85 #include "ardour/vca_manager.h"
86
87 #include "LuaBridge/LuaBridge.h"
88
89 #ifdef PLATFORM_WINDOWS
90 /* luabridge uses addresses of static functions/variables to identify classes.
91  *
92  * Static symbols on windows (even identical symbols) are not
93  * mapped to the same address when mixing .dll + .exe.
94  * So we need a single point to define those static functions.
95  * (normally they're header-only in libs/lua/LuaBridge/detail/ClassInfo.h)
96  *
97  * Really!! A static function with a static variable in a library header
98  * should never ever be replicated, even if it is a template.
99  * But then again this is windows... what else can go wrong ?!
100  */
101
102 template <class T>
103 void const*
104 luabridge::ClassInfo<T>::getStaticKey ()
105 {
106         static char value;
107         return &value;
108 }
109
110 template <class T>
111 void const*
112 luabridge::ClassInfo<T>::getClassKey ()
113 {
114         static char value;
115         return &value;
116 }
117
118 template <class T>
119 void const*
120 luabridge::ClassInfo<T>::getConstKey ()
121 {
122         static char value;
123         return &value;
124 }
125
126 void*
127 luabridge::getIdentityKey ()
128 {
129   static char value;
130   return &value;
131 }
132
133 /* ...and this is the ugly part of it.
134  *
135  * We need to foward declare classes from gtk2_ardour
136  * AND explicily list classes which are used by gtk2_ardour's bindings.
137  *
138  * This is required because some of the GUI classes use objects from libardour
139  * as function parameters or return values and the .exe would re-create
140  * symbols for libardour objects.
141  */
142
143 #define CLASSKEYS(CLS) \
144         template void const* luabridge::ClassInfo< CLS >::getStaticKey(); \
145         template void const* luabridge::ClassInfo< CLS >::getClassKey();  \
146         template void const* luabridge::ClassInfo< CLS >::getConstKey();
147
148 #define CLASSINFO(CLS) \
149         class CLS; \
150         template void const* luabridge::ClassInfo< CLS >::getStaticKey(); \
151         template void const* luabridge::ClassInfo< CLS >::getClassKey();  \
152         template void const* luabridge::ClassInfo< CLS >::getConstKey();
153
154 CLASSINFO(ArdourMarker);
155 CLASSINFO(AxisView);
156 CLASSINFO(MarkerSelection);
157 CLASSINFO(PublicEditor);
158 CLASSINFO(RegionSelection);
159 CLASSINFO(RegionView);
160 CLASSINFO(StripableTimeAxisView);
161 CLASSINFO(RouteTimeAxisView);
162 CLASSINFO(RouteUI);
163 CLASSINFO(Selectable);
164 CLASSINFO(Selection);
165 CLASSINFO(TimeAxisView);
166 CLASSINFO(TimeAxisViewItem);
167 CLASSINFO(TimeSelection);
168 CLASSINFO(TrackSelection);
169 CLASSINFO(TrackViewList);
170
171
172 CLASSKEYS(std::bitset<48ul>); // LuaSignal::LAST_SIGNAL
173
174 CLASSKEYS(void);
175 CLASSKEYS(float);
176 CLASSKEYS(unsigned char);
177
178 CLASSKEYS(ArdourMarker*);
179 CLASSKEYS(Selectable*);
180 CLASSKEYS(std::list<Selectable*>);
181
182 CLASSKEYS(ARDOUR::AudioEngine);
183 CLASSKEYS(ARDOUR::BeatsSamplesConverter);
184 CLASSKEYS(ARDOUR::DoubleBeatsSamplesConverter);
185 CLASSKEYS(ARDOUR::BufferSet);
186 CLASSKEYS(ARDOUR::ChanCount);
187 CLASSKEYS(ARDOUR::ChanMapping);
188 CLASSKEYS(ARDOUR::DSP::DspShm);
189 CLASSKEYS(ARDOUR::DataType);
190 CLASSKEYS(ARDOUR::FluidSynth);
191 CLASSKEYS(ARDOUR::Location);
192 CLASSKEYS(ARDOUR::LuaAPI::Vamp);
193 CLASSKEYS(ARDOUR::LuaOSC::Address);
194 CLASSKEYS(ARDOUR::LuaProc);
195 CLASSKEYS(ARDOUR::LuaTableRef);
196 CLASSKEYS(ARDOUR::MidiModel::NoteDiffCommand);
197 CLASSKEYS(ARDOUR::MonitorProcessor);
198 CLASSKEYS(ARDOUR::RouteGroup);
199 CLASSKEYS(ARDOUR::ParameterDescriptor);
200 CLASSKEYS(ARDOUR::PeakMeter);
201 CLASSKEYS(ARDOUR::PluginInfo);
202 CLASSKEYS(ARDOUR::PluginInfo);
203 CLASSKEYS(ARDOUR::Plugin::PresetRecord);
204 CLASSKEYS(ARDOUR::PortEngine);
205 CLASSKEYS(ARDOUR::PortManager);
206 CLASSKEYS(ARDOUR::PresentationInfo);
207 CLASSKEYS(ARDOUR::RCConfiguration);
208 CLASSKEYS(ARDOUR::Session);
209 CLASSKEYS(ARDOUR::SessionConfiguration);
210 CLASSKEYS(ARDOUR::Slavable);
211 CLASSKEYS(ARDOUR::Source);
212 CLASSKEYS(ARDOUR::VCA);
213 CLASSKEYS(ARDOUR::VCAManager);
214
215 CLASSKEYS(PBD::ID);
216 CLASSKEYS(PBD::Configuration);
217 CLASSKEYS(PBD::PropertyChange);
218 CLASSKEYS(PBD::StatefulDestructible);
219
220 CLASSKEYS(Temporal::Beats);
221 CLASSKEYS(Evoral::Event<samplepos_t>);
222 CLASSKEYS(Evoral::ControlEvent);
223
224
225 CLASSKEYS(std::vector<std::string>);
226 CLASSKEYS(std::vector<float>);
227 CLASSKEYS(std::vector<float*>);
228 CLASSKEYS(std::vector<double>);
229 CLASSKEYS(std::list<int64_t>);
230
231 CLASSKEYS(std::list<Evoral::ControlEvent*>);
232
233 CLASSKEYS(std::vector<ARDOUR::Plugin::PresetRecord>);
234 CLASSKEYS(std::vector<boost::shared_ptr<ARDOUR::Processor> >);
235 CLASSKEYS(std::vector<boost::shared_ptr<ARDOUR::Source> >);
236 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::PluginInfo> >); // PluginInfoList
237
238 CLASSKEYS(std::list<ArdourMarker*>);
239 CLASSKEYS(std::list<TimeAxisView*>);
240 CLASSKEYS(std::list<ARDOUR::AudioRange>);
241 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Port> >);
242 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Region> >);
243 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Route> >);
244 CLASSKEYS(std::list<boost::shared_ptr<ARDOUR::Stripable> >);
245 CLASSKEYS(boost::shared_ptr<std::list<boost::shared_ptr<ARDOUR::Route> > >);
246
247 CLASSKEYS(boost::shared_ptr<ARDOUR::AudioRegion>);
248 CLASSKEYS(boost::shared_ptr<ARDOUR::AudioSource>);
249 CLASSKEYS(boost::shared_ptr<ARDOUR::Automatable>);
250 CLASSKEYS(boost::shared_ptr<ARDOUR::AutomatableSequence<Temporal::Beats> >);
251 CLASSKEYS(boost::shared_ptr<ARDOUR::AutomationList>);
252 CLASSKEYS(boost::shared_ptr<ARDOUR::FileSource>);
253 CLASSKEYS(boost::shared_ptr<ARDOUR::MidiModel>);
254 CLASSKEYS(boost::shared_ptr<ARDOUR::MidiPlaylist>);
255 CLASSKEYS(boost::shared_ptr<ARDOUR::MidiRegion>);
256 CLASSKEYS(boost::shared_ptr<ARDOUR::MidiSource>);
257 CLASSKEYS(boost::shared_ptr<ARDOUR::PluginInfo>);
258 CLASSKEYS(boost::shared_ptr<ARDOUR::Processor>);
259 CLASSKEYS(boost::shared_ptr<ARDOUR::Readable>);
260 CLASSKEYS(boost::shared_ptr<ARDOUR::Region>);
261 CLASSKEYS(boost::shared_ptr<Evoral::ControlList>);
262 CLASSKEYS(boost::shared_ptr<Evoral::Note<Temporal::Beats> >);
263 CLASSKEYS(boost::shared_ptr<Evoral::Sequence<Temporal::Beats> >);
264
265 CLASSKEYS(boost::shared_ptr<ARDOUR::Playlist>);
266 CLASSKEYS(boost::shared_ptr<ARDOUR::Route>);
267 CLASSKEYS(boost::shared_ptr<ARDOUR::VCA>);
268 CLASSKEYS(boost::weak_ptr<ARDOUR::Route>);
269 CLASSKEYS(boost::weak_ptr<ARDOUR::VCA>);
270
271 CLASSKEYS(Vamp::RealTime);
272 CLASSKEYS(Vamp::PluginBase);
273 CLASSKEYS(Vamp::PluginBase::ParameterDescriptor);
274 CLASSKEYS(Vamp::Plugin);
275 CLASSKEYS(Vamp::Plugin::OutputDescriptor);
276 CLASSKEYS(Vamp::Plugin::Feature);
277 CLASSKEYS(Vamp::Plugin::OutputList);
278 CLASSKEYS(Vamp::Plugin::FeatureList);
279 CLASSKEYS(Vamp::Plugin::FeatureSet);
280
281 namespace LuaCairo {
282         class ImageSurface;
283         class PangoLayout;
284 }
285
286 namespace LuaDialog {
287         class Message;
288         class Dialog;
289 }
290
291 namespace Cairo {
292         class Context;
293 }
294
295 CLASSKEYS(Cairo::Context);
296 CLASSKEYS(LuaCairo::ImageSurface);
297 CLASSKEYS(LuaCairo::PangoLayout);
298
299 CLASSKEYS(LuaDialog::Message);
300 CLASSKEYS(LuaDialog::Dialog);
301
302 #endif // end windows special case
303
304 /* Some notes on Lua bindings for libardour and friends
305  *
306  * - Prefer factory methods over Contructors whenever possible.
307  *   Don't expose the constructor method unless required.
308  *
309  *   e.g. Don't allow the script to construct a "Track" Object directly
310  *   but do allow to create a "BBT_TIME" object.
311  *
312  * - Do not dereference Shared or Weak Pointers. Pass the pointer to Lua.
313  * - Define Objects as boost:shared_ptr Object whenever possible.
314  *
315  *   Storing a boost::shared_ptr in a Lua-variable keeps the reference
316  *   until that variable is set to 'nil'.
317  *   (if the script were to keep a direct pointer to the object instance, the
318  *   behaviour is undefined if the actual object goes away)
319  *
320  *   Methods of the actual class are indirectly exposed,
321  *   boost::*_ptr get() and ::lock() is implicit when the class is exported
322  *   as LuaBridge's "WSPtrClass".
323  */
324
325 using namespace ARDOUR;
326
327 /** Access libardour global configuration */
328 static RCConfiguration* _libardour_config () {
329         return ARDOUR::Config;
330 }
331
332 void
333 LuaBindings::stddef (lua_State* L)
334 {
335         // std::list<std::string>
336         luabridge::getGlobalNamespace (L)
337                 .beginNamespace ("C")
338                 .beginStdList <std::string> ("StringList")
339                 .endClass ()
340
341         // std::vector<std::string>
342                 .beginStdVector <std::string> ("StringVector")
343                 .endClass ()
344
345         // std::vector<float>
346                 .beginStdVector <float> ("FloatVector")
347                 .endClass ()
348
349         // register float array (uint8_t*)
350                 .registerArray <uint8_t> ("ByteArray")
351
352         // register float array (float*)
353                 .registerArray <float> ("FloatArray")
354
355         // register float array (int32_t*)
356                 .registerArray <int32_t> ("IntArray")
357
358         // std::vector<float*>
359                 .beginStdVector <float*> ("FloatArrayVector")
360                 .endClass ()
361
362                 // samplepos_t, sampleoffset_t lists e.g. AnalysisFeatureList
363                 .beginStdList <int64_t> ("Int64List")
364                 .endClass ()
365
366         // TODO std::set
367                 .endNamespace ();
368 }
369
370 void
371 LuaBindings::common (lua_State* L)
372 {
373         luabridge::getGlobalNamespace (L)
374                 .beginNamespace ("PBD")
375
376                 .addFunction ("open_uri", (bool (*) (const std::string&))&PBD::open_uri)
377                 .addFunction ("open_uri", &PBD::open_folder)
378
379                 .beginClass <PBD::ID> ("ID")
380                 .addConstructor <void (*) (std::string)> ()
381                 .addFunction ("to_s", &PBD::ID::to_s) // TODO special case LUA __tostring ?
382                 .endClass ()
383
384                 .beginStdVector <PBD::ID> ("IdVector").endClass ()
385
386                 .beginClass <XMLNode> ("XMLNode")
387                 .addFunction ("name", &XMLNode::name)
388                 .endClass ()
389
390                 .beginClass <PBD::Stateful> ("Stateful")
391                 .addFunction ("id", &PBD::Stateful::id)
392                 .addFunction ("properties", &PBD::Stateful::properties)
393                 .addFunction ("clear_changes", &PBD::Stateful::clear_changes)
394                 .endClass ()
395
396                 .beginWSPtrClass <PBD::Stateful> ("StatefulPtr")
397                 .addFunction ("id", &PBD::Stateful::id)
398                 .addFunction ("properties", &PBD::Stateful::properties)
399                 .addFunction ("clear_changes", &PBD::Stateful::clear_changes)
400                 .endClass ()
401
402                 .deriveClass <PBD::StatefulDestructible, PBD::Stateful> ("StatefulDestructible")
403                 .endClass ()
404
405                 .deriveClass <PBD::Configuration, PBD::Stateful> ("Configuration")
406                 .endClass()
407
408                 .deriveWSPtrClass <PBD::StatefulDestructible, PBD::Stateful> ("StatefulDestructiblePtr")
409                 .endClass ()
410
411                 .deriveClass <Command, PBD::StatefulDestructible> ("Command")
412                 .addFunction ("set_name", &Command::set_name)
413                 .addFunction ("name", &Command::name)
414                 .endClass ()
415
416                 /* UndoTransaction::add_command() subscribes to DropReferences()
417                  * and deletes the object.
418                  *
419                  * This object cannot be constructed by lua because lua would manage lifetime
420                  * and delete the object leading to a double free.
421                  *
422                  * use Session::add_stateful_diff_command()
423                  * and Session::abort_reversible_command()
424                  */
425                 .deriveClass <PBD::StatefulDiffCommand, Command> ("StatefulDiffCommand")
426                 .addFunction ("undo", &PBD::StatefulDiffCommand::undo)
427                 .addFunction ("empty", &PBD::StatefulDiffCommand::empty)
428                 .endClass ()
429
430                 .deriveWSPtrClass <PBD::Controllable, PBD::StatefulDestructible> ("Controllable")
431                 .addFunction ("name", &PBD::Controllable::name)
432                 .addFunction ("get_value", &PBD::Controllable::get_value)
433                 .endClass ()
434
435                 .beginClass <PBD::RingBufferNPT <uint8_t> > ("RingBuffer8")
436                 .addConstructor <void (*) (size_t)> ()
437                 .addFunction ("reset", &PBD::RingBufferNPT<uint8_t>::reset)
438                 .addFunction ("read", &PBD::RingBufferNPT<uint8_t>::read)
439                 .addFunction ("write", &PBD::RingBufferNPT<uint8_t>::write)
440                 .addFunction ("write_one", &PBD::RingBufferNPT<uint8_t>::write_one)
441                 .addFunction ("write_space", &PBD::RingBufferNPT<uint8_t>::write_space)
442                 .addFunction ("read_space", &PBD::RingBufferNPT<uint8_t>::read_space)
443                 .addFunction ("increment_read_ptr", &PBD::RingBufferNPT<uint8_t>::increment_read_ptr)
444                 .addFunction ("increment_write_ptr", &PBD::RingBufferNPT<uint8_t>::increment_write_ptr)
445                 .endClass ()
446
447                 .beginClass <PBD::RingBufferNPT <float> > ("RingBufferF")
448                 .addConstructor <void (*) (size_t)> ()
449                 .addFunction ("reset", &PBD::RingBufferNPT<float>::reset)
450                 .addFunction ("read", &PBD::RingBufferNPT<float>::read)
451                 .addFunction ("write", &PBD::RingBufferNPT<float>::write)
452                 .addFunction ("write_one", &PBD::RingBufferNPT<float>::write_one)
453                 .addFunction ("write_space", &PBD::RingBufferNPT<float>::write_space)
454                 .addFunction ("read_space", &PBD::RingBufferNPT<float>::read_space)
455                 .addFunction ("increment_read_ptr", &PBD::RingBufferNPT<float>::increment_read_ptr)
456                 .addFunction ("increment_write_ptr", &PBD::RingBufferNPT<float>::increment_write_ptr)
457                 .endClass ()
458
459                 .beginClass <PBD::RingBufferNPT <int> > ("RingBufferI")
460                 .addConstructor <void (*) (size_t)> ()
461                 .addFunction ("reset", &PBD::RingBufferNPT<int>::reset)
462                 .addFunction ("read", &PBD::RingBufferNPT<int>::read)
463                 .addFunction ("write", &PBD::RingBufferNPT<int>::write)
464                 .addFunction ("write_one", &PBD::RingBufferNPT<int>::write_one)
465                 .addFunction ("write_space", &PBD::RingBufferNPT<int>::write_space)
466                 .addFunction ("read_space", &PBD::RingBufferNPT<int>::read_space)
467                 .addFunction ("increment_read_ptr", &PBD::RingBufferNPT<int>::increment_read_ptr)
468                 .addFunction ("increment_write_ptr", &PBD::RingBufferNPT<int>::increment_write_ptr)
469                 .endClass ()
470
471                 /* PBD enums */
472                 .beginNamespace ("GroupControlDisposition")
473                 .addConst ("InverseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::InverseGroup))
474                 .addConst ("NoGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::NoGroup))
475                 .addConst ("UseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::UseGroup))
476                 .endNamespace ()
477
478                 .endNamespace (); // PBD
479
480         luabridge::getGlobalNamespace (L)
481                 .beginNamespace ("Timecode")
482                 .beginClass <Timecode::BBT_Time> ("BBT_TIME")
483                 .addConstructor <void (*) (uint32_t, uint32_t, uint32_t)> ()
484                 .addData ("bars", &Timecode::BBT_Time::bars)
485                 .addData ("beats", &Timecode::BBT_Time::beats)
486                 .addData ("ticks", &Timecode::BBT_Time::ticks)
487                 //.addStaticData ("ticks_per_beat", &Timecode::BBT_Time::ticks_per_beat, false)
488                 .endClass ()
489
490                 .beginClass <Timecode::Time> ("Time")
491                 .addConstructor <void (*) (double)> ()
492                 .addData ("negative", &Timecode::Time::negative)
493                 .addData ("hours", &Timecode::Time::hours)
494                 .addData ("minutes", &Timecode::Time::minutes)
495                 .addData ("seconds", &Timecode::Time::seconds)
496                 .addData ("frames", &Timecode::Time::frames)
497                 .addData ("subframes", &Timecode::Time::subframes)
498                 .addData ("rate", &Timecode::Time::rate)
499                 .addData ("drop", &Timecode::Time::drop)
500                 .endClass ()
501
502                 // TODO add increment, decrement; push it into the class
503
504                 /* libtimecode enums */
505                 .beginNamespace ("TimecodeFormat")
506                 .addConst ("TC23976", Timecode::TimecodeFormat(Timecode::timecode_23976))
507                 .addConst ("TC24", Timecode::TimecodeFormat(Timecode::timecode_24))
508                 .addConst ("TC24976", Timecode::TimecodeFormat(Timecode::timecode_24976))
509                 .addConst ("TC25", Timecode::TimecodeFormat(Timecode::timecode_25))
510                 .addConst ("TC2997", Timecode::TimecodeFormat(Timecode::timecode_2997))
511                 .addConst ("TC2997DF", Timecode::TimecodeFormat(Timecode::timecode_2997drop))
512                 .addConst ("TC2997000", Timecode::TimecodeFormat(Timecode::timecode_2997000))
513                 .addConst ("TC2997000DF", Timecode::TimecodeFormat(Timecode::timecode_2997000drop))
514                 .addConst ("TC30", Timecode::TimecodeFormat(Timecode::timecode_30))
515                 .addConst ("TC5994", Timecode::TimecodeFormat(Timecode::timecode_5994))
516                 .addConst ("TC60", Timecode::TimecodeFormat(Timecode::timecode_60))
517                 .endNamespace ()
518                 .endNamespace ();
519
520         luabridge::getGlobalNamespace (L)
521
522                 .beginNamespace ("Evoral")
523                 .beginClass <Evoral::Event<samplepos_t> > ("Event")
524                 .addFunction ("clear", &Evoral::Event<samplepos_t>::clear)
525                 .addFunction ("size", &Evoral::Event<samplepos_t>::size)
526                 .addFunction ("set_buffer", &Evoral::Event<samplepos_t>::set_buffer)
527                 .addFunction ("buffer", (uint8_t*(Evoral::Event<samplepos_t>::*)())&Evoral::Event<samplepos_t>::buffer)
528                 .addFunction ("time", (samplepos_t (Evoral::Event<samplepos_t>::*)())&Evoral::Event<samplepos_t>::time)
529                 .endClass ()
530
531                 .beginClass <Temporal::Beats> ("Beats")
532                 .addConstructor <void (*) (double)> ()
533                 .addFunction ("to_double", &Temporal::Beats::to_double)
534                 .endClass ()
535
536                 .beginClass <Evoral::Parameter> ("Parameter")
537                 .addConstructor <void (*) (uint32_t, uint8_t, uint32_t)> ()
538                 .addFunction ("type", &Evoral::Parameter::type)
539                 .addFunction ("channel", &Evoral::Parameter::channel)
540                 .addFunction ("id", &Evoral::Parameter::id)
541                 .endClass ()
542
543                 .beginClass <Evoral::ControlEvent> ("ControlEvent")
544                 .addData ("when", &Evoral::ControlEvent::when)
545                 .addData ("value", &Evoral::ControlEvent::value)
546                 .endClass ()
547
548                 .beginWSPtrClass <Evoral::ControlList> ("ControlList")
549                 .addFunction ("add", &Evoral::ControlList::add)
550                 .addFunction ("editor_add", &Evoral::ControlList::editor_add)
551                 .addFunction ("thin", &Evoral::ControlList::thin)
552                 .addFunction ("eval", &Evoral::ControlList::eval)
553                 .addRefFunction ("rt_safe_eval", &Evoral::ControlList::rt_safe_eval)
554                 .addFunction ("interpolation", &Evoral::ControlList::interpolation)
555                 .addFunction ("set_interpolation", &Evoral::ControlList::set_interpolation)
556                 .addFunction ("truncate_end", &Evoral::ControlList::truncate_end)
557                 .addFunction ("truncate_start", &Evoral::ControlList::truncate_start)
558                 .addFunction ("clear", (void (Evoral::ControlList::*)(double, double))&Evoral::ControlList::clear)
559                 .addFunction ("clear_list", (void (Evoral::ControlList::*)())&Evoral::ControlList::clear)
560                 .addFunction ("in_write_pass", &Evoral::ControlList::in_write_pass)
561                 .addFunction ("events", &Evoral::ControlList::events)
562                 .endClass ()
563
564                 .beginWSPtrClass <Evoral::ControlSet> ("ControlSet")
565                 .endClass ()
566
567                 .beginWSPtrClass <Evoral::Control> ("Control")
568                 .addFunction ("list", (boost::shared_ptr<Evoral::ControlList>(Evoral::Control::*)())&Evoral::Control::list)
569                 .endClass ()
570
571                 .beginClass <Evoral::ParameterDescriptor> ("ParameterDescriptor")
572                 .addVoidConstructor ()
573                 .addData ("lower", &Evoral::ParameterDescriptor::lower)
574                 .addData ("upper", &Evoral::ParameterDescriptor::upper)
575                 .addData ("normal", &Evoral::ParameterDescriptor::normal)
576                 .addData ("toggled", &Evoral::ParameterDescriptor::toggled)
577                 .addData ("logarithmic", &Evoral::ParameterDescriptor::logarithmic)
578                 .endClass ()
579
580                 .beginClass <Evoral::Range<samplepos_t> > ("Range")
581                 .addConstructor <void (*) (samplepos_t, samplepos_t)> ()
582                 .addData ("from", &Evoral::Range<samplepos_t>::from)
583                 .addData ("to", &Evoral::Range<samplepos_t>::to)
584                 .endClass ()
585
586                 .deriveWSPtrClass <Evoral::Sequence<Temporal::Beats>, Evoral::ControlSet> ("Sequence")
587                 .endClass ()
588
589                 .beginWSPtrClass <Evoral::Note<Temporal::Beats> > ("NotePtr")
590                 .addFunction ("time", &Evoral::Note<Temporal::Beats>::time)
591                 .addFunction ("note", &Evoral::Note<Temporal::Beats>::note)
592                 .addFunction ("velocity", &Evoral::Note<Temporal::Beats>::velocity)
593                 .addFunction ("off_velocity", &Evoral::Note<Temporal::Beats>::off_velocity)
594                 .addFunction ("length", &Evoral::Note<Temporal::Beats>::length)
595                 .addFunction ("channel", &Evoral::Note<Temporal::Beats>::channel)
596                 .endClass ()
597
598                 /* libevoral enums */
599                 .beginNamespace ("InterpolationStyle")
600                 .addConst ("Discrete", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Discrete))
601                 .addConst ("Linear", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Linear))
602                 .addConst ("Curved", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Curved))
603                 .endNamespace ()
604
605                 .endNamespace (); // Evoral
606
607         luabridge::getGlobalNamespace (L)
608                 .beginNamespace ("Vamp")
609
610                 .beginClass<Vamp::RealTime> ("RealTime")
611                 .addConstructor <void (*) (int, int)> ()
612                 .addData ("sec", &Vamp::RealTime::sec, false)
613                 .addData ("nsec", &Vamp::RealTime::nsec, false)
614                 .addFunction ("usec", &Vamp::RealTime::usec)
615                 .addFunction ("msec", &Vamp::RealTime::msec)
616                 .addFunction ("toString", &Vamp::RealTime::toString)
617                 .addStaticFunction ("realTime2Frame", &Vamp::RealTime::realTime2Frame)
618                 .addStaticFunction ("frame2RealTime", &Vamp::RealTime::frame2RealTime)
619                 .endClass ()
620
621                 .beginClass<Vamp::PluginBase> ("PluginBase")
622                 .addFunction ("getIdentifier", &Vamp::PluginBase::getIdentifier)
623                 .addFunction ("getName", &Vamp::PluginBase::getName)
624                 .addFunction ("getDescription", &Vamp::PluginBase::getDescription)
625                 .addFunction ("getMaker", &Vamp::PluginBase::getMaker)
626                 .addFunction ("getCopyright", &Vamp::PluginBase::getCopyright)
627                 .addFunction ("getPluginVersion", &Vamp::PluginBase::getPluginVersion)
628                 .addFunction ("getParameterDescriptors", &Vamp::PluginBase::getParameterDescriptors)
629                 .addFunction ("getParameter", &Vamp::PluginBase::getParameter)
630                 .addFunction ("setParameter", &Vamp::PluginBase::setParameter)
631                 .addFunction ("getPrograms", &Vamp::PluginBase::getPrograms)
632                 .addFunction ("getCurrentProgram", &Vamp::PluginBase::getCurrentProgram)
633                 .addFunction ("selectProgram", &Vamp::PluginBase::selectProgram)
634                 .addFunction ("getType", &Vamp::PluginBase::getType)
635                 .endClass ()
636
637                 .beginNamespace ("PluginBase")
638                 .beginClass<Vamp::PluginBase::ParameterDescriptor> ("ParameterDescriptor")
639                 .addData ("identifier", &Vamp::PluginBase::ParameterDescriptor::identifier)
640                 .addData ("name", &Vamp::PluginBase::ParameterDescriptor::name)
641                 .addData ("description", &Vamp::PluginBase::ParameterDescriptor::description)
642                 .addData ("unit", &Vamp::PluginBase::ParameterDescriptor::unit)
643                 .addData ("minValue", &Vamp::PluginBase::ParameterDescriptor::minValue)
644                 .addData ("maxValue", &Vamp::PluginBase::ParameterDescriptor::maxValue)
645                 .addData ("defaultValue", &Vamp::PluginBase::ParameterDescriptor::defaultValue)
646                 .addData ("isQuantized", &Vamp::PluginBase::ParameterDescriptor::isQuantized)
647                 .addData ("quantizeStep", &Vamp::PluginBase::ParameterDescriptor::quantizeStep)
648                 .addData ("valueNames", &Vamp::PluginBase::ParameterDescriptor::valueNames)
649                 .endClass ()
650
651                 .beginStdVector <Vamp::PluginBase::ParameterDescriptor> ("ParameterList")
652                 .endClass ()
653                 .endNamespace () // Vamp::PluginBase
654
655                 .deriveClass<Vamp::Plugin, Vamp::PluginBase> ("Plugin")
656                 //.addFunction ("process", &Vamp::Plugin::process) // unusable due to  float*const* -> LuaAPI::Vamp::process
657                 .addFunction ("initialise", &Vamp::Plugin::initialise)
658                 .addFunction ("reset", &Vamp::Plugin::reset)
659                 .addFunction ("getInputDomain", &Vamp::Plugin::getInputDomain)
660                 .addFunction ("getPreferredBlockSize", &Vamp::Plugin::getPreferredBlockSize)
661                 .addFunction ("getPreferredStepSize", &Vamp::Plugin::getPreferredStepSize)
662                 .addFunction ("getMinChannelCount", &Vamp::Plugin::getMinChannelCount)
663                 .addFunction ("getMaxChannelCount", &Vamp::Plugin::getMaxChannelCount)
664                 .addFunction ("getOutputDescriptors", &Vamp::Plugin::getOutputDescriptors)
665                 .addFunction ("getRemainingFeatures", &Vamp::Plugin::getRemainingFeatures)
666                 .addFunction ("getType", &Vamp::Plugin::getType)
667                 .endClass ()
668
669                 .beginNamespace ("Plugin")
670                 .beginClass<Vamp::Plugin::OutputDescriptor> ("OutputDescriptor")
671                 .addData ("identifier", &Vamp::Plugin::OutputDescriptor::identifier)
672                 .addData ("description", &Vamp::Plugin::OutputDescriptor::description)
673                 .addData ("unit", &Vamp::Plugin::OutputDescriptor::unit)
674                 .addData ("hasFixedBinCount", &Vamp::Plugin::OutputDescriptor::hasFixedBinCount)
675                 .addData ("binCount", &Vamp::Plugin::OutputDescriptor::binCount)
676                 .addData ("binNames", &Vamp::Plugin::OutputDescriptor::binNames)
677                 .addData ("hasKnownExtents", &Vamp::Plugin::OutputDescriptor::hasKnownExtents)
678                 .addData ("minValue", &Vamp::Plugin::OutputDescriptor::minValue)
679                 .addData ("maxValue", &Vamp::Plugin::OutputDescriptor::maxValue)
680                 .addData ("isQuantized", &Vamp::Plugin::OutputDescriptor::isQuantized)
681                 .addData ("quantizeStep", &Vamp::Plugin::OutputDescriptor::quantizeStep)
682                 .addData ("sampleType", &Vamp::Plugin::OutputDescriptor::sampleType)
683                 .addData ("sampleRate", &Vamp::Plugin::OutputDescriptor::sampleRate)
684                 .addData ("hasDuration", &Vamp::Plugin::OutputDescriptor::hasDuration)
685                 .endClass ()
686
687                 /* Vamp::Plugin enums */
688                 .beginNamespace ("InputDomain")
689                 .addConst ("TimeDomain", Vamp::Plugin::InputDomain(Vamp::Plugin::TimeDomain))
690                 .addConst ("FrequencyDomain", Vamp::Plugin::InputDomain(Vamp::Plugin::FrequencyDomain))
691                 .endNamespace ()
692
693                 /* Vamp::Plugin::OutputDescriptor enum */
694                 .beginNamespace ("OutputDescriptor")
695                 .beginNamespace ("SampleType")
696                 .addConst ("OneSamplePerStep", Vamp::Plugin::OutputDescriptor::SampleType(Vamp::Plugin::OutputDescriptor::OneSamplePerStep))
697                 .addConst ("FixedSampleRate", Vamp::Plugin::OutputDescriptor::SampleType(Vamp::Plugin::OutputDescriptor::FixedSampleRate))
698                 .addConst ("VariableSampleRate", Vamp::Plugin::OutputDescriptor::SampleType(Vamp::Plugin::OutputDescriptor::VariableSampleRate))
699                 .endNamespace ()
700                 .endNamespace () /* Vamp::Plugin::OutputDescriptor */
701
702                 .beginClass<Vamp::Plugin::Feature> ("Feature")
703                 .addData ("hasTimestamp", &Vamp::Plugin::Feature::hasTimestamp, false)
704                 .addData ("timestamp", &Vamp::Plugin::Feature::timestamp, false)
705                 .addData ("hasDuration", &Vamp::Plugin::Feature::hasDuration, false)
706                 .addData ("duration", &Vamp::Plugin::Feature::duration, false)
707                 .addData ("values", &Vamp::Plugin::Feature::values, false)
708                 .addData ("label", &Vamp::Plugin::Feature::label, false)
709                 .endClass ()
710
711                 .beginStdVector <Vamp::Plugin::OutputDescriptor> ("OutputList")
712                 .endClass ()
713
714                 .beginStdVector <Vamp::Plugin::Feature> ("FeatureList")
715                 .endClass ()
716
717                 .beginStdMap <int, Vamp::Plugin::FeatureList> ("FeatureSet")
718                 .endClass ()
719
720                 .endNamespace () // Vamp::Plugin
721                 .endNamespace ();// Vamp
722
723         luabridge::getGlobalNamespace (L)
724                 .beginNamespace ("ARDOUR")
725
726                 .beginClass <InterThreadInfo> ("InterThreadInfo")
727                 .addVoidConstructor ()
728                 .addData ("done", const_cast<bool InterThreadInfo::*>(&InterThreadInfo::done))
729 #if 0 // currently unused, lua is single-threaded, no custom UIs.
730                 .addData ("cancel", (bool InterThreadInfo::*)&InterThreadInfo::cancel)
731 #endif
732                 .addData ("progress", const_cast<float InterThreadInfo::*>(&InterThreadInfo::progress))
733                 .endClass ()
734
735                 .beginClass <Progress> ("Progress")
736                 .endClass ()
737
738                 .beginClass <MusicSample> ("MusicSample")
739                 .addConstructor <void (*) (samplepos_t, int32_t)> ()
740                 .addFunction ("set", &MusicSample::set)
741                 .addData ("frame", &MusicSample::sample)
742                 .addData ("division", &MusicSample::division)
743                 .endClass ()
744
745                 .beginClass <AudioRange> ("AudioRange")
746                 .addConstructor <void (*) (samplepos_t, samplepos_t, uint32_t)> ()
747                 .addFunction ("length", &AudioRange::length)
748                 .addFunction ("equal", &AudioRange::equal)
749                 .addData ("start", &AudioRange::start)
750                 .addData ("_end", &AudioRange::end) // XXX "end" is a lua reserved word
751                 .addData ("id", &AudioRange::id)
752                 .endClass ()
753
754                 .beginWSPtrClass <PluginInfo> ("PluginInfo")
755                 .addNilPtrConstructor ()
756                 .addData ("name", &PluginInfo::name, false)
757                 .addData ("category", &PluginInfo::category, false)
758                 .addData ("creator", &PluginInfo::creator, false)
759                 .addData ("path", &PluginInfo::path, false)
760                 .addData ("n_inputs", &PluginInfo::n_inputs, false)
761                 .addData ("n_outputs", &PluginInfo::n_outputs, false)
762                 .addData ("type", &PluginInfo::type, false)
763                 .addData ("unique_id", &PluginInfo::unique_id, false)
764                 .addFunction ("is_instrument", &PluginInfo::is_instrument)
765                 .addFunction ("get_presets", &PluginInfo::get_presets)
766                 .endClass ()
767
768                 .beginNamespace ("Route")
769                 .beginClass <Route::ProcessorStreams> ("ProcessorStreams")
770                 .addVoidConstructor ()
771                 .endClass ()
772                 .endNamespace ()
773
774                 .beginClass <ChanMapping> ("ChanMapping")
775                 .addVoidConstructor ()
776                 .addFunction ("get", static_cast<uint32_t(ChanMapping::*)(DataType, uint32_t) const>(&ChanMapping::get))
777                 .addFunction ("set", &ChanMapping::set)
778                 .addFunction ("count", &ChanMapping::count)
779                 .addFunction ("n_total", &ChanMapping::n_total)
780                 .addFunction ("is_monotonic", &ChanMapping::is_monotonic)
781                 .addConst ("Invalid", 4294967295U) // UINT32_MAX
782                 .endClass ()
783
784                 .beginNamespace ("Properties")
785                 // templated class definitions
786                 .beginClass <PBD::PropertyDescriptor<bool> > ("BoolProperty").endClass ()
787                 .beginClass <PBD::PropertyDescriptor<float> > ("FloatProperty").endClass ()
788                 .beginClass <PBD::PropertyDescriptor<samplepos_t> > ("FrameposProperty").endClass ()
789                 // actual references (TODO: also expose GQuark for std::set)
790                 //   ardour/region.h
791                 .addConst ("Start", &ARDOUR::Properties::start)
792                 .addConst ("Length", &ARDOUR::Properties::length)
793                 .addConst ("Position", &ARDOUR::Properties::position)
794                 .endNamespace ()
795
796                 .beginClass <PBD::PropertyChange> ("PropertyChange")
797                 // TODO add special handling (std::set<PropertyID>), PropertyID is a GQuark.
798                 // -> direct map to lua table  beginStdSet()A
799                 //
800                 // expand templated PropertyDescriptor<T>
801                 .addFunction ("containsBool", &PBD::PropertyChange::contains<bool>)
802                 .addFunction ("containsFloat", &PBD::PropertyChange::contains<float>)
803                 .addFunction ("containsFramePos", &PBD::PropertyChange::contains<samplepos_t>)
804                 .endClass ()
805
806                 .beginClass <PBD::PropertyList> ("PropertyList")
807                 // is-a  std::map<PropertyID, PropertyBase*>
808                 .endClass ()
809
810                 .deriveClass <PBD::OwnedPropertyList, PBD::PropertyList> ("OwnedPropertyList")
811                 .endClass ()
812
813                 .deriveWSPtrClass <AutomationList, Evoral::ControlList> ("AutomationList")
814                 .addCast<PBD::Stateful> ("to_stateful")
815                 .addCast<PBD::StatefulDestructible> ("to_statefuldestructible")
816                 .addCast<Evoral::ControlList> ("list") // deprecated
817                 .addFunction ("get_state", &AutomationList::get_state)
818                 .addFunction ("memento_command", &AutomationList::memento_command)
819                 .addFunction ("touching", &AutomationList::touching)
820                 .addFunction ("writing", &AutomationList::writing)
821                 .addFunction ("touch_enabled", &AutomationList::touch_enabled)
822                 .endClass ()
823
824                 .deriveClass <Location, PBD::StatefulDestructible> ("Location")
825                 .addFunction ("name", &Location::name)
826                 .addFunction ("locked", &Location::locked)
827                 .addFunction ("lock", &Location::lock)
828                 .addFunction ("unlock", &Location::unlock)
829                 .addFunction ("start", &Location::start)
830                 .addFunction ("_end", &Location::end) // XXX "end" is a lua reserved word
831                 .addFunction ("length", &Location::length)
832                 .addFunction ("set_start", &Location::set_start)
833                 .addFunction ("set_end", &Location::set_end)
834                 .addFunction ("set_length", &Location::set)
835                 .addFunction ("set_name", &Location::set_name)
836                 .addFunction ("move_to", &Location::move_to)
837                 .addFunction ("matches", &Location::matches)
838                 .addFunction ("flags", &Location::flags)
839                 .addFunction ("is_auto_punch", &Location::is_auto_punch)
840                 .addFunction ("is_auto_loop", &Location::is_auto_loop)
841                 .addFunction ("is_mark", &Location::is_mark)
842                 .addFunction ("is_hidden", &Location::is_hidden)
843                 .addFunction ("is_cd_marker", &Location::is_cd_marker)
844                 .addFunction ("is_session_range", &Location::is_session_range)
845                 .addFunction ("is_range_marker", &Location::is_range_marker)
846                 .endClass ()
847
848                 .deriveClass <Locations, PBD::StatefulDestructible> ("Locations")
849                 .addFunction ("list", static_cast<Locations::LocationList (Locations::*)()>(&Locations::list))
850                 .addFunction ("auto_loop_location", &Locations::auto_loop_location)
851                 .addFunction ("auto_punch_location", &Locations::auto_punch_location)
852                 .addFunction ("session_range_location", &Locations::session_range_location)
853                 .addFunction ("first_mark_after", &Locations::first_mark_after)
854                 .addFunction ("first_mark_before", &Locations::first_mark_before)
855                 .addFunction ("first_mark_at", &Locations::mark_at)
856                 .addFunction ("mark_at", &Locations::mark_at)
857                 .addFunction ("remove", &Locations::remove)
858                 .addRefFunction ("marks_either_side", &Locations::marks_either_side)
859                 .addRefFunction ("find_all_between", &Locations::find_all_between)
860                 .endClass ()
861
862                 .beginWSPtrClass <SessionObject> ("SessionObjectPtr")
863                 /* SessionObject is-a PBD::StatefulDestructible,
864                  * but multiple inheritance is not covered by luabridge,
865                  * we need explicit casts */
866                 .addCast<PBD::Stateful> ("to_stateful")
867                 .addCast<PBD::StatefulDestructible> ("to_statefuldestructible")
868                 .addFunction ("name", &SessionObject::name)
869                 .endClass ()
870
871                 .beginClass <SessionObject> ("SessionObject")
872                 .addFunction ("name", &SessionObject::name)
873                 .addCast<PBD::Stateful> ("to_stateful")
874                 .endClass ()
875
876                 .beginWSPtrClass <Port> ("Port")
877                 .addCast<MidiPort> ("to_midiport")
878                 .addCast<AsyncMIDIPort> ("to_asyncmidiport")
879                 .addCast<AudioPort> ("to_audioport")
880                 .addFunction ("name", &Port::name)
881                 .addFunction ("pretty_name", &Port::pretty_name)
882                 .addFunction ("receives_input", &Port::receives_input)
883                 .addFunction ("sends_output", &Port::sends_output)
884                 .addFunction ("connected", &Port::connected)
885                 .addFunction ("disconnect_all", &Port::disconnect_all)
886                 .addFunction ("connected_to", (bool (Port::*)(std::string const &)const)&Port::connected_to)
887                 .addFunction ("connect", (int (Port::*)(std::string const &))&Port::connect)
888                 .addFunction ("disconnect", (int (Port::*)(std::string const &))&Port::disconnect)
889                 .addFunction ("physically_connected", &Port::physically_connected)
890                 .addFunction ("private_latency_range", &Port::private_latency_range)
891                 .addFunction ("public_latency_range", &Port::public_latency_range)
892                 .addRefFunction ("get_connected_latency_range", &Port::get_connected_latency_range)
893                 //.addStaticFunction ("port_offset", &Port::port_offset) // static
894                 .endClass ()
895
896                 .deriveWSPtrClass <AudioPort, Port> ("AudioPort")
897                 .endClass ()
898
899                 .deriveWSPtrClass <MidiPort, Port> ("MidiPort")
900                 .addCast<AsyncMIDIPort> ("to_asyncmidiport")
901                 .addFunction ("input_active", &MidiPort::input_active)
902                 .addFunction ("set_input_active", &MidiPort::set_input_active)
903                 .addFunction ("get_midi_buffer", &MidiPort::get_midi_buffer) // DSP only
904                 .endClass ()
905
906                 .deriveWSPtrClass <AsyncMIDIPort, MidiPort> ("AsyncMIDIPort")
907                 .addFunction ("write", &AsyncMIDIPort::write)
908                 .endClass ()
909
910                 .beginWSPtrClass <PortSet> ("PortSet")
911                 .addFunction ("num_ports", (size_t (PortSet::*)(DataType)const)&PortSet::num_ports)
912                 .addFunction ("add", &PortSet::add)
913                 .addFunction ("remove", &PortSet::remove)
914                 .addFunction ("port", (boost::shared_ptr<Port> (PortSet::*)(DataType, size_t)const)&PortSet::port)
915                 .addFunction ("contains", &PortSet::contains)
916                 .addFunction ("clear", &PortSet::clear)
917                 .addFunction ("empty", &PortSet::empty)
918                 .endClass ()
919
920                 .deriveWSPtrClass <IO, SessionObject> ("IO")
921                 .addFunction ("active", &IO::active)
922                 .addFunction ("add_port", &IO::add_port)
923                 .addFunction ("remove_port", &IO::remove_port)
924                 .addFunction ("connect", &IO::connect)
925                 .addFunction ("disconnect", (int (IO::*)(boost::shared_ptr<Port>, std::string, void *))&IO::disconnect)
926                 .addFunction ("disconnect_all", (int (IO::*)(void *))&IO::disconnect)
927                 .addFunction ("physically_connected", &IO::physically_connected)
928                 .addFunction ("has_port", &IO::has_port)
929                 .addFunction ("nth", &IO::nth)
930                 .addFunction ("audio", &IO::audio)
931                 .addFunction ("midi", &IO::midi)
932                 .addFunction ("port_by_name", &IO::nth)
933                 .addFunction ("n_ports", &IO::n_ports)
934                 .addFunction ("latency", &IO::latency)
935                 .addFunction ("public_latency", &IO::latency)
936                 .endClass ()
937
938                 .deriveWSPtrClass <PannerShell, SessionObject> ("PannerShell")
939                 .addFunction ("bypassed", &PannerShell::bypassed)
940                 .addFunction ("set_bypassed", &PannerShell::set_bypassed)
941                 .endClass ()
942
943                 .deriveClass <RouteGroup, SessionObject> ("RouteGroup")
944                 .addFunction ("is_active", &RouteGroup::is_active)
945                 .addFunction ("is_relative", &RouteGroup::is_relative)
946                 .addFunction ("is_hidden", &RouteGroup::is_hidden)
947                 .addFunction ("is_gain", &RouteGroup::is_gain)
948                 .addFunction ("is_mute", &RouteGroup::is_mute)
949                 .addFunction ("is_solo", &RouteGroup::is_solo)
950                 .addFunction ("is_recenable", &RouteGroup::is_recenable)
951                 .addFunction ("is_select", &RouteGroup::is_select)
952                 .addFunction ("is_route_active", &RouteGroup::is_route_active)
953                 .addFunction ("is_color", &RouteGroup::is_color)
954                 .addFunction ("is_monitoring", &RouteGroup::is_monitoring)
955                 .addFunction ("group_master_number", &RouteGroup::group_master_number)
956                 .addFunction ("empty", &RouteGroup::empty)
957                 .addFunction ("size", &RouteGroup::size)
958                 .addFunction ("set_active", &RouteGroup::set_active)
959                 .addFunction ("set_relative", &RouteGroup::set_relative)
960                 .addFunction ("set_hidden", &RouteGroup::set_hidden)
961                 .addFunction ("set_gain", &RouteGroup::set_gain)
962                 .addFunction ("set_mute", &RouteGroup::set_mute)
963                 .addFunction ("set_solo", &RouteGroup::set_solo)
964                 .addFunction ("set_recenable", &RouteGroup::set_recenable)
965                 .addFunction ("set_select", &RouteGroup::set_select)
966                 .addFunction ("set_route_active", &RouteGroup::set_route_active)
967                 .addFunction ("set_color", &RouteGroup::set_color)
968                 .addFunction ("set_monitoring", &RouteGroup::set_monitoring)
969                 .addFunction ("add", &RouteGroup::add)
970                 .addFunction ("remove", &RouteGroup::remove)
971                 .addFunction ("clear", &RouteGroup::clear)
972                 .addFunction ("set_rgba", &RouteGroup::set_rgba)
973                 .addFunction ("rgba", &RouteGroup::rgba)
974                 .addFunction ("has_subgroup", &RouteGroup::has_subgroup)
975                 .addFunction ("make_subgroup", &RouteGroup::make_subgroup)
976                 .addFunction ("destroy_subgroup", &RouteGroup::destroy_subgroup)
977                 .addFunction ("route_list", &RouteGroup::route_list)
978                 .endClass ()
979
980                 .deriveClass <PresentationInfo, PBD::Stateful> ("PresentationInfo")
981                 .addFunction ("color", &PresentationInfo::color)
982                 .addFunction ("set_color", &PresentationInfo::set_color)
983                 .addFunction ("order", &PresentationInfo::order)
984                 .addFunction ("special", &PresentationInfo::special)
985                 .addFunction ("flags", &PresentationInfo::flags)
986                 .addConst ("max_order", ARDOUR::PresentationInfo::max_order)
987                 .endClass ()
988
989                 .beginWSPtrClass <Slavable> ("Slavable")
990                 .addFunction ("assign", &Slavable::assign)
991                 .addFunction ("unassign", &Slavable::unassign)
992                 .addFunction ("masters", &Slavable::masters)
993                 .addFunction ("assigned_to", &Slavable::assigned_to)
994                 .endClass ()
995
996                 .deriveWSPtrClass <Stripable, SessionObject> ("Stripable")
997                 .addCast<Route> ("to_route")
998                 .addCast<VCA> ("to_vca")
999                 .addCast<Slavable> ("to_slavable")
1000                 .addCast<Automatable> ("to_automatable")
1001                 .addFunction ("is_auditioner", &Stripable::is_auditioner)
1002                 .addFunction ("is_private_route", &Stripable::is_private_route)
1003                 .addFunction ("is_master", &Stripable::is_master)
1004                 .addFunction ("is_monitor", &Stripable::is_monitor)
1005                 .addFunction ("is_hidden", &Stripable::is_hidden)
1006                 .addFunction ("is_selected", &Stripable::is_selected)
1007                 .addFunction ("gain_control", &Stripable::gain_control)
1008                 .addFunction ("solo_control", &Stripable::solo_control)
1009                 .addFunction ("solo_isolate_control", &Stripable::solo_isolate_control)
1010                 .addFunction ("solo_safe_control", &Stripable::solo_safe_control)
1011                 .addFunction ("mute_control", &Stripable::mute_control)
1012                 .addFunction ("phase_control", &Stripable::phase_control)
1013                 .addFunction ("trim_control", &Stripable::trim_control)
1014                 .addFunction ("rec_enable_control", &Stripable::rec_enable_control)
1015                 .addFunction ("rec_safe_control", &Stripable::rec_safe_control)
1016                 .addFunction ("pan_azimuth_control", &Stripable::pan_azimuth_control)
1017                 .addFunction ("pan_elevation_control", &Stripable::pan_elevation_control)
1018                 .addFunction ("pan_width_control", &Stripable::pan_width_control)
1019                 .addFunction ("pan_frontback_control", &Stripable::pan_frontback_control)
1020                 .addFunction ("pan_lfe_control", &Stripable::pan_lfe_control)
1021                 .addFunction ("send_level_control", &Stripable::send_level_controllable)
1022                 .addFunction ("send_enable_control", &Stripable::send_level_controllable)
1023                 .addFunction ("send_name", &Stripable::send_name)
1024                 .addFunction ("monitor_control", &Stripable::monitor_control)
1025                 .addFunction ("master_send_enable_control ", &Stripable::master_send_enable_controllable )
1026                 .addFunction ("comp_enable_control ", &Stripable::comp_enable_controllable )
1027                 .addFunction ("comp_threshold_control ", &Stripable::comp_threshold_controllable )
1028                 .addFunction ("comp_speed_control ", &Stripable::comp_speed_controllable )
1029                 .addFunction ("comp_mode_control ", &Stripable::comp_mode_controllable )
1030                 .addFunction ("comp_makeup_control ", &Stripable::comp_makeup_controllable )
1031                 .addFunction ("comp_redux_control ", &Stripable::comp_redux_controllable )
1032                 .addFunction ("comp_mode_name", &Stripable::comp_mode_name)
1033                 .addFunction ("comp_speed_name", &Stripable::comp_speed_name)
1034                 .addFunction ("eq_band_cnt ", &Stripable::eq_band_cnt)
1035                 .addFunction ("eq_enable_control ", &Stripable::eq_enable_controllable )
1036                 .addFunction ("eq_band_name", &Stripable::eq_band_name)
1037                 .addFunction ("eq_gain_control", &Stripable::eq_gain_controllable)
1038                 .addFunction ("eq_freq_control ", &Stripable::eq_freq_controllable )
1039                 .addFunction ("eq_q_control ", &Stripable::eq_q_controllable )
1040                 .addFunction ("eq_shape_control ", &Stripable::eq_shape_controllable )
1041                 .addFunction ("filter_freq_controllable ", &Stripable::filter_freq_controllable )
1042                 .addFunction ("filter_slope_controllable ", &Stripable::filter_slope_controllable )
1043                 .addFunction ("filter_enable_controllable ", &Stripable::filter_enable_controllable )
1044                 .addFunction ("set_presentation_order", &Stripable::set_presentation_order)
1045                 .addFunction ("presentation_info_ptr", &Stripable::presentation_info_ptr)
1046
1047                 .endClass ()
1048
1049                 .deriveWSPtrClass <VCA, Stripable> ("VCA")
1050                 .addFunction ("full_name", &VCA::full_name)
1051                 .addFunction ("number", &VCA::number)
1052                 .addFunction ("gain_control", &VCA::gain_control)
1053                 .addFunction ("solo_control", &VCA::solo_control)
1054                 .addFunction ("mute_control", &VCA::mute_control)
1055                 .addFunction ("slaved_to", &VCA::slaved_to)
1056                 .addFunction ("slaved", &VCA::slaved)
1057                 .endClass ()
1058
1059                 .deriveWSPtrClass <Route, Stripable> ("Route")
1060                 .addCast<Track> ("to_track")
1061                 .addFunction ("set_name", &Route::set_name)
1062                 .addFunction ("comment", &Route::comment)
1063                 .addFunction ("active", &Route::active)
1064                 .addFunction ("set_active", &Route::set_active)
1065                 .addFunction ("nth_plugin", &Route::nth_plugin)
1066                 .addFunction ("nth_processor", &Route::nth_processor)
1067                 .addFunction ("nth_send", &Route::nth_send)
1068                 .addFunction ("add_processor_by_index", &Route::add_processor_by_index)
1069                 .addFunction ("remove_processor", &Route::remove_processor)
1070                 .addFunction ("remove_processors", &Route::remove_processors)
1071                 .addFunction ("replace_processor", &Route::replace_processor)
1072                 .addFunction ("reorder_processors", &Route::reorder_processors)
1073                 .addFunction ("the_instrument", &Route::the_instrument)
1074                 .addFunction ("n_inputs", &Route::n_inputs)
1075                 .addFunction ("n_outputs", &Route::n_outputs)
1076                 .addFunction ("input", &Route::input)
1077                 .addFunction ("output", &Route::output)
1078                 .addFunction ("panner_shell", &Route::panner_shell)
1079                 .addFunction ("set_comment", &Route::set_comment)
1080                 .addFunction ("strict_io", &Route::strict_io)
1081                 .addFunction ("set_strict_io", &Route::set_strict_io)
1082                 .addFunction ("reset_plugin_insert", &Route::reset_plugin_insert)
1083                 .addFunction ("customize_plugin_insert", &Route::customize_plugin_insert)
1084                 .addFunction ("add_sidechain", &Route::add_sidechain)
1085                 .addFunction ("remove_sidechain", &Route::remove_sidechain)
1086                 .addFunction ("main_outs", &Route::main_outs)
1087                 .addFunction ("muted", &Route::muted)
1088                 .addFunction ("soloed", &Route::soloed)
1089                 .addFunction ("amp", &Route::amp)
1090                 .addFunction ("trim", &Route::trim)
1091                 .addFunction ("peak_meter", (boost::shared_ptr<PeakMeter> (Route::*)())&Route::peak_meter)
1092                 .addFunction ("set_meter_point", &Route::set_meter_point)
1093                 .addFunction ("signal_latency", &Route::signal_latency)
1094                 .addFunction ("playback_latency", &Route::playback_latency)
1095                 .endClass ()
1096
1097                 .deriveWSPtrClass <Playlist, SessionObject> ("Playlist")
1098                 .addCast<AudioPlaylist> ("to_audioplaylist")
1099                 .addCast<MidiPlaylist> ("to_midiplaylist")
1100                 .addFunction ("region_by_id", &Playlist::region_by_id)
1101                 .addFunction ("data_type", &Playlist::data_type)
1102                 .addFunction ("n_regions", &Playlist::n_regions)
1103                 //.addFunction ("get_extent", &Playlist::get_extent) // pair<samplepos_t, samplepos_t>
1104                 .addFunction ("region_list", &Playlist::region_list)
1105                 .addFunction ("add_region", &Playlist::add_region)
1106                 .addFunction ("remove_region", &Playlist::remove_region)
1107                 .addFunction ("regions_at", &Playlist::regions_at)
1108                 .addFunction ("top_region_at", &Playlist::top_region_at)
1109                 .addFunction ("top_unmuted_region_at", &Playlist::top_unmuted_region_at)
1110                 .addFunction ("find_next_transient", &Playlist::find_next_transient)
1111                 .addFunction ("find_next_region", &Playlist::find_next_region)
1112                 .addFunction ("find_next_region_boundary", &Playlist::find_next_region_boundary)
1113                 .addFunction ("count_regions_at", &Playlist::count_regions_at)
1114                 .addFunction ("regions_touched", &Playlist::regions_touched)
1115                 .addFunction ("regions_with_start_within", &Playlist::regions_with_start_within)
1116                 .addFunction ("regions_with_end_within", &Playlist::regions_with_end_within)
1117                 .addFunction ("raise_region", &Playlist::raise_region)
1118                 .addFunction ("lower_region", &Playlist::lower_region)
1119                 .addFunction ("raise_region_to_top", &Playlist::raise_region_to_top)
1120                 .addFunction ("lower_region_to_bottom", &Playlist::lower_region_to_bottom)
1121                 .addFunction ("duplicate", (void (Playlist::*)(boost::shared_ptr<Region>, samplepos_t, samplecnt_t, float))&Playlist::duplicate)
1122                 .addFunction ("duplicate_until", &Playlist::duplicate_until)
1123                 .addFunction ("duplicate_range", &Playlist::duplicate_range)
1124                 .addFunction ("combine", &Playlist::combine)
1125                 .addFunction ("uncombine", &Playlist::uncombine)
1126                 .addFunction ("split_region", &Playlist::split_region)
1127                 .addFunction ("split", (void (Playlist::*)(samplepos_t))&Playlist::split)
1128                 .addFunction ("cut", (boost::shared_ptr<Playlist> (Playlist::*)(std::list<AudioRange>&, bool))&Playlist::cut)
1129 #if 0
1130                 .addFunction ("copy", &Playlist::copy)
1131                 .addFunction ("paste", &Playlist::paste)
1132 #endif
1133                 .endClass ()
1134
1135                 .deriveWSPtrClass <AudioPlaylist, Playlist> ("AudioPlaylist")
1136                 .addFunction ("read", &AudioPlaylist::read)
1137                 .endClass ()
1138
1139                 .deriveWSPtrClass <MidiPlaylist, Playlist> ("MidiPlaylist")
1140                 .addFunction ("set_note_mode", &MidiPlaylist::set_note_mode)
1141                 .endClass ()
1142
1143                 .deriveWSPtrClass <Track, Route> ("Track")
1144                 .addCast<AudioTrack> ("to_audio_track")
1145                 .addCast<MidiTrack> ("to_midi_track")
1146                 .addFunction ("set_name", &Track::set_name)
1147                 .addFunction ("can_record", &Track::can_record)
1148                 .addFunction ("bounceable", &Track::bounceable)
1149                 .addFunction ("bounce", &Track::bounce)
1150                 .addFunction ("bounce_range", &Track::bounce_range)
1151                 .addFunction ("playlist", &Track::playlist)
1152                 .endClass ()
1153
1154                 .deriveWSPtrClass <AudioTrack, Track> ("AudioTrack")
1155                 .endClass ()
1156
1157                 .deriveWSPtrClass <MidiTrack, Track> ("MidiTrack")
1158                 .endClass ()
1159
1160                 .beginWSPtrClass <Readable> ("Readable")
1161                 .addFunction ("read", &Readable::read)
1162                 .addFunction ("readable_length", &Readable::readable_length)
1163                 .addFunction ("n_channels", &Readable::n_channels)
1164                 .endClass ()
1165
1166                 .deriveWSPtrClass <Region, SessionObject> ("Region")
1167                 .addCast<Readable> ("to_readable")
1168                 .addCast<MidiRegion> ("to_midiregion")
1169                 .addCast<AudioRegion> ("to_audioregion")
1170                 /* properties */
1171                 .addFunction ("position", &Region::position)
1172                 .addFunction ("start", &Region::start)
1173                 .addFunction ("length", &Region::length)
1174                 .addFunction ("layer", &Region::layer)
1175                 .addFunction ("data_type", &Region::data_type)
1176                 .addFunction ("stretch", &Region::stretch)
1177                 .addFunction ("shift", &Region::shift)
1178                 .addRefFunction ("sync_offset", &Region::sync_offset)
1179                 .addFunction ("sync_position", &Region::sync_position)
1180                 .addFunction ("hidden", &Region::hidden)
1181                 .addFunction ("muted", &Region::muted)
1182                 .addFunction ("opaque", &Region::opaque)
1183                 .addFunction ("locked", &Region::locked)
1184                 .addFunction ("position_locked", &Region::position_locked)
1185                 .addFunction ("video_locked", &Region::video_locked)
1186                 .addFunction ("automatic", &Region::automatic)
1187                 .addFunction ("whole_file", &Region::whole_file)
1188                 .addFunction ("captured", &Region::captured)
1189                 .addFunction ("can_move", &Region::can_move)
1190                 .addFunction ("sync_marked", &Region::sync_marked)
1191                 .addFunction ("external", &Region::external)
1192                 .addFunction ("import", &Region::import)
1193                 .addFunction ("covers", &Region::covers)
1194                 .addFunction ("at_natural_position", &Region::at_natural_position)
1195                 .addFunction ("is_compound", &Region::is_compound)
1196
1197                 .addFunction ("has_transients", &Region::has_transients)
1198                 .addFunction ("transients", (AnalysisFeatureList (Region::*)())&Region::transients)
1199
1200                 /* editing operations */
1201                 .addFunction ("set_length", &Region::set_length)
1202                 .addFunction ("set_start", &Region::set_start)
1203                 .addFunction ("set_position", &Region::set_position)
1204                 .addFunction ("set_initial_position", &Region::set_initial_position)
1205                 .addFunction ("nudge_position", &Region::nudge_position)
1206                 .addFunction ("move_to_natural_position", &Region::move_to_natural_position)
1207                 .addFunction ("move_start", &Region::move_start)
1208                 .addFunction ("master_sources", &Region::master_sources)
1209                 .addFunction ("master_source_names", &Region::master_source_names)
1210                 .addFunction ("n_channels", &Region::n_channels)
1211                 .addFunction ("trim_front", &Region::trim_front)
1212                 .addFunction ("trim_end", &Region::trim_end)
1213                 .addFunction ("trim_to", &Region::trim_to)
1214                 .addFunction ("cut_front", &Region::cut_front)
1215                 .addFunction ("cut_end", &Region::cut_end)
1216                 .addFunction ("raise", &Region::raise)
1217                 .addFunction ("lower", &Region::lower)
1218                 .addFunction ("raise_to_top", &Region::raise_to_top)
1219                 .addFunction ("lower_to_bottom", &Region::lower_to_bottom)
1220                 .addFunction ("set_sync_position", &Region::set_sync_position)
1221                 .addFunction ("clear_sync_position", &Region::clear_sync_position)
1222                 .addFunction ("quarter_note", &Region::quarter_note)
1223                 .addFunction ("set_hidden", &Region::set_hidden)
1224                 .addFunction ("set_muted", &Region::set_muted)
1225                 .addFunction ("set_opaque", &Region::set_opaque)
1226                 .addFunction ("set_locked", &Region::set_locked)
1227                 .addFunction ("set_video_locked", &Region::set_video_locked)
1228                 .addFunction ("set_position_locked", &Region::set_position_locked)
1229                 .addFunction ("source", &Region::source)
1230                 .addFunction ("control", static_cast<boost::shared_ptr<Evoral::Control>(Region::*)(const Evoral::Parameter&, bool)>(&Region::control))
1231                 .endClass ()
1232
1233                 .deriveWSPtrClass <MidiRegion, Region> ("MidiRegion")
1234                 .addFunction ("do_export", &MidiRegion::do_export)
1235                 .addFunction ("midi_source", &MidiRegion::midi_source)
1236                 .addFunction ("model", (boost::shared_ptr<MidiModel> (MidiRegion::*)())&MidiRegion::model)
1237                 .addFunction ("start_beats", &MidiRegion::start_beats)
1238                 .addFunction ("length_beats", &MidiRegion::length_beats)
1239                 .endClass ()
1240
1241                 .deriveWSPtrClass <AudioRegion, Region> ("AudioRegion")
1242                 .addFunction ("audio_source", &AudioRegion::audio_source)
1243                 .addFunction ("set_scale_amplitude", &AudioRegion::set_scale_amplitude)
1244                 .addFunction ("scale_amplitude", &AudioRegion::scale_amplitude)
1245                 .addFunction ("maximum_amplitude", &AudioRegion::maximum_amplitude)
1246                 .addFunction ("rms", &AudioRegion::rms)
1247                 .addRefFunction ("separate_by_channel", &AudioRegion::separate_by_channel)
1248                 .endClass ()
1249
1250                 .deriveWSPtrClass <Source, SessionObject> ("Source")
1251                 .addCast<AudioSource> ("to_audiosource")
1252                 .addCast<MidiSource> ("to_midisource")
1253                 .addCast<FileSource> ("to_filesource")
1254                 .addFunction ("timestamp", &Source::timestamp)
1255                 .addFunction ("empty", &Source::empty)
1256                 .addFunction ("length", &Source::length)
1257                 .addFunction ("natural_position", &Source::natural_position)
1258                 .addFunction ("destructive", &Source::destructive)
1259                 .addFunction ("writable", &Source::writable)
1260                 .addFunction ("has_been_analysed", &Source::has_been_analysed)
1261                 .addFunction ("can_be_analysed", &Source::can_be_analysed)
1262                 .addFunction ("timeline_position", &Source::timeline_position)
1263                 .addFunction ("use_count", &Source::use_count)
1264                 .addFunction ("used", &Source::used)
1265                 .addFunction ("ancestor_name", &Source::ancestor_name)
1266                 .endClass ()
1267
1268                 .deriveWSPtrClass <FileSource, Source> ("FileSource")
1269                 .addFunction ("path", &FileSource::path)
1270                 .addFunction ("within_session", &FileSource::within_session)
1271                 .addFunction ("channel", &FileSource::channel)
1272                 .addFunction ("origin", &FileSource::origin)
1273                 .addFunction ("take_id", &FileSource::take_id)
1274                 .addFunction ("gain", &FileSource::gain)
1275                 .endClass ()
1276
1277                 .deriveWSPtrClass <MidiSource, Source> ("MidiSource")
1278                 .addFunction ("empty", &MidiSource::empty)
1279                 .addFunction ("length", &MidiSource::length)
1280                 .addFunction ("model", &MidiSource::model)
1281                 .endClass ()
1282
1283                 .deriveWSPtrClass <AudioSource, Source> ("AudioSource")
1284                 .addCast<Readable> ("to_readable")
1285                 .addFunction ("readable_length", &AudioSource::readable_length)
1286                 .addFunction ("n_channels", &AudioSource::n_channels)
1287                 .addFunction ("empty", &Source::empty)
1288                 .addFunction ("length", &Source::length)
1289                 .addFunction ("read", &AudioSource::read)
1290                 .addFunction ("sample_rate", &AudioSource::sample_rate)
1291                 .addFunction ("captured_for", &AudioSource::captured_for)
1292                 .endClass ()
1293
1294                 .deriveWSPtrClass <Automatable, Evoral::ControlSet> ("Automatable")
1295                 .addCast<Slavable> ("to_slavable")
1296                 .addFunction ("automation_control", (boost::shared_ptr<AutomationControl>(Automatable::*)(const Evoral::Parameter&, bool))&Automatable::automation_control)
1297                 //.addFunction ("what_can_be_automated", &Automatable::what_can_be_automated)
1298                 .endClass ()
1299
1300                 .deriveWSPtrClass <AutomatableSequence<Temporal::Beats>, Automatable> ("AutomatableSequence")
1301                 .addCast<Evoral::Sequence<Temporal::Beats> > ("to_sequence")
1302                 .endClass ()
1303
1304                 .deriveWSPtrClass <MidiModel, AutomatableSequence<Temporal::Beats> > ("MidiModel")
1305                 .addFunction ("apply_command", (void (MidiModel::*)(Session*, Command*))&MidiModel::apply_command)
1306                 .addFunction ("new_note_diff_command", &MidiModel::new_note_diff_command)
1307                 .endClass ()
1308
1309                 .beginNamespace ("MidiModel")
1310                 .deriveClass<ARDOUR::MidiModel::DiffCommand, Command> ("DiffCommand")
1311                 .endClass ()
1312
1313                 .deriveClass<ARDOUR::MidiModel::NoteDiffCommand, ARDOUR::MidiModel::DiffCommand> ("NoteDiffCommand")
1314                 .addFunction ("add", &ARDOUR::MidiModel::NoteDiffCommand::add)
1315                 .addFunction ("remove", &ARDOUR::MidiModel::NoteDiffCommand::remove)
1316                 .endClass ()
1317
1318                 .endNamespace () /* ARDOUR::MidiModel */
1319
1320                 .beginClass <Plugin::PresetRecord> ("PresetRecord")
1321                 .addVoidConstructor ()
1322                 .addData ("uri", &Plugin::PresetRecord::uri, false)
1323                 .addData ("label", &Plugin::PresetRecord::label, false)
1324                 .addData ("user", &Plugin::PresetRecord::user, false)
1325                 .addData ("valid", &Plugin::PresetRecord::valid, false)
1326                 .endClass ()
1327
1328                 .beginStdVector <Plugin::PresetRecord> ("PresetVector").endClass ()
1329                 .beginStdList <boost::shared_ptr<ARDOUR::PluginInfo> > ("PluginInfoList").endClass ()
1330
1331                 .deriveClass <ParameterDescriptor, Evoral::ParameterDescriptor> ("ParameterDescriptor")
1332                 .addVoidConstructor ()
1333                 .addData ("label", &ParameterDescriptor::label)
1334                 .addStaticFunction ("midi_note_name", &ParameterDescriptor::midi_note_name)
1335                 .endClass ()
1336
1337                 .beginStdVector <boost::shared_ptr<ARDOUR::Processor> > ("ProcessorVector").endClass ()
1338
1339                 .deriveWSPtrClass <Processor, SessionObject> ("Processor")
1340                 .addCast<Automatable> ("to_automatable")
1341                 .addCast<PluginInsert> ("to_insert") // deprecated
1342                 .addCast<PluginInsert> ("to_plugininsert")
1343                 .addCast<SideChain> ("to_sidechain")
1344                 .addCast<IOProcessor> ("to_ioprocessor")
1345                 .addCast<UnknownProcessor> ("to_unknownprocessor")
1346                 .addCast<Amp> ("to_amp")
1347                 .addCast<DiskIOProcessor> ("to_diskioprocessor")
1348                 .addCast<DiskReader> ("to_diskreader")
1349                 .addCast<DiskWriter> ("to_diskwriter")
1350                 .addCast<PeakMeter> ("to_peakmeter")
1351                 .addCast<MonitorProcessor> ("to_monitorprocessor")
1352                 .addCast<Send> ("to_send")
1353                 .addCast<PolarityProcessor> ("to_polarityprocessor")
1354                 .addCast<DelayLine> ("to_delayline")
1355 #if 0 // those objects are not yet bound
1356                 .addCast<CapturingProcessor> ("to_capturingprocessor")
1357 #endif
1358                 .addCast<PeakMeter> ("to_meter")
1359                 .addFunction ("display_name", &Processor::display_name)
1360                 .addFunction ("display_to_user", &Processor::display_to_user)
1361                 .addFunction ("active", &Processor::active)
1362                 .addFunction ("activate", &Processor::activate)
1363                 .addFunction ("deactivate", &Processor::deactivate)
1364                 .addFunction ("input_latency", &Processor::input_latency)
1365                 .addFunction ("output_latency", &Processor::output_latency)
1366                 .addFunction ("capture_offset", &Processor::capture_offset)
1367                 .addFunction ("playback_offset", &Processor::playback_offset)
1368                 .addFunction ("output_streams", &Processor::output_streams)
1369                 .addFunction ("input_streams", &Processor::input_streams)
1370                 .addFunction ("signal_latency", &Processor::signal_latency)
1371                 .endClass ()
1372
1373                 .deriveWSPtrClass <DiskIOProcessor, Processor> ("DiskIOProcessor")
1374                 .endClass ()
1375
1376                 .deriveWSPtrClass <DiskReader, DiskIOProcessor> ("DiskReader")
1377                 .endClass ()
1378
1379                 .deriveWSPtrClass <DiskWriter, DiskIOProcessor> ("DiskWriter")
1380                 .endClass ()
1381
1382                 .deriveWSPtrClass <IOProcessor, Processor> ("IOProcessor")
1383                 .addFunction ("natural_input_streams", &IOProcessor::natural_input_streams)
1384                 .addFunction ("natural_output_streams", &IOProcessor::natural_output_streams)
1385                 .addFunction ("input", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::input)
1386                 .addFunction ("output", (boost::shared_ptr<IO>(IOProcessor::*)())&IOProcessor::output)
1387                 .endClass ()
1388
1389                 .deriveWSPtrClass <SideChain, IOProcessor> ("SideChain")
1390                 .endClass ()
1391
1392                 .deriveWSPtrClass <Delivery, IOProcessor> ("Delivery")
1393                 .addFunction ("panner_shell", &Route::panner_shell)
1394                 .endClass ()
1395
1396                 .deriveWSPtrClass <Send, Delivery> ("Send")
1397                 .addFunction ("get_delay_in", &Send::get_delay_in)
1398                 .addFunction ("get_delay_out", &Send::get_delay_out)
1399                 .endClass ()
1400
1401                 .deriveWSPtrClass <InternalSend, Send> ("InternalSend")
1402                 .endClass ()
1403
1404                 .deriveWSPtrClass <Return, IOProcessor> ("Return")
1405                 .endClass ()
1406
1407                 .deriveWSPtrClass <InternalReturn, Return> ("InternalReturn")
1408                 .endClass ()
1409
1410                 .beginNamespace ("Plugin")
1411                 .beginClass <Plugin::IOPortDescription> ("IOPortDescription")
1412                 .addData ("name", &Plugin::IOPortDescription::name)
1413                 .addData ("is_sidechain", &Plugin::IOPortDescription::is_sidechain)
1414                 .addData ("group_name", &Plugin::IOPortDescription::group_name)
1415                 .addData ("group_channel", &Plugin::IOPortDescription::group_channel)
1416                 .endClass ()
1417                 .endNamespace ()
1418
1419                 .deriveWSPtrClass <Plugin, PBD::StatefulDestructible> ("Plugin")
1420                 .addCast<LuaProc> ("to_luaproc")
1421                 .addFunction ("unique_id", &Plugin::unique_id)
1422                 .addFunction ("label", &Plugin::label)
1423                 .addFunction ("name", &Plugin::name)
1424                 .addFunction ("maker", &Plugin::maker)
1425                 .addFunction ("parameter_count", &Plugin::parameter_count)
1426                 .addFunction ("parameter_label", &Plugin::parameter_label)
1427                 .addRefFunction ("nth_parameter", &Plugin::nth_parameter)
1428                 .addFunction ("preset_by_label", &Plugin::preset_by_label)
1429                 .addFunction ("preset_by_uri", &Plugin::preset_by_uri)
1430                 .addFunction ("load_preset", &Plugin::load_preset)
1431                 .addFunction ("parameter_is_input", &Plugin::parameter_is_input)
1432                 .addFunction ("parameter_is_output", &Plugin::parameter_is_output)
1433                 .addFunction ("parameter_is_control", &Plugin::parameter_is_control)
1434                 .addFunction ("parameter_is_audio", &Plugin::parameter_is_audio)
1435                 .addFunction ("get_docs", &Plugin::get_docs)
1436                 .addFunction ("get_info", &Plugin::get_info)
1437                 .addFunction ("get_parameter_docs", &Plugin::get_parameter_docs)
1438                 .addFunction ("describe_io_port", &Plugin::describe_io_port)
1439                 .addRefFunction ("get_parameter_descriptor", &Plugin::get_parameter_descriptor)
1440                 .endClass ()
1441
1442                 .deriveWSPtrClass <LuaProc, Plugin> ("LuaProc")
1443                 .addFunction ("shmem", &LuaProc::instance_shm)
1444                 .addFunction ("table", &LuaProc::instance_ref)
1445                 .endClass ()
1446
1447                 .deriveWSPtrClass <PluginInsert, Processor> ("PluginInsert")
1448                 .addFunction ("plugin", &PluginInsert::plugin)
1449                 .addFunction ("activate", &PluginInsert::activate)
1450                 .addFunction ("deactivate", &PluginInsert::deactivate)
1451                 .addFunction ("strict_io_configured", &PluginInsert::strict_io_configured)
1452                 .addFunction ("input_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::input_map)
1453                 .addFunction ("output_map", (ARDOUR::ChanMapping (PluginInsert::*)(uint32_t) const)&PluginInsert::output_map)
1454                 .addFunction ("set_input_map", &PluginInsert::set_input_map)
1455                 .addFunction ("set_output_map", &PluginInsert::set_output_map)
1456                 .addFunction ("natural_output_streams", &PluginInsert::natural_output_streams)
1457                 .addFunction ("natural_input_streams", &PluginInsert::natural_input_streams)
1458                 .addFunction ("reset_parameters_to_default", &PluginInsert::reset_parameters_to_default)
1459                 .addFunction ("has_sidechain", &PluginInsert::has_sidechain)
1460                 .addFunction ("is_instrument", &PluginInsert::is_instrument)
1461                 .addFunction ("type", &PluginInsert::type)
1462                 .addFunction ("signal_latency", &PluginInsert::signal_latency)
1463                 .addFunction ("get_count", &PluginInsert::get_count)
1464                 .endClass ()
1465
1466                 .deriveWSPtrClass <ReadOnlyControl, PBD::StatefulDestructible> ("ReadOnlyControl")
1467                 .addFunction ("get_parameter", &ReadOnlyControl::get_parameter)
1468                 .addFunction ("describe_parameter", &ReadOnlyControl::describe_parameter)
1469                 .addFunction ("desc", &ReadOnlyControl::desc)
1470                 .endClass ()
1471
1472                 .deriveWSPtrClass <AutomationControl, PBD::Controllable> ("AutomationControl")
1473                 .addCast<Evoral::Control> ("to_ctrl")
1474                 .addCast<SlavableAutomationControl> ("to_slavable")
1475                 .addFunction ("automation_state", &AutomationControl::automation_state)
1476                 .addFunction ("set_automation_state", &AutomationControl::set_automation_state)
1477                 .addFunction ("start_touch", &AutomationControl::start_touch)
1478                 .addFunction ("stop_touch", &AutomationControl::stop_touch)
1479                 .addFunction ("get_value", &AutomationControl::get_value)
1480                 .addFunction ("set_value", &AutomationControl::set_value)
1481                 .addFunction ("writable", &AutomationControl::writable)
1482                 .addFunction ("alist", &AutomationControl::alist)
1483                 .endClass ()
1484
1485                 .deriveWSPtrClass <SlavableAutomationControl, AutomationControl> ("SlavableAutomationControl")
1486                 .addFunction ("add_master", &SlavableAutomationControl::add_master)
1487                 .addFunction ("remove_master", &SlavableAutomationControl::remove_master)
1488                 .addFunction ("clear_masters", &SlavableAutomationControl::clear_masters)
1489                 .addFunction ("slaved_to", &SlavableAutomationControl::slaved_to)
1490                 .addFunction ("slaved", &SlavableAutomationControl::slaved)
1491                 .addFunction ("get_masters_value", &SlavableAutomationControl::get_masters_value)
1492                 .addFunction ("get_boolean_masters", &SlavableAutomationControl::get_boolean_masters)
1493                 //.addFunction ("masters", &SlavableAutomationControl::masters) // not implemented
1494                 .endClass ()
1495
1496                 .deriveWSPtrClass <PhaseControl, AutomationControl> ("PhaseControl")
1497                 .addFunction ("set_phase_invert", (void(PhaseControl::*)(uint32_t, bool))&PhaseControl::set_phase_invert)
1498                 .addFunction ("inverted", &PhaseControl::inverted)
1499                 .endClass ()
1500
1501                 .deriveWSPtrClass <GainControl, SlavableAutomationControl> ("GainControl")
1502                 .endClass ()
1503
1504                 .deriveWSPtrClass <SoloControl, SlavableAutomationControl> ("SoloControl")
1505                 .addFunction ("can_solo", &SoloControl::can_solo)
1506                 .addFunction ("soloed", &SoloControl::soloed)
1507                 .addFunction ("self_soloed", &SoloControl::self_soloed)
1508                 .endClass ()
1509
1510                 .deriveWSPtrClass <MuteControl, SlavableAutomationControl> ("MuteControl")
1511                 .addFunction ("muted", &MuteControl::muted)
1512                 .addFunction ("muted_by_self", &MuteControl::muted_by_self)
1513                 .endClass ()
1514
1515                 .deriveWSPtrClass <SoloIsolateControl, SlavableAutomationControl> ("SoloIsolateControl")
1516                 .addFunction ("solo_isolated", &SoloIsolateControl::solo_isolated)
1517                 .addFunction ("self_solo_isolated", &SoloIsolateControl::self_solo_isolated)
1518                 .endClass ()
1519
1520                 .deriveWSPtrClass <SoloSafeControl, SlavableAutomationControl> ("SoloSafeControl")
1521                 .addFunction ("solo_safe", &SoloSafeControl::solo_safe)
1522                 .endClass ()
1523
1524                 .deriveWSPtrClass <Amp, Processor> ("Amp")
1525                 .addFunction ("gain_control", (boost::shared_ptr<GainControl>(Amp::*)())&Amp::gain_control)
1526                 .endClass ()
1527
1528                 .deriveWSPtrClass <PeakMeter, Processor> ("PeakMeter")
1529                 .addFunction ("meter_level", &PeakMeter::meter_level)
1530                 .addFunction ("set_type", &PeakMeter::set_type)
1531                 .addFunction ("reset_max", &PeakMeter::reset_max)
1532                 .endClass ()
1533
1534                 .deriveWSPtrClass <MonitorProcessor, Processor> ("MonitorProcessor")
1535                 .addFunction ("set_cut_all", &MonitorProcessor::set_cut_all)
1536                 .addFunction ("set_dim_all", &MonitorProcessor::set_dim_all)
1537                 .addFunction ("set_polarity", &MonitorProcessor::set_polarity)
1538                 .addFunction ("set_cut", &MonitorProcessor::set_cut)
1539                 .addFunction ("set_dim", &MonitorProcessor::set_dim)
1540                 .addFunction ("set_solo", &MonitorProcessor::set_solo)
1541                 .addFunction ("set_mono", &MonitorProcessor::set_mono)
1542                 .addFunction ("dim_level", &MonitorProcessor::dim_level)
1543                 .addFunction ("solo_boost_level", &MonitorProcessor::solo_boost_level)
1544                 .addFunction ("dimmed", &MonitorProcessor::dimmed)
1545                 .addFunction ("soloed", &MonitorProcessor::soloed)
1546                 .addFunction ("inverted", &MonitorProcessor::inverted)
1547                 .addFunction ("cut", &MonitorProcessor::cut)
1548                 .addFunction ("cut_all", &MonitorProcessor::cut_all)
1549                 .addFunction ("dim_all", &MonitorProcessor::dim_all)
1550                 .addFunction ("mono", &MonitorProcessor::mono)
1551                 .addFunction ("monitor_active", &MonitorProcessor::monitor_active)
1552                 .addFunction ("channel_cut_control", &MonitorProcessor::channel_cut_control)
1553                 .addFunction ("channel_dim_control", &MonitorProcessor::channel_dim_control)
1554                 .addFunction ("channel_polarity_control", &MonitorProcessor::channel_polarity_control)
1555                 .addFunction ("channel_solo_control", &MonitorProcessor::channel_solo_control)
1556                 .addFunction ("dim_control", &MonitorProcessor::dim_control)
1557                 .addFunction ("cut_control", &MonitorProcessor::cut_control)
1558                 .addFunction ("mono_control", &MonitorProcessor::mono_control)
1559                 .addFunction ("dim_level_control", &MonitorProcessor::dim_level_control)
1560                 .addFunction ("solo_boost_control", &MonitorProcessor::solo_boost_control)
1561                 .endClass ()
1562
1563                 .deriveWSPtrClass <UnknownProcessor, Processor> ("UnknownProcessor")
1564                 .endClass ()
1565
1566                 .deriveWSPtrClass <PolarityProcessor, Processor> ("PolarityProcessor")
1567                 .endClass ()
1568
1569                 .deriveWSPtrClass <DelayLine, Processor> ("DelayLine")
1570                 .addFunction ("delay", &DelayLine::delay)
1571                 .endClass ()
1572
1573                 .deriveWSPtrClass <PluginInsert::PluginControl, AutomationControl> ("PluginControl")
1574                 .endClass ()
1575
1576                 .beginClass <RawMidiParser> ("RawMidiParser")
1577                 .addVoidConstructor ()
1578                 .addFunction ("reset", &RawMidiParser::reset)
1579                 .addFunction ("process_byte", &RawMidiParser::process_byte)
1580                 .addFunction ("buffer_size", &RawMidiParser::buffer_size)
1581                 .addFunction ("midi_buffer", &RawMidiParser::midi_buffer)
1582                 .endClass ()
1583
1584                 .deriveWSPtrClass <AudioSource, Source> ("AudioSource")
1585                 .addFunction ("readable_length", &AudioSource::readable_length)
1586                 .addFunction ("n_channels", &AudioSource::n_channels)
1587                 .endClass ()
1588
1589                 // <std::list<boost::shared_ptr <AudioTrack> >
1590                 .beginStdList <boost::shared_ptr<AudioTrack> > ("AudioTrackList")
1591                 .endClass ()
1592
1593                 // std::list<boost::shared_ptr <MidiTrack> >
1594                 .beginStdList <boost::shared_ptr<MidiTrack> > ("MidiTrackList")
1595                 .endClass ()
1596
1597                 // RouteList == std::list<boost::shared_ptr<Route> >
1598                 .beginConstStdList <boost::shared_ptr<Route> > ("RouteList")
1599                 .endClass ()
1600
1601                 // StripableList == std::list<boost::shared_ptr<Stripable> >
1602                 .beginConstStdList <boost::shared_ptr<Stripable> > ("StripableList")
1603                 .endClass ()
1604
1605                 // VCAList == std::list<boost::shared_ptr<VCA> >
1606                 .beginConstStdList <boost::shared_ptr<VCA> > ("VCAList")
1607                 .endClass ()
1608
1609                 // VCAVector == std::vector<boost::shared_ptr<VCA> >
1610                 .beginConstStdVector <boost::shared_ptr<VCA> > ("VCAVector")
1611                 .endClass ()
1612
1613                 // boost::shared_ptr<RouteList>
1614                 .beginPtrStdList <boost::shared_ptr<Route> > ("RouteListPtr")
1615                 .addVoidPtrConstructor<std::list<boost::shared_ptr <Route> > > ()
1616                 .endClass ()
1617
1618                 // typedef std::list<boost::weak_ptr <Route> > WeakRouteList
1619                 .beginConstStdList <boost::weak_ptr<Route> > ("WeakRouteList")
1620                 .endClass ()
1621
1622                 // RouteGroupList == std::list<RouteGroup*>
1623                 .beginConstStdCPtrList <RouteGroup> ("RouteGroupList")
1624                 .endClass ()
1625
1626                 // typedef std::vector<boost::shared_ptr<Source> > Region::SourceList
1627                 .beginStdVector <boost::shared_ptr<Source> > ("SourceList")
1628                 .endClass ()
1629
1630                 // std::list< boost::weak_ptr <AudioSource> >
1631                 .beginConstStdList <boost::weak_ptr<AudioSource> > ("WeakAudioSourceList")
1632                 .endClass ()
1633
1634                 // typedef std::vector<boost::shared_ptr<Region> > RegionVector
1635                 .beginStdVector <boost::shared_ptr<Region> > ("RegionVector")
1636                 .endClass ()
1637
1638                 // typedef std::list<boost::shared_ptr<Region> > RegionList
1639                 .beginConstStdList <boost::shared_ptr<Region> > ("RegionList")
1640                 .endClass ()
1641
1642                 // boost::shared_ptr <std::list<boost::shared_ptr<Region> > >
1643                 .beginPtrStdList <boost::shared_ptr<Region> > ("RegionListPtr")
1644                 .addVoidPtrConstructor<std::list<boost::shared_ptr <Region> > > ()
1645                 .endClass ()
1646
1647                 // RegionFactory::RegionMap
1648                 .beginStdMap <PBD::ID,boost::shared_ptr<Region> > ("RegionMap")
1649                 .endClass ()
1650
1651                 // typedef std::list<boost::shared_ptr<Processor> > ProcessorList;
1652                 .beginStdList <boost::shared_ptr<Processor> > ("ProcessorList")
1653                 .endClass ()
1654
1655                 //std::list<boost::shared_ptr<Port> > PortList;
1656                 .beginConstStdList <boost::shared_ptr<Port> > ("PortList")
1657                 .endClass ()
1658
1659                 // used by Playlist::cut/copy
1660                 .beginConstStdList <AudioRange> ("AudioRangeList")
1661                 .endClass ()
1662
1663                 .beginConstStdList <Location*> ("LocationList")
1664                 .endClass ()
1665
1666                 // std::list<boost::shared_ptr<AutomationControl> > ControlList;
1667                 .beginStdList <boost::shared_ptr<AutomationControl> > ("ControlList")
1668                 .endClass ()
1669
1670                 .beginPtrStdList <boost::shared_ptr<AutomationControl> > ("ControlListPtr")
1671                 .addVoidPtrConstructor<std::list<boost::shared_ptr <AutomationControl> > > ()
1672                 .endClass ()
1673
1674                 .beginStdList <boost::shared_ptr<Evoral::Note<Temporal::Beats> > > ("NotePtrList")
1675                 .endClass ()
1676
1677                 .beginConstStdList <Evoral::ControlEvent*> ("EventList")
1678                 .endClass ()
1679
1680 #if 0  // depends on Evoal:: Note, Beats see note_fixer.h
1681         // typedef Evoral::Note<Temporal::Beats> Note;
1682         // std::set< boost::weak_ptr<Note> >
1683                 .beginStdSet <boost::weak_ptr<Note> > ("WeakNoteSet")
1684                 .endClass ()
1685 #endif
1686
1687         // std::list<boost::weak_ptr<Source> >
1688                 .beginConstStdList <boost::weak_ptr<Source> > ("WeakSourceList")
1689                 .endClass ()
1690
1691                 .beginClass <Tempo> ("Tempo")
1692                 .addConstructor <void (*) (double, double, double)> ()
1693                 .addFunction ("note_type", &Tempo::note_type)
1694                 .addFunction ("note_types_per_minute",  (double (Tempo::*)() const)&Tempo::note_types_per_minute)
1695                 .addFunction ("quarter_notes_per_minute", &Tempo::quarter_notes_per_minute)
1696                 .addFunction ("samples_per_quarter_note", &Tempo::samples_per_quarter_note)
1697                 .addFunction ("samples_per_note_type", &Tempo::samples_per_note_type)
1698                 .endClass ()
1699
1700                 .beginClass <Meter> ("Meter")
1701                 .addConstructor <void (*) (double, double)> ()
1702                 .addFunction ("divisions_per_bar", &Meter::divisions_per_bar)
1703                 .addFunction ("note_divisor", &Meter::note_divisor)
1704                 .addFunction ("samples_per_bar", &Meter::samples_per_bar)
1705                 .addFunction ("samples_per_grid", &Meter::samples_per_grid)
1706                 .endClass ()
1707
1708                 .beginClass <BeatsSamplesConverter> ("BeatsSamplesConverter")
1709                 .addConstructor <void (*) (const TempoMap&, samplepos_t)> ()
1710                 .addFunction ("to", &BeatsSamplesConverter::to)
1711                 .addFunction ("from", &BeatsSamplesConverter::from)
1712                 .endClass ()
1713
1714                 .beginClass <DoubleBeatsSamplesConverter> ("DoubleBeatsSamplesConverter")
1715                 .addConstructor <void (*) (const TempoMap&, samplepos_t)> ()
1716                 .addFunction ("to", &DoubleBeatsSamplesConverter::to)
1717                 .addFunction ("from", &DoubleBeatsSamplesConverter::from)
1718                 .endClass ()
1719
1720                 .beginClass <TempoMap> ("TempoMap")
1721                 .addFunction ("add_tempo", &TempoMap::add_tempo)
1722                 .addFunction ("add_meter", &TempoMap::add_meter)
1723                 .addFunction ("tempo_section_at_frame", (TempoSection& (TempoMap::*)(samplepos_t))&TempoMap::tempo_section_at_sample)
1724                 .addFunction ("tempo_section_at_frame", (const TempoSection& (TempoMap::*)(samplepos_t) const)&TempoMap::tempo_section_at_sample)
1725                 .addFunction ("meter_section_at_frame", &TempoMap::meter_section_at_sample)
1726                 .addFunction ("meter_section_at_beat", &TempoMap::meter_section_at_beat)
1727                 .addFunction ("bbt_at_frame", &TempoMap::bbt_at_sample)
1728                 .addFunction ("exact_beat_at_frame", &TempoMap::exact_beat_at_sample)
1729                 .addFunction ("exact_qn_at_frame", &TempoMap::exact_qn_at_sample)
1730                 .addFunction ("samplepos_plus_qn", &TempoMap::samplepos_plus_qn)
1731                 .addFunction ("framewalk_to_qn", &TempoMap::framewalk_to_qn)
1732                 .endClass ()
1733
1734                 .beginClass <MetricSection> ("MetricSection")
1735                 .addFunction ("pulse", &MetricSection::pulse)
1736                 .addFunction ("set_pulse", &MetricSection::set_pulse)
1737                 .endClass ()
1738
1739                 .deriveClass <TempoSection, MetricSection> ("TempoSection")
1740                 .addFunction ("c", (double(TempoSection::*)()const)&TempoSection::c)
1741                 .endClass ()
1742
1743                 .deriveClass <MeterSection, MetricSection> ("MeterSection")
1744                 .addCast<Meter> ("to_meter")
1745                 .addFunction ("set_pulse", &MeterSection::set_pulse)
1746                 .addFunction ("set_beat", (void(MeterSection::*)(double))&MeterSection::set_beat)
1747                 .endClass ()
1748
1749                 .beginClass <ChanCount> ("ChanCount")
1750                 .addConstructor <void (*) (DataType, uint32_t)> ()
1751                 .addFunction ("get", &ChanCount::get)
1752                 .addFunction ("set", &ChanCount::set)
1753                 .addFunction ("n_audio", &ChanCount::n_audio)
1754                 .addFunction ("n_midi", &ChanCount::n_midi)
1755                 .addFunction ("n_total", &ChanCount::n_total)
1756                 .addFunction ("reset", &ChanCount::reset)
1757                 .endClass()
1758
1759                 .beginClass <DataType> ("DataType")
1760                 .addConstructor <void (*) (std::string)> ()
1761                 .addStaticCFunction ("null",  &LuaAPI::datatype_ctor_null) // "nil" is a lua reseved word
1762                 .addStaticCFunction ("audio", &LuaAPI::datatype_ctor_audio)
1763                 .addStaticCFunction ("midi",  &LuaAPI::datatype_ctor_midi)
1764                 .addFunction ("to_string",  &DataType::to_string) // TODO Lua __tostring
1765                 // TODO add uint32_t cast, add operator==  !=
1766                 .endClass()
1767
1768                 /* libardour enums */
1769                 .beginNamespace ("PluginType")
1770                 .addConst ("AudioUnit", ARDOUR::PluginType(AudioUnit))
1771                 .addConst ("LADSPA", ARDOUR::PluginType(LADSPA))
1772                 .addConst ("LV2", ARDOUR::PluginType(LV2))
1773                 .addConst ("Windows_VST", ARDOUR::PluginType(Windows_VST))
1774                 .addConst ("LXVST", ARDOUR::PluginType(LXVST))
1775                 .addConst ("Lua", ARDOUR::PluginType(Lua))
1776                 .endNamespace ()
1777
1778                 .beginNamespace ("PresentationInfo")
1779                 .beginNamespace ("Flag")
1780                 .addConst ("AudioTrack", ARDOUR::PresentationInfo::Flag(PresentationInfo::AudioTrack))
1781                 .addConst ("MidiTrack", ARDOUR::PresentationInfo::Flag(PresentationInfo::MidiTrack))
1782                 .addConst ("AudioBus", ARDOUR::PresentationInfo::Flag(PresentationInfo::AudioBus))
1783                 .addConst ("MidiBus", ARDOUR::PresentationInfo::Flag(PresentationInfo::MidiBus))
1784                 .addConst ("VCA", ARDOUR::PresentationInfo::Flag(PresentationInfo::VCA))
1785                 .addConst ("MasterOut", ARDOUR::PresentationInfo::Flag(PresentationInfo::MasterOut))
1786                 .addConst ("MonitorOut", ARDOUR::PresentationInfo::Flag(PresentationInfo::MonitorOut))
1787                 .addConst ("Auditioner", ARDOUR::PresentationInfo::Flag(PresentationInfo::Auditioner))
1788                 .addConst ("Hidden", ARDOUR::PresentationInfo::Flag(PresentationInfo::Hidden))
1789                 .addConst ("GroupOrderSet", ARDOUR::PresentationInfo::Flag(PresentationInfo::OrderSet))
1790                 .addConst ("StatusMask", ARDOUR::PresentationInfo::Flag(PresentationInfo::StatusMask))
1791                 .endNamespace ()
1792                 .endNamespace ()
1793
1794                 .beginNamespace ("AutoState")
1795                 .addConst ("Off", ARDOUR::AutoState(Off))
1796                 .addConst ("Write", ARDOUR::AutoState(Write))
1797                 .addConst ("Touch", ARDOUR::AutoState(Touch))
1798                 .addConst ("Play", ARDOUR::AutoState(Play))
1799                 .addConst ("Latch", ARDOUR::AutoState(Latch))
1800                 .endNamespace ()
1801
1802                 .beginNamespace ("AutomationType")
1803                 .addConst ("GainAutomation", ARDOUR::AutomationType(GainAutomation))
1804                 .addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation))
1805                 .addConst ("SoloAutomation", ARDOUR::AutomationType(SoloAutomation))
1806                 .addConst ("SoloIsolateAutomation", ARDOUR::AutomationType(SoloIsolateAutomation))
1807                 .addConst ("SoloSafeAutomation", ARDOUR::AutomationType(SoloSafeAutomation))
1808                 .addConst ("MuteAutomation", ARDOUR::AutomationType(MuteAutomation))
1809                 .addConst ("RecEnableAutomation", ARDOUR::AutomationType(RecEnableAutomation))
1810                 .addConst ("RecSafeAutomation", ARDOUR::AutomationType(RecSafeAutomation))
1811                 .addConst ("TrimAutomation", ARDOUR::AutomationType(TrimAutomation))
1812                 .addConst ("PhaseAutomation", ARDOUR::AutomationType(PhaseAutomation))
1813                 .addConst ("MidiCCAutomation", ARDOUR::AutomationType(MidiCCAutomation))
1814                 .addConst ("MidiPgmChangeAutomation", ARDOUR::AutomationType(MidiPgmChangeAutomation))
1815                 .addConst ("MidiPitchBenderAutomation", ARDOUR::AutomationType(MidiPitchBenderAutomation))
1816                 .addConst ("MidiChannelPressureAutomation", ARDOUR::AutomationType(MidiChannelPressureAutomation))
1817                 .addConst ("MidiNotePressureAutomation", ARDOUR::AutomationType(MidiNotePressureAutomation))
1818                 .addConst ("MidiSystemExclusiveAutomation", ARDOUR::AutomationType(MidiSystemExclusiveAutomation))
1819                 .endNamespace ()
1820
1821                 .beginNamespace ("SrcQuality")
1822                 .addConst ("SrcBest", ARDOUR::SrcQuality(SrcBest))
1823                 .endNamespace ()
1824
1825                 .beginNamespace ("MeterType")
1826                 .addConst ("MeterMaxSignal", ARDOUR::MeterType(MeterMaxSignal))
1827                 .addConst ("MeterMaxPeak", ARDOUR::MeterType(MeterMaxPeak))
1828                 .addConst ("MeterPeak", ARDOUR::MeterType(MeterPeak))
1829                 .addConst ("MeterKrms", ARDOUR::MeterType(MeterKrms))
1830                 .addConst ("MeterK20", ARDOUR::MeterType(MeterK20))
1831                 .addConst ("MeterK14", ARDOUR::MeterType(MeterK14))
1832                 .addConst ("MeterIEC1DIN", ARDOUR::MeterType(MeterIEC1DIN))
1833                 .addConst ("MeterIEC1NOR", ARDOUR::MeterType(MeterIEC1NOR))
1834                 .addConst ("MeterIEC2BBC", ARDOUR::MeterType(MeterIEC2BBC))
1835                 .addConst ("MeterIEC2EBU", ARDOUR::MeterType(MeterIEC2EBU))
1836                 .addConst ("MeterVU", ARDOUR::MeterType(MeterVU))
1837                 .addConst ("MeterK12", ARDOUR::MeterType(MeterK12))
1838                 .addConst ("MeterPeak0dB", ARDOUR::MeterType(MeterPeak0dB))
1839                 .addConst ("MeterMCP", ARDOUR::MeterType(MeterMCP))
1840                 .endNamespace ()
1841
1842                 .beginNamespace ("MeterPoint")
1843                 .addConst ("MeterInput", ARDOUR::MeterPoint(MeterInput))
1844                 .addConst ("MeterPreFader", ARDOUR::MeterPoint(MeterPreFader))
1845                 .addConst ("MeterPostFader", ARDOUR::MeterPoint(MeterPostFader))
1846                 .addConst ("MeterOutput", ARDOUR::MeterPoint(MeterOutput))
1847                 .addConst ("MeterCustom", ARDOUR::MeterPoint(MeterCustom))
1848                 .endNamespace ()
1849
1850                 .beginNamespace ("Placement")
1851                 .addConst ("PreFader", ARDOUR::Placement(PreFader))
1852                 .addConst ("PostFader", ARDOUR::Placement(PostFader))
1853                 .endNamespace ()
1854
1855                 .beginNamespace ("MonitorChoice")
1856                 .addConst ("MonitorAuto", ARDOUR::MonitorChoice(MonitorAuto))
1857                 .addConst ("MonitorInput", ARDOUR::MonitorChoice(MonitorInput))
1858                 .addConst ("MonitorDisk", ARDOUR::MonitorChoice(MonitorDisk))
1859                 .addConst ("MonitorCue", ARDOUR::MonitorChoice(MonitorCue))
1860                 .endNamespace ()
1861
1862                 .beginNamespace ("NoteMode")
1863                 .addConst ("Sustained", ARDOUR::NoteMode(Sustained))
1864                 .addConst ("Percussive", ARDOUR::NoteMode(Percussive))
1865                 .endNamespace ()
1866
1867                 .beginNamespace ("PortFlags")
1868                 .addConst ("IsInput", ARDOUR::PortFlags(IsInput))
1869                 .addConst ("IsOutput", ARDOUR::PortFlags(IsOutput))
1870                 .addConst ("IsPhysical", ARDOUR::PortFlags(IsPhysical))
1871                 .addConst ("CanMonitor", ARDOUR::PortFlags(CanMonitor))
1872                 .addConst ("IsTerminal", ARDOUR::PortFlags(IsTerminal))
1873                 .endNamespace ()
1874
1875                 .beginNamespace ("MidiPortFlags")
1876                 .addConst ("MidiPortMusic", ARDOUR::MidiPortFlags(MidiPortMusic))
1877                 .addConst ("MidiPortControl", ARDOUR::MidiPortFlags(MidiPortControl))
1878                 .addConst ("MidiPortSelection", ARDOUR::MidiPortFlags(MidiPortSelection))
1879                 .addConst ("MidiPortVirtual", ARDOUR::MidiPortFlags(MidiPortVirtual))
1880                 .endNamespace ()
1881
1882                 .beginNamespace ("PlaylistDisposition")
1883                 .addConst ("CopyPlaylist", ARDOUR::PlaylistDisposition(CopyPlaylist))
1884                 .addConst ("NewPlaylist", ARDOUR::PlaylistDisposition(NewPlaylist))
1885                 .addConst ("SharePlaylist", ARDOUR::PlaylistDisposition(SharePlaylist))
1886                 .endNamespace ()
1887
1888                 .beginNamespace ("MidiTrackNameSource")
1889                 .addConst ("SMFTrackNumber", ARDOUR::MidiTrackNameSource(SMFTrackNumber))
1890                 .addConst ("SMFTrackName", ARDOUR::MidiTrackNameSource(SMFTrackName))
1891                 .addConst ("SMFInstrumentName", ARDOUR::MidiTrackNameSource(SMFInstrumentName))
1892                 .endNamespace ()
1893
1894                 .beginNamespace ("MidiTempoMapDisposition")
1895                 .addConst ("SMFTempoIgnore", ARDOUR::MidiTempoMapDisposition(SMFTempoIgnore))
1896                 .addConst ("SMFTempoUse", ARDOUR::MidiTempoMapDisposition(SMFTempoUse))
1897                 .endNamespace ()
1898
1899                 .beginNamespace ("RegionPoint")
1900                 .addConst ("Start", ARDOUR::RegionPoint(Start))
1901                 .addConst ("End", ARDOUR::RegionPoint(End))
1902                 .addConst ("SyncPoint", ARDOUR::RegionPoint(SyncPoint))
1903                 .endNamespace ()
1904
1905                 .beginNamespace ("TempoSection")
1906                 .beginNamespace ("PositionLockStyle")
1907                 .addConst ("AudioTime", ARDOUR::PositionLockStyle(AudioTime))
1908                 .addConst ("MusicTime", ARDOUR::PositionLockStyle(MusicTime))
1909                 .endNamespace ()
1910                 .endNamespace ()
1911
1912                 .beginNamespace ("TempoSection")
1913                 .beginNamespace ("Type")
1914                 .addConst ("Ramp", ARDOUR::TempoSection::Type(TempoSection::Ramp))
1915                 .addConst ("Constant", ARDOUR::TempoSection::Type(TempoSection::Constant))
1916                 .endNamespace ()
1917                 .endNamespace ()
1918
1919                 .beginNamespace ("TrackMode")
1920                 .addConst ("Normal", ARDOUR::TrackMode(Start))
1921                 .addConst ("NonLayered", ARDOUR::TrackMode(NonLayered))
1922                 .addConst ("Destructive", ARDOUR::TrackMode(Destructive))
1923                 .endNamespace ()
1924
1925                 .beginNamespace ("SampleFormat")
1926                 .addConst ("Float", ARDOUR::SampleFormat(FormatFloat))
1927                 .addConst ("Int24", ARDOUR::SampleFormat(FormatInt24))
1928                 .addConst ("Int16", ARDOUR::SampleFormat(FormatInt16))
1929                 .endNamespace ()
1930
1931                 .beginNamespace ("HeaderFormat")
1932                 .addConst ("BWF", ARDOUR::HeaderFormat(BWF))
1933                 .addConst ("WAVE", ARDOUR::HeaderFormat(WAVE))
1934                 .addConst ("WAVE64", ARDOUR::HeaderFormat(WAVE64))
1935                 .addConst ("CAF", ARDOUR::HeaderFormat(CAF))
1936                 .addConst ("AIFF", ARDOUR::HeaderFormat(AIFF))
1937                 .addConst ("iXML", ARDOUR::HeaderFormat(iXML))
1938                 .addConst ("RF64", ARDOUR::HeaderFormat(RF64))
1939                 .addConst ("RF64_WAV", ARDOUR::HeaderFormat(RF64_WAV))
1940                 .addConst ("MBWF", ARDOUR::HeaderFormat(MBWF))
1941                 .endNamespace ()
1942
1943                 .beginNamespace ("InsertMergePolicy")
1944                 .addConst ("Reject", ARDOUR::InsertMergePolicy(InsertMergeReject))
1945                 .addConst ("Relax", ARDOUR::InsertMergePolicy(InsertMergeRelax))
1946                 .addConst ("Replace", ARDOUR::InsertMergePolicy(InsertMergeReplace))
1947                 .addConst ("TruncateExisting", ARDOUR::InsertMergePolicy(InsertMergeTruncateExisting))
1948                 .addConst ("TruncateAddition", ARDOUR::InsertMergePolicy(InsertMergeTruncateAddition))
1949                 .addConst ("Extend", ARDOUR::InsertMergePolicy(InsertMergeExtend))
1950                 .endNamespace ()
1951
1952                 .beginNamespace ("AFLPosition")
1953                 .addConst ("AFLFromBeforeProcessors", ARDOUR::AFLPosition(AFLFromBeforeProcessors))
1954                 .addConst ("AFLFromAfterProcessors", ARDOUR::AFLPosition(AFLFromAfterProcessors))
1955                 .endNamespace ()
1956
1957                 .beginNamespace ("PFLPosition")
1958                 .addConst ("PFLFromBeforeProcessors", ARDOUR::PFLPosition(PFLFromBeforeProcessors))
1959                 .addConst ("PFLFromAfterProcessors", ARDOUR::PFLPosition(PFLFromAfterProcessors))
1960                 .endNamespace ()
1961
1962                 .beginNamespace ("AutoReturnTarget")
1963                 .addConst ("LastLocate", ARDOUR::AutoReturnTarget(LastLocate))
1964                 .addConst ("RangeSelectionStart", ARDOUR::AutoReturnTarget(RangeSelectionStart))
1965                 .addConst ("Loop", ARDOUR::AutoReturnTarget(Loop))
1966                 .addConst ("RegionSelectionStart", ARDOUR::AutoReturnTarget(RegionSelectionStart))
1967                 .endNamespace ()
1968
1969                 .beginNamespace ("FadeShape")
1970                 .addConst ("FadeLinear", ARDOUR::FadeShape(FadeLinear))
1971                 .addConst ("FadeFast", ARDOUR::FadeShape(FadeFast))
1972                 .addConst ("FadeSlow", ARDOUR::FadeShape(FadeSlow))
1973                 .addConst ("FadeConstantPower", ARDOUR::FadeShape(FadeConstantPower))
1974                 .addConst ("FadeSymmetric", ARDOUR::FadeShape(FadeSymmetric))
1975                 .endNamespace ()
1976
1977                 .beginNamespace ("DenormalModel")
1978                 .addConst ("DenormalNone", ARDOUR::DenormalModel(DenormalNone))
1979                 .addConst ("DenormalFTZ", ARDOUR::DenormalModel(DenormalFTZ))
1980                 .addConst ("DenormalDAZ", ARDOUR::DenormalModel(DenormalDAZ))
1981                 .addConst ("DenormalFTZDAZ", ARDOUR::DenormalModel(DenormalFTZDAZ))
1982                 .endNamespace ()
1983
1984                 .beginNamespace ("BufferingPreset")
1985                 .addConst ("Small", ARDOUR::BufferingPreset(Small))
1986                 .addConst ("Medium", ARDOUR::BufferingPreset(Medium))
1987                 .addConst ("Large", ARDOUR::BufferingPreset(Large))
1988                 .addConst ("Custom", ARDOUR::BufferingPreset(Custom))
1989                 .endNamespace ()
1990
1991                 .beginNamespace ("EditMode")
1992                 .addConst ("Slide", ARDOUR::EditMode(Slide))
1993                 .addConst ("Splice", ARDOUR::EditMode(Splice))
1994                 .addConst ("Ripple", ARDOUR::EditMode(Ripple))
1995                 .addConst ("Lock", ARDOUR::EditMode(Lock))
1996                 .endNamespace ()
1997
1998                 .beginNamespace ("AutoConnectOption")
1999                 .addConst ("ManualConnect", ARDOUR::AutoConnectOption(ManualConnect))
2000                 .addConst ("AutoConnectPhysical", ARDOUR::AutoConnectOption(AutoConnectPhysical))
2001                 .addConst ("AutoConnectMaster", ARDOUR::AutoConnectOption(AutoConnectMaster))
2002                 .endNamespace ()
2003
2004                 .beginNamespace ("LayerModel")
2005                 .addConst ("LaterHigher", ARDOUR::LayerModel(LaterHigher))
2006                 .addConst ("Manual", ARDOUR::LayerModel(Manual))
2007                 .endNamespace ()
2008
2009                 .beginNamespace ("ListenPosition")
2010                 .addConst ("AfterFaderListen", ARDOUR::ListenPosition(AfterFaderListen))
2011                 .addConst ("PreFaderListen", ARDOUR::ListenPosition(PreFaderListen))
2012                 .endNamespace ()
2013
2014                 .beginNamespace ("MonitorModel")
2015                 .addConst ("HardwareMonitoring", ARDOUR::MonitorModel(HardwareMonitoring))
2016                 .addConst ("SoftwareMonitoring", ARDOUR::MonitorModel(SoftwareMonitoring))
2017                 .addConst ("ExternalMonitoring", ARDOUR::MonitorModel(ExternalMonitoring))
2018                 .endNamespace ()
2019
2020                 .beginNamespace ("RegionSelectionAfterSplit")
2021                 .addConst ("None", ARDOUR::RegionSelectionAfterSplit(None))
2022                 .addConst ("NewlyCreatedLeft", ARDOUR::RegionSelectionAfterSplit(NewlyCreatedLeft))
2023                 .addConst ("NewlyCreatedRight", ARDOUR::RegionSelectionAfterSplit(NewlyCreatedRight))
2024                 .addConst ("NewlyCreatedBoth", ARDOUR::RegionSelectionAfterSplit(NewlyCreatedBoth))
2025                 .addConst ("Existing", ARDOUR::RegionSelectionAfterSplit(Existing))
2026                 .addConst ("ExistingNewlyCreatedLeft", ARDOUR::RegionSelectionAfterSplit(ExistingNewlyCreatedLeft))
2027                 .addConst ("ExistingNewlyCreatedRight", ARDOUR::RegionSelectionAfterSplit(ExistingNewlyCreatedRight))
2028                 .addConst ("ExistingNewlyCreatedBoth", ARDOUR::RegionSelectionAfterSplit(ExistingNewlyCreatedBoth))
2029                 .endNamespace ()
2030
2031                 .beginNamespace ("ShuttleBehaviour")
2032                 .addConst ("Sprung", ARDOUR::ShuttleBehaviour(Sprung))
2033                 .addConst ("Wheel", ARDOUR::ShuttleBehaviour(Wheel))
2034                 .endNamespace ()
2035
2036                 .beginNamespace ("ShuttleUnits")
2037                 .addConst ("Percentage", ARDOUR::ShuttleUnits(Percentage))
2038                 .addConst ("Semitones", ARDOUR::ShuttleUnits(Semitones))
2039                 .endNamespace ()
2040
2041                 .beginNamespace ("SyncSource")
2042                 .addConst ("Engine", ARDOUR::SyncSource(Engine))
2043                 .addConst ("MTC", ARDOUR::SyncSource(MTC))
2044                 .addConst ("MIDIClock", ARDOUR::SyncSource(MIDIClock))
2045                 .addConst ("LTC", ARDOUR::SyncSource(LTC))
2046                 .endNamespace ()
2047
2048                 .beginNamespace ("TracksAutoNamingRule")
2049                 .addConst ("UseDefaultNames", ARDOUR::TracksAutoNamingRule(UseDefaultNames))
2050                 .addConst ("NameAfterDriver", ARDOUR::TracksAutoNamingRule(NameAfterDriver))
2051                 .endNamespace ()
2052
2053                 .endNamespace (); // end ARDOUR
2054
2055         luabridge::getGlobalNamespace (L)
2056                 .beginNamespace ("ARDOUR")
2057                 .beginClass <AudioBackendInfo> ("AudioBackendInfo")
2058                 .addData ("name", &AudioBackendInfo::name)
2059                 .endClass()
2060                 .beginConstStdVector <const AudioBackendInfo*> ("BackendVector").endClass ()
2061
2062                 .beginClass <AudioBackend::DeviceStatus> ("DeviceStatus")
2063                 .addData ("name", &AudioBackend::DeviceStatus::name)
2064                 .addData ("available", &AudioBackend::DeviceStatus::available)
2065                 .endClass()
2066                 .beginStdVector <AudioBackend::DeviceStatus> ("DeviceStatusVector").endClass ()
2067
2068                 .beginWSPtrClass <AudioBackend> ("AudioBackend")
2069                 .addFunction ("info", &AudioBackend::info)
2070                 .addFunction ("sample_rate", &AudioBackend::sample_rate)
2071                 .addFunction ("buffer_size", &AudioBackend::buffer_size)
2072                 .addFunction ("period_size", &AudioBackend::period_size)
2073                 .addFunction ("input_channels", &AudioBackend::input_channels)
2074                 .addFunction ("output_channels", &AudioBackend::output_channels)
2075                 .addFunction ("dsp_load", &AudioBackend::dsp_load)
2076
2077                 .addFunction ("set_sample_rate", &AudioBackend::set_sample_rate)
2078                 .addFunction ("set_buffer_size", &AudioBackend::set_buffer_size)
2079                 .addFunction ("set_peridod_size", &AudioBackend::set_peridod_size)
2080
2081                 .addFunction ("enumerate_drivers", &AudioBackend::enumerate_drivers)
2082                 .addFunction ("driver_name", &AudioBackend::driver_name)
2083                 .addFunction ("set_driver", &AudioBackend::set_driver)
2084
2085                 .addFunction ("use_separate_input_and_output_devices", &AudioBackend::use_separate_input_and_output_devices)
2086                 .addFunction ("enumerate_devices", &AudioBackend::enumerate_devices)
2087                 .addFunction ("enumerate_input_devices", &AudioBackend::enumerate_input_devices)
2088                 .addFunction ("enumerate_output_devices", &AudioBackend::enumerate_output_devices)
2089                 .addFunction ("device_name", &AudioBackend::device_name)
2090                 .addFunction ("input_device_name", &AudioBackend::input_device_name)
2091                 .addFunction ("output_device_name", &AudioBackend::output_device_name)
2092                 .addFunction ("set_device_name", &AudioBackend::set_device_name)
2093                 .addFunction ("set_input_device_name", &AudioBackend::set_input_device_name)
2094                 .addFunction ("set_output_device_name", &AudioBackend::set_output_device_name)
2095                 .endClass()
2096
2097                 .beginClass <LatencyRange> ("LatencyRange")
2098                 .addVoidConstructor ()
2099                 .addData ("min", &LatencyRange::min)
2100                 .addData ("max", &LatencyRange::max)
2101                 .endClass()
2102
2103                 .beginClass <PortManager> ("PortManager")
2104                 .addFunction ("port_engine", &PortManager::port_engine)
2105                 .addFunction ("connected", &PortManager::connected)
2106                 .addFunction ("connect", &PortManager::connect)
2107                 .addFunction ("physically_connected", &PortManager::physically_connected)
2108                 .addFunction ("disconnect", (int (PortManager::*)(const std::string&, const std::string&))&PortManager::disconnect)
2109                 .addFunction ("disconnect_port", (int (PortManager::*)(boost::shared_ptr<Port>))&PortManager::disconnect)
2110                 .addFunction ("get_port_by_name", &PortManager::get_port_by_name)
2111                 .addFunction ("get_pretty_name_by_name", &PortManager::get_pretty_name_by_name)
2112                 .addFunction ("port_is_physical", &PortManager::port_is_physical)
2113                 .addFunction ("get_physical_outputs", &PortManager::get_physical_outputs)
2114                 .addFunction ("get_physical_inputs", &PortManager::get_physical_inputs)
2115                 .addFunction ("n_physical_outputs", &PortManager::n_physical_outputs)
2116                 .addFunction ("n_physical_inputs", &PortManager::n_physical_inputs)
2117                 .addRefFunction ("get_connections", &PortManager::get_connections)
2118                 .addRefFunction ("get_ports", (int (PortManager::*)(DataType, PortManager::PortList&))&PortManager::get_ports)
2119                 .addRefFunction ("get_backend_ports", (int (PortManager::*)(const std::string&, DataType, PortFlags, std::vector<std::string>&))&PortManager::get_ports)
2120                 .endClass()
2121
2122                 .deriveClass <AudioEngine, PortManager> ("AudioEngine")
2123                 .addFunction ("available_backends", &AudioEngine::available_backends)
2124                 .addFunction ("current_backend_name", &AudioEngine::current_backend_name)
2125                 .addFunction ("set_backend", &AudioEngine::set_backend)
2126                 .addFunction ("setup_required", &AudioEngine::setup_required)
2127                 .addFunction ("start", &AudioEngine::start)
2128                 .addFunction ("stop", &AudioEngine::stop)
2129                 .addFunction ("get_dsp_load", &AudioEngine::get_dsp_load)
2130                 .addFunction ("set_device_name", &AudioEngine::set_device_name)
2131                 .addFunction ("set_sample_rate", &AudioEngine::set_sample_rate)
2132                 .addFunction ("set_buffer_size", &AudioEngine::set_buffer_size)
2133                 .addFunction ("get_last_backend_error", &AudioEngine::get_last_backend_error)
2134                 .endClass()
2135
2136                 .deriveClass <VCAManager, PBD::StatefulDestructible> ("VCAManager")
2137                 .addFunction ("create_vca", &VCAManager::create_vca)
2138                 .addFunction ("remove_vca", &VCAManager::remove_vca)
2139                 .addFunction ("vca_by_number", &VCAManager::vca_by_number)
2140                 .addFunction ("vca_by_name", &VCAManager::vca_by_name)
2141                 .addFunction ("vcas", &VCAManager::vcas)
2142                 .addFunction ("n_vcas", &VCAManager::n_vcas)
2143                 .endClass()
2144
2145                 .deriveClass <RCConfiguration, PBD::Configuration> ("RCConfiguration")
2146 #undef  CONFIG_VARIABLE
2147 #undef  CONFIG_VARIABLE_SPECIAL
2148 #define CONFIG_VARIABLE(Type,var,name,value) \
2149                 .addFunction ("get_" # var, &RCConfiguration::get_##var) \
2150                 .addFunction ("set_" # var, &RCConfiguration::set_##var) \
2151                 .addProperty (#var, &RCConfiguration::get_##var, &RCConfiguration::set_##var)
2152
2153 #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) \
2154                 .addFunction ("get_" # var, &RCConfiguration::get_##var) \
2155                 .addFunction ("set_" # var, &RCConfiguration::set_##var) \
2156                 .addProperty (#var, &RCConfiguration::get_##var, &RCConfiguration::set_##var)
2157
2158 #include "ardour/rc_configuration_vars.h"
2159
2160 #undef CONFIG_VARIABLE
2161 #undef CONFIG_VARIABLE_SPECIAL
2162                 .endClass()
2163
2164                 .deriveClass <SessionConfiguration, PBD::Configuration> ("SessionConfiguration")
2165 #undef  CONFIG_VARIABLE
2166 #undef  CONFIG_VARIABLE_SPECIAL
2167 #define CONFIG_VARIABLE(Type,var,name,value) \
2168                 .addFunction ("get_" # var, &SessionConfiguration::get_##var) \
2169                 .addFunction ("set_" # var, &SessionConfiguration::set_##var) \
2170                 .addProperty (#var, &SessionConfiguration::get_##var, &SessionConfiguration::set_##var)
2171
2172 #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) \
2173                 .addFunction ("get_" # var, &SessionConfiguration::get_##var) \
2174                 .addFunction ("set_" # var, &SessionConfiguration::set_##var) \
2175                 .addProperty (#var, &SessionConfiguration::get_##var, &SessionConfiguration::set_##var)
2176
2177 #include "ardour/session_configuration_vars.h"
2178
2179 #undef CONFIG_VARIABLE
2180 #undef CONFIG_VARIABLE_SPECIAL
2181                 .endClass()
2182
2183                 // we could use addProperty ()
2184                 .addFunction ("config", &_libardour_config)
2185
2186                 .endNamespace ();
2187
2188         // basic representation of Session
2189         // functions which can be used from realtime and non-realtime contexts
2190         luabridge::getGlobalNamespace (L)
2191                 .beginNamespace ("ARDOUR")
2192                 .beginClass <Session> ("Session")
2193                 .addFunction ("scripts_changed", &Session::scripts_changed) // used internally
2194                 .addFunction ("transport_rolling", &Session::transport_rolling)
2195                 .addFunction ("request_transport_speed", &Session::request_transport_speed)
2196                 .addFunction ("transport_sample", &Session::transport_sample)
2197                 .addFunction ("transport_speed", &Session::transport_speed)
2198                 .addFunction ("sample_rate", &Session::sample_rate)
2199                 .addFunction ("nominal_sample_rate", &Session::nominal_sample_rate)
2200                 .addFunction ("samples_per_timecode_frame", &Session::samples_per_timecode_frame)
2201                 .addFunction ("timecode_frames_per_hour", &Session::timecode_frames_per_hour)
2202                 .addFunction ("timecode_frames_per_second", &Session::timecode_frames_per_second)
2203                 .addFunction ("timecode_drop_frames", &Session::timecode_drop_frames)
2204                 .addFunction ("request_locate", &Session::request_locate)
2205                 .addFunction ("request_stop", &Session::request_stop)
2206                 .addFunction ("request_play_loop", &Session::request_play_loop)
2207                 .addFunction ("get_play_loop", &Session::get_play_loop)
2208                 .addFunction ("last_transport_start", &Session::last_transport_start)
2209                 .addFunction ("goto_start", &Session::goto_start)
2210                 .addFunction ("goto_end", &Session::goto_end)
2211                 .addFunction ("current_start_frame", &Session::current_start_sample)
2212                 .addFunction ("current_end_frame", &Session::current_end_sample)
2213                 .addFunction ("actively_recording", &Session::actively_recording)
2214                 .addFunction ("new_audio_track", &Session::new_audio_track)
2215                 .addFunction ("new_audio_route", &Session::new_audio_route)
2216                 .addFunction ("new_midi_track", &Session::new_midi_track)
2217                 .addFunction ("new_midi_route", &Session::new_midi_route)
2218
2219                 .addFunction ("add_master_bus", &Session::add_master_bus)
2220                 .addFunction ("add_monitor_section", &Session::add_monitor_section)
2221                 .addFunction ("remove_monitor_section", &Session::remove_monitor_section)
2222
2223                 .addFunction ("get_routes", &Session::get_routes)
2224                 .addFunction ("get_tracks", &Session::get_tracks)
2225                 .addFunction ("get_stripables", (StripableList (Session::*)() const)&Session::get_stripables)
2226                 .addFunction ("name", &Session::name)
2227                 .addFunction ("path", &Session::path)
2228                 .addFunction ("record_status", &Session::record_status)
2229                 .addFunction ("maybe_enable_record", &Session::maybe_enable_record)
2230                 .addFunction ("disable_record", &Session::disable_record)
2231                 .addFunction ("route_by_id", &Session::route_by_id)
2232                 .addFunction ("route_by_name", &Session::route_by_name)
2233                 .addFunction ("stripable_by_id", &Session::stripable_by_id)
2234                 .addFunction ("get_remote_nth_stripable", &Session::get_remote_nth_stripable)
2235                 .addFunction ("get_remote_nth_route", &Session::get_remote_nth_route)
2236                 .addFunction ("route_by_selected_count", &Session::route_by_selected_count)
2237                 .addFunction ("source_by_id", &Session::source_by_id)
2238                 .addFunction ("controllable_by_id", &Session::controllable_by_id)
2239                 .addFunction ("processor_by_id", &Session::processor_by_id)
2240                 .addFunction ("snap_name", &Session::snap_name)
2241                 .addFunction ("monitor_out", &Session::monitor_out)
2242                 .addFunction ("master_out", &Session::master_out)
2243                 .addFunction ("add_internal_sends", &Session::add_internal_sends)
2244                 .addFunction ("tempo_map", (TempoMap& (Session::*)())&Session::tempo_map)
2245                 .addFunction ("locations", &Session::locations)
2246                 .addFunction ("soloing", &Session::soloing)
2247                 .addFunction ("listening", &Session::listening)
2248                 .addFunction ("solo_isolated", &Session::solo_isolated)
2249                 .addFunction ("cancel_all_solo", &Session::cancel_all_solo)
2250                 .addFunction ("clear_all_solo_state", &Session::clear_all_solo_state)
2251                 .addFunction ("set_controls", &Session::set_controls)
2252                 .addFunction ("set_control", &Session::set_control)
2253                 .addFunction ("set_exclusive_input_active", &Session::set_exclusive_input_active)
2254                 .addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command)
2255                 .addFunction ("commit_reversible_command", &Session::commit_reversible_command)
2256                 .addFunction ("abort_reversible_command", &Session::abort_reversible_command)
2257                 .addFunction ("add_command", &Session::add_command)
2258                 .addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command)
2259                 .addFunction ("engine", (AudioEngine& (Session::*)())&Session::engine)
2260                 .addFunction ("get_block_size", &Session::get_block_size)
2261                 .addFunction ("worst_output_latency", &Session::worst_output_latency)
2262                 .addFunction ("worst_input_latency", &Session::worst_input_latency)
2263                 .addFunction ("worst_route_latency", &Session::worst_route_latency)
2264                 .addFunction ("worst_latency_preroll", &Session::worst_latency_preroll)
2265                 .addFunction ("cfg", &Session::cfg)
2266                 .addFunction ("route_groups", &Session::route_groups)
2267                 .addFunction ("new_route_group", &Session::new_route_group)
2268                 .addFunction ("end_is_free", &Session::end_is_free)
2269                 .addFunction ("set_end_is_free", &Session::set_end_is_free)
2270                 .addFunction ("remove_route_group", (void (Session::*)(RouteGroup*))&Session::remove_route_group)
2271                 .addFunction ("vca_manager", &Session::vca_manager_ptr)
2272                 .addExtCFunction ("timecode_to_sample_lua", ARDOUR::LuaAPI::timecode_to_sample_lua)
2273                 .addExtCFunction ("sample_to_timecode_lua", ARDOUR::LuaAPI::sample_to_timecode_lua)
2274                 .endClass ()
2275
2276                 .beginClass <RegionFactory> ("RegionFactory")
2277                 .addStaticFunction ("region_by_id", &RegionFactory::region_by_id)
2278                 .addStaticFunction ("regions", &RegionFactory::regions)
2279                 .addStaticFunction ("clone_region", static_cast<boost::shared_ptr<Region> (*)(boost::shared_ptr<Region>, bool, bool)>(&RegionFactory::create))
2280                 .endClass ()
2281
2282                 /* session enums (rt-safe, common) */
2283                 .beginNamespace ("Session")
2284
2285                 .beginNamespace ("RecordState")
2286                 .addConst ("Disabled", ARDOUR::Session::RecordState(Session::Disabled))
2287                 .addConst ("Enabled", ARDOUR::Session::RecordState(Session::Enabled))
2288                 .addConst ("Recording", ARDOUR::Session::RecordState(Session::Recording))
2289                 .endNamespace ()
2290
2291                 .endNamespace () // end Session enums
2292
2293                 /* ardour enums (rt-safe, common) */
2294                 .beginNamespace ("LocationFlags")
2295                 .addConst ("IsMark", ARDOUR::Location::Flags(Location::IsMark))
2296                 .addConst ("IsAutoPunch", ARDOUR::Location::Flags(Location::IsAutoPunch))
2297                 .addConst ("IsAutoLoop", ARDOUR::Location::Flags(Location::IsAutoLoop))
2298                 .addConst ("IsHidden", ARDOUR::Location::Flags(Location::IsHidden))
2299                 .addConst ("IsCDMarker", ARDOUR::Location::Flags(Location::IsCDMarker))
2300                 .addConst ("IsRangeMarker", ARDOUR::Location::Flags(Location::IsRangeMarker))
2301                 .addConst ("IsSessionRange", ARDOUR::Location::Flags(Location::IsSessionRange))
2302                 .addConst ("IsSkip", ARDOUR::Location::Flags(Location::IsSkip))
2303                 .addConst ("IsSkipping", ARDOUR::Location::Flags(Location::IsSkipping))
2304                 .endNamespace ()
2305
2306                 .beginNamespace ("LuaAPI")
2307                 .addFunction ("nil_proc", ARDOUR::LuaAPI::nil_processor)
2308                 .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
2309                 .addFunction ("list_plugins", ARDOUR::LuaAPI::list_plugins)
2310                 .addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
2311                 .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
2312                 .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
2313                 .addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
2314                 .addFunction ("reset_processor_to_default", ARDOUR::LuaAPI::reset_processor_to_default)
2315                 .addRefFunction ("get_processor_param", ARDOUR::LuaAPI::get_processor_param)
2316                 .addRefFunction ("get_plugin_insert_param", ARDOUR::LuaAPI::get_plugin_insert_param)
2317                 .addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
2318                 .addCFunction ("hsla_to_rgba", ARDOUR::LuaAPI::hsla_to_rgba)
2319                 .addCFunction ("color_to_rgba", ARDOUR::LuaAPI::color_to_rgba)
2320                 .addFunction ("usleep", Glib::usleep)
2321                 .addFunction ("monotonic_time", ::g_get_monotonic_time)
2322                 .addCFunction ("build_filename", ARDOUR::LuaAPI::build_filename)
2323                 .addFunction ("new_noteptr", ARDOUR::LuaAPI::new_noteptr)
2324                 .addFunction ("note_list", ARDOUR::LuaAPI::note_list)
2325                 .addCFunction ("sample_to_timecode", ARDOUR::LuaAPI::sample_to_timecode)
2326                 .addCFunction ("timecode_to_sample", ARDOUR::LuaAPI::timecode_to_sample)
2327
2328                 .beginClass <ARDOUR::LuaAPI::Vamp> ("Vamp")
2329                 .addConstructor <void (*) (const std::string&, float)> ()
2330                 .addStaticFunction ("list_plugins", &ARDOUR::LuaAPI::Vamp::list_plugins)
2331                 .addFunction ("plugin", &ARDOUR::LuaAPI::Vamp::plugin)
2332                 .addFunction ("analyze", &ARDOUR::LuaAPI::Vamp::analyze)
2333                 .addFunction ("reset", &ARDOUR::LuaAPI::Vamp::reset)
2334                 .addFunction ("initialize", &ARDOUR::LuaAPI::Vamp::initialize)
2335                 .addFunction ("process", &ARDOUR::LuaAPI::Vamp::process)
2336                 .endClass ()
2337
2338                 .endNamespace () // end LuaAPI
2339                 .endNamespace ();// end ARDOUR
2340
2341         // DSP functions
2342         luabridge::getGlobalNamespace (L)
2343                 .beginNamespace ("ARDOUR")
2344                 .beginNamespace ("DSP")
2345                 .addFunction ("compute_peak", ARDOUR::compute_peak)
2346                 .addFunction ("find_peaks", ARDOUR::find_peaks)
2347                 .addFunction ("apply_gain_to_buffer", ARDOUR::apply_gain_to_buffer)
2348                 .addFunction ("mix_buffers_no_gain", ARDOUR::mix_buffers_no_gain)
2349                 .addFunction ("mix_buffers_with_gain", ARDOUR::mix_buffers_with_gain)
2350                 .addFunction ("copy_vector", ARDOUR::copy_vector)
2351                 .addFunction ("dB_to_coefficient", &dB_to_coefficient)
2352                 .addFunction ("fast_coefficient_to_dB", &fast_coefficient_to_dB)
2353                 .addFunction ("accurate_coefficient_to_dB", &accurate_coefficient_to_dB)
2354                 .addFunction ("memset", &DSP::memset)
2355                 .addFunction ("mmult", &DSP::mmult)
2356                 .addFunction ("log_meter", &DSP::log_meter)
2357                 .addFunction ("log_meter_coeff", &DSP::log_meter_coeff)
2358                 .addFunction ("process_map", &DSP::process_map)
2359                 .addRefFunction ("peaks", &DSP::peaks)
2360
2361                 .beginClass <DSP::LowPass> ("LowPass")
2362                 .addConstructor <void (*) (double, float)> ()
2363                 .addFunction ("proc", &DSP::LowPass::proc)
2364                 .addFunction ("ctrl", &DSP::LowPass::ctrl)
2365                 .addFunction ("set_cutoff", &DSP::LowPass::set_cutoff)
2366                 .addFunction ("reset", &DSP::LowPass::reset)
2367                 .endClass ()
2368                 .beginClass <DSP::Biquad> ("Biquad")
2369                 .addConstructor <void (*) (double)> ()
2370                 .addFunction ("run", &DSP::Biquad::run)
2371                 .addFunction ("compute", &DSP::Biquad::compute)
2372                 .addFunction ("configure", &DSP::Biquad::configure)
2373                 .addFunction ("reset", &DSP::Biquad::reset)
2374                 .addFunction ("dB_at_freq", &DSP::Biquad::dB_at_freq)
2375                 .endClass ()
2376                 .beginClass <DSP::FFTSpectrum> ("FFTSpectrum")
2377                 .addConstructor <void (*) (uint32_t, double)> ()
2378                 .addFunction ("set_data_hann", &DSP::FFTSpectrum::set_data_hann)
2379                 .addFunction ("execute", &DSP::FFTSpectrum::execute)
2380                 .addFunction ("power_at_bin", &DSP::FFTSpectrum::power_at_bin)
2381                 .addFunction ("freq_at_bin", &DSP::FFTSpectrum::freq_at_bin)
2382                 .endClass ()
2383                 .beginClass <DSP::Generator> ("Generator")
2384                 .addVoidConstructor ()
2385                 .addFunction ("run", &DSP::Generator::run)
2386                 .addFunction ("set_type", &DSP::Generator::set_type)
2387                 .endClass ()
2388
2389                 /* DSP enums */
2390                 .beginNamespace ("BiquadType")
2391                 .addConst ("LowPass", ARDOUR::DSP::Biquad::LowPass)
2392                 .addConst ("HighPass", ARDOUR::DSP::Biquad::HighPass)
2393                 .addConst ("BandPassSkirt", ARDOUR::DSP::Biquad::BandPassSkirt)
2394                 .addConst ("BandPass0dB", ARDOUR::DSP::Biquad::BandPass0dB)
2395                 .addConst ("Notch", ARDOUR::DSP::Biquad::Notch)
2396                 .addConst ("AllPass", ARDOUR::DSP::Biquad::AllPass)
2397                 .addConst ("Peaking", ARDOUR::DSP::Biquad::Peaking)
2398                 .addConst ("LowShelf", ARDOUR::DSP::Biquad::LowShelf)
2399                 .addConst ("HighShelf", ARDOUR::DSP::Biquad::HighShelf)
2400                 .endNamespace ()
2401
2402                 .beginNamespace ("NoiseType")
2403                 .addConst ("UniformWhiteNoise", ARDOUR::DSP::Generator::UniformWhiteNoise)
2404                 .addConst ("GaussianWhiteNoise", ARDOUR::DSP::Generator::GaussianWhiteNoise)
2405                 .addConst ("PinkNoise", ARDOUR::DSP::Generator::PinkNoise)
2406                 .endNamespace ()
2407
2408                 .beginClass <DSP::DspShm> ("DspShm")
2409                 .addConstructor<void (*) (size_t)> ()
2410                 .addFunction ("allocate", &DSP::DspShm::allocate)
2411                 .addFunction ("clear", &DSP::DspShm::clear)
2412                 .addFunction ("to_float", &DSP::DspShm::to_float)
2413                 .addFunction ("to_int", &DSP::DspShm::to_int)
2414                 .addFunction ("atomic_set_int", &DSP::DspShm::atomic_set_int)
2415                 .addFunction ("atomic_get_int", &DSP::DspShm::atomic_get_int)
2416                 .endClass ()
2417
2418                 .endNamespace () // DSP
2419                 .endNamespace ();// end ARDOUR
2420 }
2421
2422 void
2423 LuaBindings::dsp (lua_State* L)
2424 {
2425         luabridge::getGlobalNamespace (L)
2426                 .beginNamespace ("ARDOUR")
2427
2428                 .beginClass <AudioBuffer> ("AudioBuffer")
2429                 .addEqualCheck ()
2430                 .addFunction ("data", (Sample*(AudioBuffer::*)(samplecnt_t))&AudioBuffer::data)
2431                 .addFunction ("silence", &AudioBuffer::silence)
2432                 .addFunction ("apply_gain", &AudioBuffer::apply_gain)
2433                 .addFunction ("check_silence", &AudioBuffer::check_silence)
2434                 .addFunction ("read_from", (void (AudioBuffer::*)(const Sample*, samplecnt_t, samplecnt_t, samplecnt_t))&AudioBuffer::check_silence)
2435                 .endClass()
2436
2437                 .beginClass <MidiBuffer> ("MidiBuffer")
2438                 .addEqualCheck ()
2439                 .addFunction ("silence", &MidiBuffer::silence)
2440                 .addFunction ("size", &MidiBuffer::size)
2441                 .addFunction ("empty", &MidiBuffer::empty)
2442                 .addFunction ("resize", &MidiBuffer::resize)
2443                 .addFunction ("copy", (void (MidiBuffer::*)(MidiBuffer const * const))&MidiBuffer::copy)
2444                 .addFunction ("push_event", (bool (MidiBuffer::*)(const Evoral::Event<samplepos_t>&))&MidiBuffer::push_back)
2445                 .addFunction ("push_back", (bool (MidiBuffer::*)(samplepos_t, size_t, const uint8_t*))&MidiBuffer::push_back)
2446                 // TODO iterators..
2447                 .addExtCFunction ("table", &luabridge::CFunc::listToTable<const Evoral::Event<samplepos_t>, MidiBuffer>)
2448                 .endClass()
2449
2450                 .beginClass <BufferSet> ("BufferSet")
2451                 .addEqualCheck ()
2452                 .addFunction ("get_audio", static_cast<AudioBuffer&(BufferSet::*)(size_t)>(&BufferSet::get_audio))
2453                 .addFunction ("get_midi", static_cast<MidiBuffer&(BufferSet::*)(size_t)>(&BufferSet::get_midi))
2454                 .addFunction ("count", static_cast<const ChanCount&(BufferSet::*)()const>(&BufferSet::count))
2455                 .endClass()
2456                 .endNamespace ();
2457
2458         luabridge::getGlobalNamespace (L)
2459                 .beginNamespace ("Evoral")
2460                 .deriveClass <Evoral::Event<samplepos_t>, Evoral::Event<samplepos_t> > ("Event")
2461                 // add Ctor?
2462                 .addFunction ("type", &Evoral::Event<samplepos_t>::type)
2463                 .addFunction ("channel", &Evoral::Event<samplepos_t>::channel)
2464                 .addFunction ("set_type", &Evoral::Event<samplepos_t>::set_type)
2465                 .addFunction ("set_channel", &Evoral::Event<samplepos_t>::set_channel)
2466                 .endClass ()
2467                 .endNamespace ();
2468
2469         // dsp releated session functions
2470         luabridge::getGlobalNamespace (L)
2471                 .beginNamespace ("ARDOUR")
2472                 .beginClass <Session> ("Session")
2473                 .addFunction ("get_scratch_buffers", &Session::get_scratch_buffers)
2474                 .addFunction ("get_silent_buffers", &Session::get_silent_buffers)
2475                 .endClass ()
2476                 .endNamespace ();
2477
2478         luabridge::getGlobalNamespace (L)
2479                 .beginNamespace ("ARDOUR")
2480                 .beginClass <FluidSynth> ("FluidSynth")
2481                 .addConstructor <void (*) (float, int)> ()
2482                 .addFunction ("load_sf2", &FluidSynth::load_sf2)
2483                 .addFunction ("synth", &FluidSynth::synth)
2484                 .addFunction ("midi_event", &FluidSynth::midi_event)
2485                 .addFunction ("panic", &FluidSynth::panic)
2486                 .addFunction ("select_program", &FluidSynth::select_program)
2487                 .addFunction ("program_count", &FluidSynth::program_count)
2488                 .addFunction ("program_name", &FluidSynth::program_name)
2489                 .endClass ()
2490                 .endNamespace ();
2491
2492         luabridge::getGlobalNamespace (L)
2493                 .beginNamespace ("ARDOUR")
2494
2495                 .beginClass <LuaTableRef> ("LuaTableRef")
2496                 .addCFunction ("get", &LuaTableRef::get)
2497                 .addCFunction ("set", &LuaTableRef::set)
2498                 .endClass ()
2499
2500                 .endNamespace (); // ARDOUR
2501 }
2502
2503 void
2504 LuaBindings::session (lua_State* L)
2505 {
2506         // non-realtime session functions
2507         luabridge::getGlobalNamespace (L)
2508                 .beginNamespace ("ARDOUR")
2509                 .beginClass <Session> ("Session")
2510                 .addFunction ("save_state", &Session::save_state)
2511                 .addFunction ("set_dirty", &Session::set_dirty)
2512                 .addFunction ("unknown_processors", &Session::unknown_processors)
2513                 .addFunction ("export_track_state", &Session::export_track_state)
2514
2515                 .addFunction<RouteList (Session::*)(uint32_t, PresentationInfo::order_t, const std::string&, const std::string&, PlaylistDisposition)> ("new_route_from_template", &Session::new_route_from_template)
2516                 // TODO  session_add_audio_track  session_add_midi_track  session_add_mixed_track
2517                 //.addFunction ("new_midi_track", &Session::new_midi_track)
2518                 .endClass ()
2519
2520                 .endNamespace (); // ARDOUR
2521 }
2522
2523 void
2524 LuaBindings::osc (lua_State* L)
2525 {
2526         luabridge::getGlobalNamespace (L)
2527                 .beginNamespace ("ARDOUR")
2528                 .beginNamespace ("LuaOSC")
2529                 .beginClass<LuaOSC::Address> ("Address")
2530                 .addConstructor<void (*) (std::string)> ()
2531                 .addCFunction ("send", &LuaOSC::Address::send)
2532                 .endClass ()
2533                 .endNamespace ()
2534                 .endNamespace ();
2535 }
2536
2537 void
2538 LuaBindings::set_session (lua_State* L, Session *s)
2539 {
2540         /* LuaBridge uses unique keys to identify classes/c-types.
2541          *
2542          * Those keys are "generated" by using the memory-address of a static
2543          * variable, templated for every Class.
2544          * (see libs/lua/LuaBridge/detail/ClassInfo.h)
2545          *
2546          * When linking the final executable there must be exactly one static
2547          * function (static variable) for every templated class.
2548          * This works fine on OSX and Linux...
2549          *
2550          * Windows (mingw and MSVC) however expand the template differently for libardour
2551          * AND gtk2_ardour. We end up with two identical static functions
2552          * at different addresses!!
2553          *
2554          * The Solution: have gtk2_ardour never include LuaBridge headers directly
2555          * and always go via libardour function calls for classes that are registered
2556          * in libardour. (calling lua itself is fine,  calling c-functions in the GUI
2557          * which expand the template is not)
2558          *
2559          * (the actual cause: even static symbols in a .dll have no fixed address
2560          * and are mapped when loading the dll. static functions in .exe do have a fixed
2561          * address)
2562          *
2563          * libardour:
2564          *  0000000000000000 I __imp__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
2565          *  0000000000000000 I __nm__ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
2566          *  0000000000000000 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
2567          *
2568          * ardour.exe
2569          *  000000000104f560 d .data$_ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
2570          *  000000000104f560 D _ZZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEvE5value
2571          *  0000000000e9baf0 T _ZN9luabridge9ClassInfoIN6ARDOUR7SessionEE11getClassKeyEv
2572          *
2573          *
2574          */
2575         luabridge::push <Session *> (L, s);
2576         lua_setglobal (L, "Session");
2577
2578         if (s) {
2579                 // call lua function.
2580                 luabridge::LuaRef cb_ses = luabridge::getGlobal (L, "new_session");
2581                 if (cb_ses.type() == LUA_TFUNCTION) { cb_ses(s->name()); } // TODO args
2582         }
2583 }