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