Rec & export from lua cmd

Hello comunity,

Is it possible to execute from command line lua script to load a session and start recording and export to a wav file.

I wanted to automatically triggered the record and export from the command line.

1 Like

Yes. Something like


#!/opt/Ardour-7.5.0/bin/ardour7-lua
reclen = 5 -- seconds

AudioEngine:set_backend("JACK", "", "")

-- open existing session "/tmp/lua-test/lua-test.ardour"
s = load_session ("/tmp/lua-test", "lua-test")
assert (s);

-- record-arm all tracks
for track in Session:get_tracks():iter() do
  track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
end

-- rewind, record-enable transport state and roll
Session:goto_start()
Session:maybe_enable_record()
Session:request_roll (ARDOUR.TransportRequestSource.TRS_UI)

-- recording
for i = 1, (2 * reclen) do
  ARDOUR.LuaAPI.usleep (500000) -- 500ms
  print ("Recording", i / 2, "sec")
end

-- stop transport
Session:request_stop (false, false, ARDOUR.TransportRequestSource.TRS_UI)

ARDOUR.LuaAPI.usleep (500000) -- wait for 1/2 sec
s:save_state("")

-- export session
e = s:simple_export()
assert (e:check_outputs ())
e:run_export()
e = nil

close_session()

Thanks for your fast answer.
It does record but I got a silent wav file. I also got over the command line these erros
Vamp::HostExt::PluginLoader: No library found in Vamp path for plugin “libardourvampplugins:ebur128”
Vamp::HostExt::PluginLoader: No library found in Vamp path for plugin “libardourvampplugins:dBTP”
Vamp::HostExt::PluginLoader: No library found in Vamp path for plugin “libardourvampplugins:dBTP”

I can see that the library is found under “C:\Program Files\Ardour7\lib\ardour7\vamp” but I don’t know how to set “Vamp path” from command line

Do you know how to set it?

Oh Windows… I assume you don’t use JACK. Have you configured the backend?

backend = AudioEngine:set_backend("PortAudio", "", "")
backend:set_driver ("ASIO")
backend:set_device_name ("HDA Intel PCH") -- or similar
1 Like

It worked now after setting
backend = AudioEngine:set_backend(“PortAudio (default)”, “”, “”)
e = backend:set_driver (“MME”)
backend:set_input_device_name (“Headset (Jabra Evolve2 65)”)

Also when I use set_device, it doesn’t work, I need to use set_input_device_name
Thank you very much for your support :slight_smile:

One last question is it possible to export each track into separate wave file from lua script?

No. Stem Export can currently only be initiated from the GUI.

However, by default mono .wav files are used when recording. You could just grab the files directly from the session: <session-dir>\interchage\<session-name>\audiofiles\

1 Like

perfect, thank you! very much :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.