Import a media and create a region using Lua

Related to

I’m investigating several solutions to “import” edits from the Lightworks video editor into Ardour.
I thought first about creating a new Ardour XML session file from scratch–but this seems a rather fragile solution. I am now considering generating a Lua script from Lightworks that could be used to re-create the same edit into Ardour.

As a typical use case, I would like:

  1. create a new track
  2. import the media /tmp/test.wav
  3. Put the segment from 00:00:05 to 00:00:15 from the media at position 00:01:00 in the newly created track

I searched through the examples and the doc, but I have a hard time fitting the pieces together.
I found how to create a track:

t = Session:new_audio_track (${inPorts}, ${outPorts}, nil, 1,
                                          ARDOUR.PresentationInfo.max_order, ARDOUR.TrackMode.Normal)

And how to import a media into the region list

m = Editor:do_import (files,
        Editing.ImportDistinctFiles, Editing.ImportAsRegion, ARDOUR.SrcQuality.SrcBest,
        ARDOUR.MidiTrackNameSource.SMFTrackName, ARDOUR.MidiTempoMapDisposition.SMFTempoIgnore,
        pos, ARDOUR.PluginInfo())

But I can find how to put the region at a given position on the track.
Any suggestion or example would be more than welcome!

  • Sylvain

I don’t have any particular advice, but I have recently created a script to import our band-recordings which shows how to create a track and import a certain file into it. Have a look:

Hi Robert,

Thank you for that example! I will certainly study it in depth.