Wait for Track Preset to Finish Building?
I’m trying to get my instrument Track Presets to come up and put themselves into Record automatically.
It (sort of) works, but the track selection and record arming is quite flakey. I suspect it has something to do with ‘waiting’ but I can’t seem to get the right command. Each bit of the script works individually but strung together, I think it’s taking too long for Kontakt to load, for example, a piano library.
Perhaps there's a better way to have the Track Preset come up already selected? but it doesn't with this method.
Any help greatly appreciated!
//Calling command "RS_Create New Track with Track Preset" from package "Raphael Sepulveda Utilities" (installed from user/pkg/version "wumCaKnhA0T91I79tL1NbXLQmH03/ckijqv49o000b4z10qr66346e/cktxeotob0002gz10dx9agktp")
sf.soundflow.runCommand({
commandId: 'user:1633356086185:ckilausmg000br910x1wluhgz',
props: {
numberOfTracks: 1,
menuPath1: ["Track Presets","1) Prod Stuff"],
menuPath2: ["Inst - Piano"],
}
});
sf.ui.proTools.windows.whoseTitle.is('Inst - Piano').first.elementWaitFor({
waitType: "Appear",
});
sf.ui.proTools.trackSelectByName({
names: ["Inst - Piano"],
});
sf.keyboard.press({
keys: "shift+r",
});
- Raphael Sepulveda @raphaelsepulveda2021-10-06 15:51:22.672Z
Hey Gavin!
One of the side effects of creating a new track is that it automatically gets selected after it is created, so we don't need to do anything else in that regard.
The following script should get you the desired result:
//Calling command "RS_Create New Track with Track Preset" from package "Raphael Sepulveda Utilities" (installed from user/pkg/version "wumCaKnhA0T91I79tL1NbXLQmH03/ckijqv49o000b4z10qr66346e/cktxeotob0002gz10dx9agktp") sf.soundflow.runCommand({ commandId: 'user:1633356086185:ckilausmg000br910x1wluhgz', props: { numberOfTracks: 1, menuPath1: ["Track Presets","1) Prod Stuff"], menuPath2: ["Inst - Piano"], } }); sf.ui.proTools.mainWindow.invalidate(); sf.ui.proTools.selectedTrack.buttons.whoseTitle.is("Track Record Enable").first.elementClick();
- GGavin Goldberg @Gavin_Goldberg
Hi Raphael,
Thanks for the reply. For some reason, on my system the newly created preset track is not automatically selecting itself after creation. Maybe I need to resave the track preset while it's selected? Other tracks (audio, auxes etc.) do select themselves after creation.
I've added this to your script and it seems to do the job now
sf.ui.proTools.trackSelectByName({ names: ["Inst - Piano"], });
Only problem is, if I add another instance of the same track preset it will have a different name and therefore won't select.
Raphael Sepulveda @raphaelsepulveda2021-10-06 17:16:31.512Z
That's odd. I tried to make my session behave like that but nothing worked. The new track is always selected. Mmm.. I'd be interested if you could try and find out why that happens so we can help other folks in the future!
In the meantime, here's a script that will select the newly created track without you having to specify it's name:
const oldTracksInSession = sf.ui.proTools.tracks.names; //Calling command "RS_Create New Track with Track Preset" from package "Raphael Sepulveda Utilities" (installed from user/pkg/version "wumCaKnhA0T91I79tL1NbXLQmH03/ckijqv49o000b4z10qr66346e/cktxeotob0002gz10dx9agktp") sf.soundflow.runCommand({ commandId: 'user:1633356086185:ckilausmg000br910x1wluhgz', props: { numberOfTracks: 1, menuPath1: ["Track Presets","1) Prod Stuff"], menuPath2: ["Inst - Piano"], } }); sf.ui.proTools.mainWindow.invalidate(); const currentTracksInSession = sf.ui.proTools.tracks.names; const newlyCreatedTracks = currentTracksInSession.filter(track => !oldTracksInSession.includes(track)); sf.ui.proTools.trackSelectByName({ names: newlyCreatedTracks, }); sf.ui.proTools.selectedTrack.buttons.whoseTitle.is("Track Record Enable").first.elementClick();
- GIn reply toGavin_Goldberg⬆:Gavin Goldberg @Gavin_Goldberg
Hi Raphael,
Thanks again for your efforts. That new script is throwing up an error saying Old tracks in session is not defined (line 15) . Not sure what that means, but I've basically got a version of it working with my work around, which is not perfect, but doing the job!
Best,
Gavin
Raphael Sepulveda @raphaelsepulveda2021-10-06 22:37:33.638Z
Weird. That means it wasn't able to fetch a list of the tracks in the session. Try adding this at the very top of that last script I sent
sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate();