Volume automation - Sound Forge 18 Pro

Paul-Fegan wrote on 5/24/2025, 7:46 AM

Is it possible to tie automation to a hotkey? I want to be able to select a breath-intake in voiceover audio, then press a key to lower the volume by, say, -8 dB. In REAPER, I can do this via user-defined actions, but I don't see a way to do it in Sound Forge and I'm not familiar with scripting. I have a hotkey tied to Mute, which is great, but I'd love to tie another hotkey to lower the volume, if needs be. Many thanks.

Comments

rraud wrote on 5/24/2025, 10:40 AM

Hi @Paul-Fegan, You can draw a volume envelope, however envelope points cannot be added automatically (like in Vegas). . To initiate the volume envelope plug-in, press the 'V' key. If you wish to save the volume envelope and continue later, save as an Sound Forge Pro Project file <.frg>. To write or overwrite the file, save as in your preferred format.
This volume envelope plug-in will only work in the timeline chainer mode (not 'Fx Favorites')

Paul-Fegan wrote on 5/24/2025, 11:36 AM

Thanks, Rick. I appreciate that's one way of doing it, but drawing envelope points for every breath might slow me down a bit. Since I last posted, I bound a hotkey to the Volume window. Everytime I open it, it remembers the last setting I used (I'm using the same volume drop for every breath), so at least it's just a two-click operation now: hotkey and then RETURN. Could be worse, so it'll do me for now. I was kind of hoping one key could do both... but maybe I just need to stop being lazy. 😄

Thanks a mill for your quick response.

SP. wrote on 5/24/2025, 11:39 AM

@Paul-Fegan This script calls a preset named Reduce Volume -8 dB in the Volume effect and applies it to a selection. If you save this in a text file with the file ending cs to your Sound Forge script folder and rescan the folder you can add a shortcut to this script inside the Customize Keyboard options. Then it's only a single button press instead of hotkey and Return.

For it to work, you need to save a preset with your desired settings and the name mentioned above in the Volume Effect. Of course, you can simply change the name in the script if you want to call it something different.

/* ==========================================================================
 *    Script Name: Reduce Volume -8 dB
 *    Description: This script takes a selection in an open file and applies the Volume effect preset named Reduce Volume -8 dB
 *
 *    Initial State: A file open with a selection
 *
 *    Output: Done with success or failure
 *
 * ========================================================================== */

using System;
using System.IO;
using System.Windows.Forms;
using SoundForge;

//BEHAVIOR: Takes a selection in an open file and applies the Volume effect preset named Reduce Volume -8 dB

public class EntryPoint {
public string Begin(IScriptableApp app) {

   ISfDataWnd wnd = app.ActiveWindow;
   if (null == wnd)
      return "Open a file before running this script.";

   SfAudioSelection asel = wnd.Selection;
   if (asel.ccLength == 0)
   {
      DPF("No selection in the active window - quitting");
      return "Choose a selection before running the script.";
   }

   ISfFileHost file = wnd.File;

   bool fCancel = false;
   int idUndo = file.BeginUndo("Reduce Volume -8 dB");

   file.DoEffect("Volume", "Reduce Volume -8 dB", new SfAudioSelection(wnd.Selection.ccStart, wnd.Selection.ccLength), EffectOptions.EffectOnly);
   
   SfStatus result = file.WaitForDoneOrCancel();
   if (result != SfStatus.Success)
      fCancel = true;   

   file.EndUndo(idUndo, fCancel);
   DPF("Done - {0}", fCancel ? "failed and rewound changes" : "success");
   if(fCancel)
      return "Script canceled.";
   else
      return null;
}

public void FromSoundForge(IScriptableApp app) {
   ForgeApp = app; //execution begins here
   app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
   string msg = Begin(app);
   app.SetStatusText(msg != null ? msg : String.Format("Script '{0}' is done.", Script.Name));
}
public static IScriptableApp ForgeApp = null;
public static void DPF(string sz) { ForgeApp.OutputText(sz); }
public static void DPF(string fmt, object o) { ForgeApp.OutputText(String.Format(fmt,o)); }
public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); }
public static void DPF(string fmt, object o, object o2, object o3) { ForgeApp.OutputText(String.Format(fmt,o,o2,o3)); }
} //EntryPoint

 

Paul-Fegan wrote on 5/24/2025, 2:37 PM

Hi SP, wow, this is exactly what I was hoping for. However, I'm having trouble with it. Here's what I've done:

1) copied exactly what's in the grey box above into a TXT file and renamed that as a .CS file

2) added it to SF's scripts folder

3) re-scanned my scripts in SF 18

4) the script showed up fine in the list

5) created a preset in Process > Volume called "Reduce Volume -8 dB" and set the volume parameter for -8 dB

6) bound a hotkey to the script (which I've also called "Reduce Volume -8 dB" — does it matter what I call it?)

7) selected a breath and pressed the hotkey; it didn't work

8) selected a breath and tried to run the script from the scripts menu; that didn't work either

Any idea what I might be doing wrong?

Many thanks. If I can get this working, it will make such a difference to my work flow.

SP. wrote on 5/24/2025, 3:17 PM

@Paul-Fegan I tested it in SF 18 and you are correct. This is a bug in newer SF versions. Please change the EffectOptions at the end of line 37 from

file.DoEffect("Volume", "Reduce Volume -8 dB", new SfAudioSelection(wnd.Selection.ccStart, wnd.Selection.ccLength), EffectOptions.EffectOnly);

to

file.DoEffect("Volume", "Reduce Volume -8 dB", new SfAudioSelection(wnd.Selection.ccStart, wnd.Selection.ccLength), EffectOptions.DialogFirst);

and save the file.

If you now press the hotkey, the Volume Effect window opens first before the effect is applied. As you can see, the preset doesn't exist here even if you created it before. This is the bug I mentioned. Please create the preset Reduce Volume -8 dB in this window and save it. After that you can change EffectOptions.DialogFirst back to EffectOptions.EffectOnly and from now on it should run fine.

Paul-Fegan wrote on 5/24/2025, 3:36 PM

SP, you're a genius! I followed the steps to the letter and it wasn't working at first. In fact, the Volume process wasn't working at all, no matter what preset I used. Then I clicked on a different audio file that was open on the workspace and tried it there and it worked! When I returned to my original file, it was suddenly working there, too. Seriously, this has vastly improved my work flow and I am so grateful to you. Thank you very much.

SP. wrote on 5/24/2025, 3:49 PM

@Paul-Fegan Excellent! Yeah, SF18 seems to be somewhat sensitive. I also got an error message pop-up after changing EffectOptions.DialogFirst back to EffectOptions.EffectOnly and running the script the first time.

The only problem is, if you want to edit the preset you'll need to change the script so that the dialog is visible again and edit and save the preset there. I personally use SF12 and there this problem doesn't exist. It seems like something changed in newer versions and presets created by the user are stored in a different location than presets looked up by scripts.