How do I select a track based on the track number
I want to be able to select a Track In Pro Tools based on the Track number is there a script for this?
- Kitch Membery @Kitch2021-01-20 01:36:45.730Z
Hi @Brad_Lauchert,
The following script will select the track number of your choice.
const trackNumber = 2; sf.ui.proTools.appActivateMainWindow(); const track = sf.ui.proTools.visibleTrackNames[trackNumber-1]; sf.ui.proTools.trackSelectByName({names:[track]});
Let me know if this is what you are after. :-)
Rock on
Kitch- JJonathan Johnson @Jonathan_Johnson
What about a track scroll option?
say start with track one but each time the button is toggled, it rolls down, track 2, track 3.
Then a version that goes the opposite way?
ideally it would ask you for what start track number, say enter track 10, then next hit down goes to 11, 12, ect.....
Kitch Membery @Kitch2025-01-16 19:19:24.446Z
Could you provide additional context about the use case? This will help me better understand what you're after.
- JJonathan Johnson @Jonathan_Johnson
Sure, let’s say you have a session with 100 tracks.
Without SoundFlow what I’m doing is selecting the track view so that every track gets a track number, and then in pro tools with ‘Link track and edit selection’ I’m using the Colon key to scroll down to quickly jump through the tracks as a way of navigating what track selection is active. Or I’d use the ‘P’ Key to scroll up.
I’d like to create two buttons that did this for me instead
Perhaps they could have an arrow left on one and an arrow right in their logo
When I hit the right arrow button, it would prompt me and ask me which track I want to start with - regardless of the name.
Let’s say I key in the number 15. It would go to track number 15.
Then because the button is a toggle button if I hit it again, it would jump down a track to track 16 if I hit the button again it would go to track 17 etc.
Then the other button with the left arrow would do the same thing, but it would count up so if I was prompted and keyed in the prompt to track 14, the next time I hit the same button, it would go to track 13, then track 12.
Then using these two buttons, I could quickly scroll through my entire session. Perhaps if I wanted to be in jump view mode it could pull the selected track up quite large.
The reason why I want to do this is let’s say I have 100 tracks and I have everything scrunched down onto the screen very small. I want to quickly be able to scroll through the tracks and have individual tracks jump up at a jumbo view and get an overview of what’s in the session without having to change the view quickly.
I don’t have a control surface, but if I had one of those single Chanel control services with one Fader, this would essentially bank that fader through all my channels kind of like a left right toggle on a control surface
Hope that makes sense.
Kitch Membery @Kitch2025-01-17 00:31:35.999Z
If you're interested I put together a video of me creating the script in real time, it's totally raw with lots of mistakes but I got there in the end. Ha!
https://www.loom.com/share/154a8cc4f553496f8b20612329aaefe0?sid=ced7e5a4-0a1e-4d92-b65e-10edbb8bc1de
And here is the script that I created.
You'll need to copy and paste the script into SoundFlow and convert the script into a Command template. See from 23:22 in the video for how to set that up.
Here's the script.
const isOptionModifierHeld = event.keyboardState.hasAlt; const direction = event.props.direction; sf.app.proTools.tracks.invalidate(); const visibleTracks = sf.app.proTools.tracks.allItems.filter(track => !track.isHidden); const visibleTrackNames = visibleTracks.map(track => track.name); const selectedTrackName = visibleTracks.find(track => track.isSelected).name; /** * @param {Object} args * @param {'Up'|'Down'} args.direction */ function navigateTrack({ direction = "Down" }) { const indexOffest = direction === "Down" ? 1 : -1; const selectedTrackIndex = visibleTrackNames.indexOf(selectedTrackName); const targetTrackIndex = selectedTrackIndex + indexOffest; const targetTrackName = visibleTrackNames[targetTrackIndex]; if (!targetTrackName) throw 0 sf.app.proTools.selectTracksByName({ trackNames: [targetTrackName] }); sf.ui.proTools.trackGetByName({ name: targetTrackName }).track.trackScrollToView(); } function main() { if (isOptionModifierHeld) { // Ask user for target track number. const trackNumberString = sf.interaction.displayDialog({ title: "Navigate to Track", prompt: "Please enter the target track number.", buttons: ["OK", "Cancel"], defaultButton: "OK", cancelButton: "Cancel", defaultAnswer: "1", }).text; const targetTrackNumber = Number(trackNumberString); const targetTrackIndex = targetTrackNumber - 1; const targetTrackName = visibleTrackNames[targetTrackIndex]; sf.app.proTools.selectTracksByName({ trackNames: [targetTrackName] }); sf.ui.proTools.trackGetByName({ name: targetTrackName }).track.trackScrollToView(); } else { // Navigate tracks up/down navigateTrack({ direction }); } } main();
I hope that helps. :-)
It does not cover the track resizing but it does the navigation part.
Let me know if you have any questions.
- JJonathan Johnson @Jonathan_Johnson
Thanks so much for this, listen I ran into error
~Toggle Tracks failed
TypeError: Cannot read property 'direction' of null (~Toggle Tracks line 3)
CLIPS
(Type to Filter)
SetupI’m using this with the latest version of SoundFlow 5.10. Any suggestions?
Kitch Membery @Kitch2025-01-17 18:19:43.633Z
No worries, As mentioned in my previous thread, you'll need to convert this into a command template and create the "User-Defined Enums" associated with the up/down navigation direction.
Did you follow those steps from 23:22 in the video?
Let me know. :-)
- JJonathan Johnson @Jonathan_Johnson
My bad I just copy and pasted the script. I didn’t realize there was a little bit more work to do. I’ll go back and look at your video. Thank you so much.
- In reply toKitch⬆:JJonathan Johnson @Jonathan_Johnson
This is so great, thank you so much for making the video. It is so informative. I’m very excited.!!!
Works like a charm!!
Kitch Membery @Kitch2025-01-18 02:15:29.000Z
Awesome!! Glad it worked! :-)
- In reply toBrad_Lauchert⬆:Kitch Membery @Kitch2021-01-20 01:45:56.146Z
You can also select a track by name like this :-)
const trackName = 'Audio 2'; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.trackSelectByName({names:[trackName]});