Hi everyone,
I’m working on a project where I want to automatically create an Ardour session by reading track information from a JSON file.
Goal
I want to:
- Read instrument data (like track name and type) from a JSON file.
- Automatically create tracks in Ardour using Lua scripting.
- Correctly handle mono vs stereo tracks based on the
"Type"
field.
Example JSON Input
Here’s a sample of how my input JSON looks:
json
CopyEdit
[
{
"Channel": "Channel",
"Description": "Instrument",
"Type": "Classified Type"
},
{
"Channel": "1",
"Description": "Kick In",
"Type": "Mono"
},
{
"Channel": "13-14",
"Description": "Lead Guitar DI",
"Type": "Stereo"
}
// ... More entries ...
]
Challenge
Ardour’s Lua scripting engine does not support require
or external Lua modules (like json.lua
) due to sandboxing. So I’m not sure how to parse JSON inside the Lua script in Ardour.
What I Tried
- I tried using
require("json")
, but it throws:
attempt to call a nil value (global 'require')
- Attempting to use a global
JSON
object fails as well:attempt to index a nil value (global 'JSON')
My Question
What’s the best way to work around Ardour’s limitations and load this JSON-like data in a Lua script?
Would converting the JSON into a Lua table (i.e., track_data.lua
) and using dofile()
be the recommended way?
And if so, could someone provide a clean example of:
- How the
track_data.lua
file should look? - How to loop over it and create mono/stereo tracks dynamically inside the Ardour Lua script?
Any help or suggestions would be greatly appreciated!
Thanks! How can I create Ardour tracks from a JSON file using Lua?
Hi everyone,
I’m working on a project where I want to automatically create an Ardour session by reading track information from a JSON file.
Goal
I want to:
- Read instrument data (like track name and type) from a JSON file.
- Automatically create tracks in Ardour using Lua scripting.
- Correctly handle mono vs stereo tracks based on the
"Type"
field.
Example JSON Input
Here’s a sample of how my input JSON looks:
json
CopyEdit
[
{
"Channel": "Channel",
"Description": "Instrument",
"Type": "Classified Type"
},
{
"Channel": "1",
"Description": "Kick In",
"Type": "Mono"
},
{
"Channel": "13-14",
"Description": "Lead Guitar DI",
"Type": "Stereo"
}
// ... More entries ...
]
Challenge
Ardour’s Lua scripting engine does not support require
or external Lua modules (like json.lua
) due to sandboxing. So I’m not sure how to parse JSON inside the Lua script in Ardour.
What I Tried
- I tried using
require("json")
, but it throws:
attempt to call a nil value (global 'require')
- Attempting to use a global
JSON
object fails as well:attempt to index a nil value (global 'JSON')
My Question
What’s the best way to work around Ardour’s limitations and load this JSON-like data in a Lua script?
Would converting the JSON into a Lua table (i.e., track_data.lua
) and using dofile()
be the recommended way?
And if so, could someone provide a clean example of:
- How the
track_data.lua
file should look? - How to loop over it and create mono/stereo tracks dynamically inside the Ardour Lua script?
Any help or suggestions would be greatly appreciated!
Could you provide code as well it is highly appreciated
Thanks!