I can't access many lua objects that are listed in the docs/cpp

(Kazoo) #1

Hi there! I’m using Ardour 5.12.0 on Ubuntu Studio 18.04. So I used this code as a class reference:
which is the code of the 5.12 release.
My problem is that many of the lua objects I try to use are nil. For instance:
I access the console using window -> scripting, then I pick snippets -> foreach track, which looks like this:

ardour { ["type"] = "Snippet", name = "Foreach Track" }

function factory () return function ()
	for r in Session:get_tracks():iter() do
		print (r:name())
		-- see http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Track
		-- for available methods e.g.
		r:set_active (true, nil)
end end

which works fine. However, when I use r:playlist() instead of r:name(), I just get “attempt to call a nil value”. Same for r:can_record(). Those methods should be present, they are added in the luabindings.cc.

The bigger picture: I want to use Ardour for band practice and record everything. So for every take, I want to create a new empty playlist in multiple tracks, each having date and time in its name. And without having to click and type everything by hand. I am also open for alternative ways to do this (including OSC). But in the end I would like to learn the lua scripting as well.

Kind regards!

(Robin Gareus) #2

Despite the name get_tracks() returns a Route object (a route is a base-class of everything that can route audio or midi data).
Cast it to a track first. e.g. r:to_track():playlist()

(Robin Gareus) #3

Sadly this is a somewhat tricky. One cannot directly create objects in a script. You’ll have to call existing methods to create a new playlist. For the case of playlists I don’t know if it can be scripted.
There’s https://github.com/Ardour/ardour/blob/master/scripts/new_playlist.lua - but that is interactive.

(Kazoo) #4

Thank you! I guess shifting inactive regions far to the right would also be an option… But that would be less convenient…
Can the click on [ P ] and [ New… ] be automated via OSC maybe?

Or is there a better option in general for the multiple takes on multiple tracks thing? A dropdown menu for layers or something…

(Robin Gareus) #5

I’d just use layers, in particular if you want to comp takes later.

Perhaps use Stacked Layers http://manual.ardour.org/working-with-tracks/controlling-track-appearance/layering-display/

(Kazoo) #6

I think what I’ll do is manually create a new playlist for every practice session and then use layers within one session, automatically naming newly recorded regions with the time of recording.

Thanks, you helped a lot! :slight_smile: