I'm trying to figure out a script to set a track to a fader value of 0.0 dB. I use a master fader for a eucon master and it's be great to have a set to zero shortcut. I found the code to find the track by name but can't quite figure out how to set fader to zero.
Any help?
Linked from:
- Christian Scheuer @chrscheuer2020-08-17 08:48:52.394Z
This script will Option-Click on the volume display of the selected track in the Edit window, to reset the volume to 0.0 for that track:
sf.ui.proTools.selectedTrack.groups.whoseTitle.is("Audio IO").first.sliders.whoseTitle.is('Volume').first.mouseClickElement({ isOption: true, });
This does the same for a track named "Eucon Master" by first scrolling the track into view, then option-clicking its volume display:
const track = sf.ui.proTools.trackGetByName({ name: 'Eucon Master' }).track; track.trackScrollToView(); track.groups.whoseTitle.is("Audio IO").first.sliders.whoseTitle.is('Volume').first.mouseClickElement({ isOption: true, });
- UUdi Simhon @Udi_Simhon
Hi Christian Scheuer
@chrscheuer
Can you please modify the first script to to -3db reduction of level to the selected track?Thanks!
Udi
Andrew Scheps @Andrew_Scheps
Hi @Udi_Simhon ,
That script uses option-click to set it to 0, so there's no version of it that will work to do relative levels. My script below would be the starting point, but you would have to read the level, do the math and then set the level. Not too involved. It would probably be better to make it for selected track as well to not have it hard coded (unless it's a template track you use all the time).
If you want to try it yourself here's some untested code that might work. I'm not in front of Pro Tools to test.
Change (from line 32):
win.textFields.whoseTitle.is('Volume Numerical').first.elementClick(); sf.keyboard.type({ text: VOLUME }); sf.keyboard.press({ keys: 'enter' });
to
var volumeTextField = win.textFields.whoseTitle.is('Volume Numerical').first; var originalVolume = Number(volumeField.value.invalidate().value); var newVolume = originalVolume - 3; volumeTextField.elementClick(); sf.keyboard.type({ text: String(newVolume) }); sf.keyboard.press({ keys: 'enter' });
Also, change line 1 to:
const Target_Track = sf.ui.proTools.selectedTrackNames[0];
If you want to do it to all selected tracks you would need get rid of the
[0]
and set up afor
loop, remembering to scroll each track into view first.If this doesn't work out of the box I would suggest starting a new thread in the forum with a copy of my script and get somebody to add the bits you need.
Happy new year!
AndrewChristian Scheuer @chrscheuer2024-01-01 16:16:21.506Z
There's also possible inspiration to get in this command in our official Pro Tools package:
- DDavid Carey @David_Carey
Is there a numeric value for -INF? Fader all the way down...
- In reply toChipSloan⬆:Chip Sloan @ChipSloan
Great Thanks. Is there a command I can add to return the scroll to where it started?
Christian Scheuer @chrscheuer2020-08-27 09:29:37.401Z
Unfortunately, I don't think we have that ability today.
- In reply toChipSloan⬆:Chip Sloan @ChipSloan
For the record I could not get that to work in the Edit window. I did however get this to work for my track named "ST CR Master":
sf.ui.proTools.trackGetByName({ name: "ST CR Level", makeVisible: true }).track.trackScrollToView(); sf.ui.proTools.mainWindow.groups.whoseTitle.is('ST CR Level - Master Track ').first.groups.whoseTitle.is('Master IO').first.buttons.whoseTitle.is('Output Window button').first.elementClick(); sf.ui.proTools.mainTrackOutputWindow.sliders.whoseTitle.is('Volume').first.elementClick({ isOption: true, });
Thanks
C
- AIn reply toChipSloan⬆:Andy Daddario @Andy_Daddario
Hi All, completely new here. I can see how to set the fader to 0. What if I wanted to set it to -10? Is there a way to do that? Specifically the MX Fader in my session if that helps.
I wrote an apple script to do this, but runs SO SLOW.....:)
Thanks!.....Andy
Christian Scheuer @chrscheuer2020-09-04 18:19:02.494Z
Hi Andy,
Didn't see your post here immediately as you replied to a closed/solved thread. The best way is to open a new thread linking to the old one as then I can see your thread would be marked unsolved, so I won't forget it :)
I think you can do something to implement this by combining our HUI emulation with preview reading/writing.
If you open up a new thread, I'll send you some scripts.
- In reply toChipSloan⬆:Andrew Scheps @Andrew_Scheps
This script will set the volume of the specified track to the specified volume, as set by the two constants at the top of the script, and then reselect the original track. You could make this more flexible by doing it on the selected track.
sf.ui.proTools.appActivateMainWindow(); const TARGET_TRACK = "MX"; const VOLUME = '-10'; function setVolume() { if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open') sf.ui.proTools.selectedTrack.outputWindowButton.elementClick(); var win = sf.ui.proTools.floatingWindows.allItems.filter(function (w) { return w.children.whoseTitle.is('Volume').exists; })[0]; win.textFields.whoseTitle.is('Volume Numerical').first.elementClick(); sf.keyboard.type({ text: VOLUME }); sf.keyboard.press({ keys: 'enter' }); } function main() { //Save the name of the originally selected track //And the selection var originalTrackName = sf.ui.proTools.selectedTrackNames[0]; var selection = sf.ui.proTools.selectionGetInSamples(); //Select the desired track sf.ui.proTools.trackSelectByName({ names: [TARGET_TRACK] }); //Set the volume setVolume(); //Select original track again sf.ui.proTools.trackSelectByName({ names: [originalTrackName] }); } main();
- AAndy Daddario @Andy_Daddario
Andrew, thank you so much for this, a complete newbie here.
I'm getting this one error, anything I need to do on my end?
Thanks!......Andy
Andrew Scheps @Andrew_Scheps
I didn’t do any setup routine. I believe this is because you’re not showing I/O in the edit window.
- In reply toAndy_Daddario⬆:
Andrew Scheps @Andrew_Scheps
This should be more robust:
const TARGET_TRACK = "Audio 7"; const VOLUME = '-10'; sf.ui.proTools.appActivateMainWindow(); const checkBoxes = [ { Title: 'I/O', State: "Enable" }, ]; function setCheckboxState(item) { sf.ui.proTools.menuClick({ menuPath: ['View', 'Edit Window Views', item.Title], targetValue: item.State, onError: "Continue", }) } function setupScreen() { //Make sure I/O visible in Edit window checkBoxes.forEach(setCheckboxState); } function setVolume() { sf.ui.proTools.mainWindow.invalidate(); if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value != 'open') sf.ui.proTools.selectedTrack.outputWindowButton.elementClick(); var win = sf.ui.proTools.floatingWindows.allItems.filter(function (w) { return w.children.whoseTitle.is('Volume').exists; })[0]; win.textFields.whoseTitle.is('Volume Numerical').first.elementClick(); sf.keyboard.type({ text: VOLUME }); sf.keyboard.press({ keys: 'enter' }); } function main() { setupScreen(); //Save the name of the originally selected track var originalTrackName = sf.ui.proTools.selectedTrackNames[0]; //Select the desired track sf.ui.proTools.trackSelectByName({ names: [TARGET_TRACK] }); //Set the volume setVolume(); //Select original track again sf.ui.proTools.trackSelectByName({ names: [originalTrackName] }); } main();
- AAndy Daddario @Andy_Daddario
Terrific Andrew, I will give this a try when I'm back to my studio. Thanks so much and appreciate your taking the time to write this. Your script seems very detailed, I have a lot to learn.
Thanks!......Andy
- In reply toAndrew_Scheps⬆:AAndy Daddario @Andy_Daddario
Andrew, it works beautifully, thank you so much!
So now, how and why does it work? (as I try and learn the language). Are the // messages on what each command is doing?
Andrew Scheps @Andrew_Scheps
Hi Andy,
Yes, and line that has
//
in front of it is a comment- AAndy Daddario @Andy_Daddario
Thanks so much for your help with this Andrew, much appreciated!
- In reply toAndrew_Scheps⬆:RRyan Short @Ryan_Short
Hey Andrew, love this code! Just trying to figure out how to make it work for whichever track(s) is selected currently, rather than just the "Audio 7" track specifically.. is that possible? Sorry in advance, only been using for a couple days now... Thank you!
- In reply toChipSloan⬆:Samuel Škubla @Samuel_Skubla
Not script related, but I just found that tapping (not pressing) "Monitor" knob while holding ALT/OPT key will set assigned aster fader to 0dB.
- EIn reply toChipSloan⬆:Enrique Larreal @Enrique_Larreal
Is there a way to do this for all selected tracks?
- SSreejesh Nair @Sreejesh_Nair
This code will prompt for the user value and set it for all the selected tracks
const VOLUME = (sf.interaction.displayDialog({ defaultAnswer: "-6", buttons: ["OK", "Cancel"], defaultButton: "OK", cancelButton: "Cancel", title: ("Volume Setter"), prompt: ("Enter Volume Value"), })).text; function setupScreenAndSetVolume() { // Make sure I/O visible in Edit window and set checkboxes ['I/O'].forEach(title => { sf.ui.proTools.menuClick({ menuPath: ['View', 'Edit Window Views', title], targetValue: "Enable", onError: "Continue", }); }); let outputWindowState = sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value; if (outputWindowState !== "open" && outputWindowState !== "output bypassed active open") { sf.ui.proTools.selectedTrack.trackOutputToggleShow(); } let win = sf.ui.proTools.floatingWindows.allItems.find(w => w.children.whoseTitle.is('Volume').exists); if (win) { win.textFields.whoseTitle.is('Volume Numerical').first.elementClick(); sf.keyboard.type({ text: VOLUME }); sf.keyboard.press({ keys: 'enter' }); } } sf.ui.proTools.appActivateMainWindow() sf.ui.proTools.mainWindow.invalidate(); // Save the names of the originally selected tracks and get all selected tracks let originalTrackNames = sf.ui.proTools.selectedTrackNames; let selectedTracks = sf.ui.proTools.selectedTrackHeaders; // Loop through each selected track and set the volume selectedTracks.forEach(trackHeader => { sf.ui.proTools.trackSelectByName({ names: [trackHeader.normalizedTrackName], deselectOthers: true }); setupScreenAndSetVolume(); }); // Select original tracks again sf.ui.proTools.trackSelectByName({ names: originalTrackNames });