how to get all the parameters id of all parameters of a track (even those nested in a rack, in a rack, in a rack etc..)
Hello
Sorry if it's simple but I don't manage totally to achieve that.
I can get all the device of a track, and get then the id of each parameters.
I can then with "can_have_chains" know wich device is a rack and retrieve the devices nested inside it.
ok
But how can I do the same with rack in rack.., when I don't know the depth of the rack/rack/rack hierarchy ?
.At the end I just try to have a list with all parameters of a track.
The menu "paste from/max for live/Live api chooser/browse device parameter" do the trick easily, but I don't know JS at all and I don't manage to bang this snippet in a way it will output the whole list of track's parameters...
an idea ?
thank you !
Julien
You probably know this but you can use [uzi] set to an arbitrary big number, and break its iterations using the 'break' message.
thank you Chapelier,
Yes I know the trick, maybe I was not clear enough with what bothers me.
I know how to retrieve the parameters list of a device.
What I don't manage to achieve correctly, is to, with a track, to retrieve the whole list of all parameters id of this whole track, with parameters of devices that are nested in a rack, even those nested in a rack in a rack in a rack etc..
How to perform a such request to API when you don't know the depth hierarchy of chains?
I am looking for a patch idea, where you ask for each device of a track its "can_have_chains" property to know if it's a rack, and then re-ask for this id, the list of chains, and so on with all those chains, etc etc.
I can see the logical but I don't manage to build this loop that will go through all the depth of racks and have to whole list of parameters of the track at the end (including Rack mixer parameters, chain mixer parameters etc..)
As I said*, the menu "paste from/max for live/Live api chooser/browse device parameter" do the trick easily.
But how do you bang this snippet to have at the end this clean ID list of ALL the parameters of a track ? Even ID of mixer settings of all the chains hierarchy...
thank you for your help !
a la tienne
Julien
bump
..............
This is really a job for the js
object and the JS LiveAPI object. This sort of iterative, recursive stuff is a royal pain to do using object boxes.
thank you Jeremy for your response. You confirm my pain =)
I still don't have Live12beta so I cannot open and see the new m4L device "variation" that seems to collect the id of all the parameters of a track. This device is achieving that thanks to JS ? Does it looks parameters in rack within rack within racks... without limits ? If yes, is there somewhere in the device a way to collect all those parameters id in a list ?
About the JS solution, someone has surely already made this "iterative and recursive" code isn't it ?
I know at least one person who has done this sort of thing. Here's a start for how you get get at this.
For your goal you'd need to modify it so that it includes the Chain ids when it's building the list. And once you have the full list of device/chain ids you'll need to type-check them so that you can get mixer_device parameters in the Chains.
//// Trivial example usage...
function bang() {
var api = new LiveAPI(null, "live_set tracks 1")
var device_ids = get_all_child_device_ids(api)
post("device_ids","\n")
for (var i = 0; i < device_ids.length; i+=2) {
api.id = device_ids[i+1]
post(" ", api.get("name"), "id", api.id, "\n")
}
}
/*
get_all_child_device_ids
Returns a list of all child ids of api_obj (which could be a Track or Chain). Called recursively into device Racks/Chains.
The returned ids list is in order such that earlier ids in Chains always come before ids downstream of those chains.
EXAMPLE:
var child_ids_list = get_all_child_device_ids( my_track_api_obj )
*/
function get_all_child_device_ids(api_obj, matching_ids_list) {
// Concat matching ids in recursive usage (for RackDevice and their Chains)
var matching_ids = (matching_ids_list && matching_ids_list.length) ? matching_ids_list : []
var original_id = api_obj.id
// 2023-06-05 : Put in a try/catch while trying to debug why this wasn't working with nested Drum Racks. The issue was that I didn't know "DrumChain" existed as a type. Rather than explicitly testing against three types (Track, Chain, DrumChain), it seems easier to just try to get "devices" children, and if it fails we know we passed something bogus. With the catch{} we will now print the informative error in that case, instead.
try {
var devices = api_obj.get("devices") // This should fail and throw error if type is not correct
// post("devices", devices, "\n")
for (var i = 0; i < devices.length; i+=2) {
api_obj.id = parseInt(devices[i+1])
// Include the device.
matching_ids[matching_ids.length] = "id"
matching_ids[matching_ids.length] = parseInt(devices[i+1])
if (api_obj.type == "RackDevice") {
// If it's a RackDevice, call recursively to look in its chains.
var chains_ids = api_obj.get("chains")
// post("chains_ids", chains_ids, "\n")
if ( chains_ids == "<empty>" || ! chains_ids ) { continue } // Drum Racks can exist with no chains.
for (var n = 0; n < chains_ids.length; n+=2) {
// post(" test id:", parseInt(chains_ids[n+1]), "\n")
var id = parseInt(chains_ids[n+1])
if ( id ) { // id can be 'nan'. This should prevent calling below that.
api_obj.id = id
matching_ids = get_all_child_device_ids(api_obj, matching_ids)
}
}
}
}
} catch (err) {
error(String(err), "get_all_child_device_ids() requires LiveAPI object with children devices (Track/Chain/DrumChain). api_obj id was: " + api_obj.id, "\n")
} finally {
api_obj.id = original_id // restore initial api_obj selection
return matching_ids
}
};
Thank you a lot Tyler
I will investigate...but I don't know anything to JS.. One day it's time to start =)
Made an account to say thank you for this, it was actually super helpful. I added another part that would also print the device names and parameters (which slowed up my live for a bit but no biggie) .
This was super useful in helping me get things better, and to make my own m4l device.
Once again, thanks .
Hello, knowing absolutly nothing to JS, can you maybe post your patch ?
And I am still curious to see an "no,JS" solution. Some devices are close to, but even "Variation" seems to miss some parameters...
Thank you
as the most 'only max' purist, I have tackled this problem. a years ago to make the device that mutates all parameter randomly and interpolate between two random presets. (check the demo: https://www.instagram.com/reel/C-c0-WePj2Q/?utm_source=ig_web_copy_link&igsh=MzRlODBiNWFlZA==)
this type of problem always needs a nested loop style programming idea, which is little bit tricky to illustrate in Max environment. (personally) sometimes code-based solution is much straightforward.
here's a max snippet i made for record all parameters from a track in Live.
and completed script i wrote in JS as well. simply load this script into JS object and push bang.
Oh, this is really a thing. I remember there was a device called Kapture storing selected parameters of entire set - based on JS, not bad, but not robust enough to use it on the fly - track-oriented approach seems to be more promising from my point of view, Thanks for sharing.