---
layout: default
-title: Lua Scripting Documentation
+title: Scripting Documentation
---
<p class="warning">
-This Documention is Work in Progress and far from complete. Also the documented API may be subject to change.
+This Documentation is Work in Progress and far from complete. Also the documented API may be subject to change.
</p>
<h2>Preface</h2>
rename all regions after a specific timecode, launch an external application when a certain track is soloed, generate automation curves
or simply provide a quick shortcut for a custom batch operation.
</p><p>
-Cases like this call for means to extend the DAW without actually changing the DAW itself. This is here scripting comes in.
+Cases like this call for means to extend the DAW without actually changing the DAW itself. This is where scripting comes in.
</p><p>
"Scripting" refers to tasks that could alternatively be executed step-by-step by a human operator.
</p><p>
Lua is a tiny and simple language which is easy to learn, yet allows for comprehensive solutions.
Lua is also a glue language it allows to tie existing component in Ardour together in unprecedented ways,
-and most importantly Lua is one of the few scripting-languages which be safely used in a real-time environment.
+and most importantly Lua is one of the few scripting-languages which can be safely used in a real-time environment.
</p><p>
A good introduction to Lua is the book <a href="http://www.lua.org/pil/">Programming in Lua</a>. The first edition is available online,
but if you have the means buy a copy of the book, it not only helps to support the Lua project,
<dl>
<dt>type [required]</dt><dd>one of "<code>DSP</code>", "<code>Session</code>", "<code>EditorHook</code>", "<code>EditorAction</code>" (the type is not case-sensitive)</dd>
<dt>name [required]</dt><dd>Name/Title of the script</dd>
- <dt>author</dt<dd>Your Name</dd>
+ <dt>author</dt><dd>Your Name</dd>
<dt>license</dt><dd>The license of the script (e.g. "GPL" or "MIT")</dd>
<dt>description</dt><dd>A longer text explaining to the user what the script does</dd>
</dl>
<li>convenience methods (wrap more complex Ardour actions into a library). e.g set plugin parameters, write automation lists from a lua table</li>
<li>Add some useful scripts and more examples</li>
<li>Documentation (Ardour API), also usable for tab-exansion, syntax highlighting</li>
+ <li>bindings for GUI Widgets (plugin UIs, message boxes, etc)</li>
</ul>
<li>
</ul>
for r in Session:get_routes():iter() do print(r:name()) end
-Session:tempo_map():add_tempo(ARDOUR.Tempo(100,4), ARDOUR.BBT_TIME(4,1,0))
+Session:tempo_map():add_tempo(ARDOUR.Tempo(100,4), Timecode.BBT_TIME(4,1,0))
Editor:set_zoom_focus(Editing.ZoomFocusRight)
Editor:set_zoom_focus(1)
-files = ARDOUR.StringVector();
+files = C.StringVector();
files:push_back("/home/rgareus/data/coding/ltc-tools/smpte.wav")
pos = -1
Editor:do_import(files, Editing.ImportDistinctFiles, Editing.ImportAsTrack, ARDOUR.SrcQuality.SrcBest, pos, ARDOUR.PluginInfo())
#or in one line:
-Editor:do_import(ARDOUR.StringVector():add({"/path/to/file.wav"}), Editing.ImportDistinctFiles, Editing.ImportAsTrack, ARDOUR.SrcQuality.SrcBest, -1, ARDOUR.PluginInfo())
+Editor:do_import(C.StringVector():add({"/path/to/file.wav"}), Editing.ImportDistinctFiles, Editing.ImportAsTrack, ARDOUR.SrcQuality.SrcBest, -1, ARDOUR.PluginInfo())
# called when a new session is loaded:
function new_session (name) print("NEW SESSION:", name) end
+# read/set/describe a plugin parameter
route = Session:route_by_remote_id(1)
processor = route:nth_plugin(0)
plugininsert = processor:to_insert()
paramdesc = t[2]
print (paramdesc.lower)
-ctrl = ARDOUR.EvoralParameter(ARDOUR.AutomationType.PluginAutomation, 0, 2)
+ctrl = Evoral.Parameter(ARDOUR.AutomationType.PluginAutomation, 0, 2)
ac = plugininsert:automation_control(ctrl, false)
print (ac:get_value ())
ac:set_value(1.0, PBD.GroupControlDisposition.NoGroup)
+
+# the same using a convenience wrapper:
+route = Session:route_by_remote_id(1)
+proc = t:nth_plugin (i)
+ARDOUR.LuaAPI.set_processor_param (proc, 2, 1.0)
+
</code></pre>
</div>