Querying Track length
The last time I worked with java was helping with OSRS packet automation api & tick perfect scripts in 2020 so I'm a little rusty when it comes to all things java. I wanted to start with something easy which setting markers in pro tools every 8 bars was solid starting project.
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.invalidate();
var index_Markers = 1
var index_BarLocation = 1
for (var i = 0; i < 20; i++){
sf.ui.proTools.memoryLocationsCreate({
memoryLocationNumber: index_Markers ,
name : ""+index_Markers,
});
index_Markers++; //update index
index_BarLocation+= 8;//update index
sf.ui.proTools.mainWindow.counterDisplay.textFields.whoseTitle.is("Main Counter").first.elementClick();
//todo figure out how to just nest theses two in a func
sf.keyboard.type ({text: ""+index_BarLocation,});
sf.keyboard.press({keys: "return", });
}//end for
/*
function getLongestClipLength(){
var temp_LongestClip = 0
for (every clip) {
if (clip.length > temp_LongestClip){
temp_LongestClip = clip.length
}
}
return temp_LongestClip
}
*/
Next issue I ran into was not every session is the same length and I couldn't really find an easy way to query every track length or even find like the properties of a track object in the documentation. (the f12 command in the script editor isn't anything like intellij when it comes to figuring out what something does or what an object consists of)
Excuse the bad pseudocode but basically looking to know how to query audio length of clips so I can just have the script set markers based on session size vs some constant number. (sorry if it's been answered before I did give it the good ol' college try before asking for help)
Eventually want to dive further into automating audio manipulation so I can essentially automate my entire sampling workflow with stem separation, drumsep, melodyne, and audio to midi. For example exporting individual drum kit elements, bass notes, vocal phrases/words, chords.
Is there a community user defined functions list or do I have to go through everyones packages and strip them?
- SSoundFlow Bot @soundflowbot
Thanks for contacting SoundFlow support.
Please note, that the best way to get help with a script, macro or other content installed from the Store or content that you've made yourself, is to select the script/macro, then click the red Need help button, and then click "Get help with this script or macro".
By using this method, we will get access to more information and so should be able to help you quicker.
You can read more about how this works here: bit.ly/sfscripthelpIf you're seeing an error that isn't related to scripts or macros, and you think this is a bug in SoundFlow, please file a Help/Issue bug report.
You can see how to do this by going to bit.ly/sfhelpissue
In reply tocameron_korner⬆:Christian Scheuer @chrscheuer2024-01-06 16:06:09.923ZHi Cameron,
Please note the language used in SoundFlow is Javascript, not Java. While the languages share part of their name, other than that, they are entirely independent languages. (Javascript is not a leaner/"script" version of Java, they really have nothing to do with each other except both taking syntax from C).
Here are some good resources for brushing up on your JS:
https://soundflow.org/docs/how-to/custom-commands/javascript-resourcesThe best/easiest way to learn how to do things in SoundFlow is to use the macro editor first to build macros and then convert them to scripts.
I'd also highly recommend our Youtube tutorials if you haven't already seen them:
https://www.youtube.com/playlist?list=PLKWpZOwx5Z3jxnpNo_dQPhDQNRwp7DCNjfind like the properties of a track object in the documentation
Type
sf.ui.proTools.selectedTrack.and you'll get a list of actions that are available to perform on tracks.Please note that by virtue of SoundFlow doing most of what it does via UI automation, there are limitations to the information we have access to.
You should also take a look at actions available under
sf.app.proToolswhich give you access to SDK/API integration features that aren't based on UI automation but have deeper access to information from your session.Now that was for the basics/general questions. For your concrete question, for the community to help better, it would be helpful if you could elaborate on the following:
how to query audio length of clips so I can just have the script set markers based on session size vs some constant number
Specifically, where do you want the markers to be set based on what exactly? For example, it could be "set markers every 8 bars until the position in the session where the right-most audio clip is located".
To achieve that, you'd need to fetch information about where clips are in the session, which is currently not very well supported in the APIs. We hope to keep working with Avid to get more access to information about the timeline in the future.
Hope this can help you get started.
Christian Scheuer @chrscheuer2024-01-06 16:10:08.196ZHere's an example using newer SDK features to create markers at every 8 bars:
let markerNumber = 1; for (let barNumber = 1; barNumber <= 64; barNumber += 8) { sf.app.proTools.createMemoryLocation({ number: markerNumber, name: `Bar ${barNumber}`, startTime: `${barNumber}|1|000`, }); markerNumber++; }
Christian Scheuer @chrscheuer2024-01-06 16:15:50.538ZHere's an example of creating markers every 8 bars until the "end" of the session - end here defined by the last "content" in the session.
//Select all tracks sf.app.proTools.extendSelectionToTracks({ trackNames: sf.ui.proTools.visibleTrackNames, }); //Select everything on all tracks sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Select All'] }); //Make sure we're in Bars|Beats mode sf.ui.proTools.mainCounterSetValue({ targetValue: 'Bars|Beats', }); //Now, get the right edge of the selection (we'll consider that the "end" of the session - content-wise) let outTime = sf.app.proTools.getTimelineSelection({ timeScale: 'BarsBeats', }).outTime; //Get the last bar let lastBar = Number(outTime.split('|')[0].trim()); //Now create the markers let markerNumber = 1; for (let barNumber = 1; barNumber <= lastBar + 8; barNumber += 8) { sf.app.proTools.createMemoryLocation({ number: markerNumber, name: `Bar ${barNumber}`, startTime: `${barNumber}|1|000`, }); markerNumber++; }