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