]> Shamusworld >> Repos - ardour-manual/blobdiff - _manual/24_lua-scripting/01_brain_dump.html
include generated lua class reference
[ardour-manual] / _manual / 24_lua-scripting / 01_brain_dump.html
index 4333509a02c601e4ca470ff28b966f4716253f93..fe3820b0418ce23e7464ec46db8cccc29aa90b7e 100644 (file)
@@ -1,6 +1,6 @@
 ---
 layout: default
-title: Lua Scripting Documentation
+title: Scripting Documentation
 ---
 
 <p class="warning">
@@ -15,16 +15,16 @@ Examples for these include voice-activate (record-arm specific tracks and roll t
 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, which not only helps to support the Lua project,
+but if you have the means buy a copy of the book, it not only helps to support the Lua project,
 but provides for a much nicer reading and learning experience.
 </p>
 
@@ -142,9 +142,9 @@ The common part for all scripts is the "Descriptor". It's a Lua function which r
 <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>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>
+       <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>
 
 <p class="note">
@@ -307,6 +307,7 @@ Fully functional, yet still in a prototyping stage:
                        <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>
@@ -332,7 +333,7 @@ for t in Session:get_tracks():iter() do print(t:name()) end
 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)
@@ -340,18 +341,19 @@ print(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()
@@ -365,10 +367,16 @@ _, t = plugin:get_parameter_descriptor(2, x) -- port #2
 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>