Differences

This shows you the differences between two versions of the page.

Link to this comparison view

wiki:ardourlua [28.01.2016 22:28]
rgareus
wiki:ardourlua [24.02.2016 00:46] (current)
rgareus [LuaSession]
Line 1: Line 1:
 ====== Ardour Lua Scripting ====== ====== Ardour Lua Scripting ======
-~~DRAFT~~+moved to   http://manual.ardour.org/lua-scripting/
  
-Lua is a lightweight programming language which lends itself nicely to embedded into other applications.+===== Console Examples =====
  
-In Ardour's case Lua is available: 
- 
-  * DSP Scripts - audio processor - plugins with access to the session 
-  * Session Scripts - realtime, called at the start of every audio cycle 
-  * Editor Action Scripts - user accessible actions (menu, bindings) 
-  * Editor Hooks - event triggered actions, GUI thread 
-  * Script Console 
- 
-===== Why Lua? ===== 
- 
-small, lean, rt-safe. 
- 
-===== General Concepts ===== 
- 
-  * Ardour calls Lua (not the other way 'round). 
-  * No bound constructors. Ardour provided factory methods. ie. Lua asks Ardour to create objects (eg, add a new track), then receives a reference to the object. 
-  * All Lua interpreters except the DSP-scripts are singleton instances. 
-    * Session Scripts: The process-callback run all //registered// scripts in sequence. Session Script have limited access to the Session (realtime-safe). Scripts are registered/unregistered from Menu -> Session -> Scripting -> Add/Remove Script 
-    * Editor Action Scripts: These are called from the GUI (explicit user action). 10 Slots are available from Menu -> Edit -> Scripted Actions.  Editor Action Scripts have complete access to the Session and to the Editor. 
-    * Editor Hooks: They're automatically triggered Action Scripts, connect to signals (block the GUI thread while running). -- currently not implemented 
-    * DSP scripts: are like regular plugins with a generic GUI. The context menu for each Route allows to add them. Using Plugin Controls, these are the only scripts that a user can interact with once they're instantiated. 
-  * Scripts, once loaded, are saved with the Session (no reference to external files) 
-  * Lua Scripts are never executed directly. They provide a "factory" method which can have instantiation parameters. 
- 
-===== Script Layout ===== 
- 
-  * Descriptor: Name, Author, Description, URL,... 
-  * Factory function: a function which returns the actual script. 
-  * [optional]: list of parameters for the "factory". 
- 
-DSP-plugins have additional list of automatable parameters. 
- 
- 
-===== Bindings ===== 
-Lua has direct access to Ardour internals: C++ classes, methods, data and functions. 
-So writing elaborate scripts requires some knowledge about Ardour's internal interfaces. 
- 
- 
-===== DSP Scripts ===== 
- 
- 
- 
-===== Editor Examples ===== 
- 
-   
   print (Session:route_by_remote_id(1):name())   print (Session:route_by_remote_id(1):name())
      
Line 81: Line 36:
   # called when a new session is loaded:   # called when a new session is loaded:
   function new_session (name) print("NEW SESSION:", name) end   function new_session (name) print("NEW SESSION:", name) end
 +  
 +   
 +  route = Session:route_by_remote_id(1)
 +  processor = route:nth_plugin(0)
 +  plugininsert = processor:to_insert()
 +  
 +  plugin = plugininsert:plugin(0)
 +  print (plugin:label())
 +  print (plugin:parameter_count())
 +  
 +  x = ARDOUR.ParameterDescriptor ()
 +  _, t = plugin:get_parameter_descriptor(2, x) -- port #2
 +  paramdesc = t[2]
 +  print (paramdesc.lower)
 +  
 +  ctrl = ARDOUR.EvoralParameter(ARDOUR.AutomationType.PluginAutomation, 0, 2)
 +  ac = plugininsert:automation_control(ctrl, false)
 +  print (ac:get_value ())
 +  ac:set_value(1.0, PBD.GroupControlDisposition.NoGroup)
  
 +===== LuaSession =====
  
-  A = ARDOUR.AudioEngine.create() +  for i,in AudioEngine:available_backends():iter() do print (i.name) end               
-  for i,in A:available_backends():iter() do print (i.name) end                                                                                                                                +  backend = AudioEngine:set_backend("ALSA", "", "") 
-  print (A:current_backend_name()) +  print (AudioEngine:current_backend_name())
-  backend = A:set_backend("ALSA", "", "") +
   for i,_ in backend:enumerate_devices():iter() do print (i.name) end   for i,_ in backend:enumerate_devices():iter() do print (i.name) end
 +  backend:set_input_device_name("HDA Intel PCH") 
 +  backend:set_output_device_name("HDA Intel PCH") 
 +  print (backend:buffer_size()) 
 +  print (AudioEngine:get_last_backend_error()) 
 +  
   s = load_session ("/home/rgareus/Documents/ArdourSessions/lua2/", "lua2")   s = load_session ("/home/rgareus/Documents/ArdourSessions/lua2/", "lua2")
   s:request_transport_speed (1.0)   s:request_transport_speed (1.0)
   print (s:transport_rolling())   print (s:transport_rolling())
 +  s:goto_start()
 +  close_session()
  
- 
-  A = ARDOUR.AudioEngine.create() backend = A:set_backend("ALSA", "", "") 
-  backend:set_input_device_name("HDA Intel PCH") 
-  backend:set_output_device_name("HDA Intel PCH") 
-  s = load_session ("/home/rgareus/Documents/ArdourSessions/theCat/", "theCat") 
-  s:request_transport_speed (1.0) 
- 
-  print (backend:buffer_size()) 
-  print (A:start()) 
-  print (A:get_last_backend_error()) 
 
wiki/ardourlua.1454016525.txt.gz · Last modified: 28.01.2016 22:28 by rgareus