Scripting

shaun-toole wrote on 2/1/2017, 11:42 AM

I have never written a script before, but I have a need for one now. I want to put a few seconds of silence between regions in a file.

I looked in the archive and found a discussion about this capability, but no examples. I have also read about the Scripting SDK but cannot find it anywhere. Help in finding the SDK and writing a script to perform this function would be greatly appreciated!

Comments

ReverendLove wrote on 2/8/2017, 7:46 AM

You don't need the Scripting SDK. It was for SF 7 and earlier.
Now there is anything you need on board.
Look at Menu->View->Script Editor or hit Ctrl-Alt-3.
Below Menu->Process->Scripting you can see already installed scripts.
Then you should look for the archived Forum in Sound Forge Scripting.
This archive is http://forum-archive.magix.info/home

shaun-toole wrote on 2/8/2017, 8:21 AM

Thank you for the information about the Scripting SDK. I am still looking for help with a script to put a few seconds of silence between regions of a file.

ReverendLove wrote on 2/8/2017, 9:07 AM

Mm.

By "I have never written a script before,..." do you mean that you have no experience in scripting at all?
You should have basic knowledge of c#, jscript or similar.

For iterating through regions you could use the delivered script "Extract Regions As Files.cs" as a template. It's a c#-script.

Scripting can be very powerful in SF but it is a kind of programming and should only be used for often recurring tasks.

shaun-toole wrote on 2/15/2017, 6:21 AM

I am a coder and know a lot about programming in a variety of languages, but not about scripting in Sound Forge. Is there an object library or any documentation on what commands are available and how to invoke them? What libraries do I need? The functions I want to perform are all available on the Sound Forge menus and are repetitive tasks.

ReverendLove wrote on 2/15/2017, 9:07 AM

Great. In the help file there is a point called 'scripting' and below this 'batch scripting'. In the last one is documented a complete objects' and interfaces' catalogue.

You invoke scripts via tools->scripting->Run Script but you can call them by customized key commands too. And as you're using C# (or wscript's basic, but that's not my cup of tea ;-) ) you can use windows' objects too by using lines like:

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

 

As I understand actually it uses the windows scripting engine and you add the sound forge objects and interfaces via:

using SoundForge;

You create scripts by calling the script editor as mentioned above. In the script editor you can open existing scripts, create new ones, compile them and run them.
As suggested you should open the existing scripts and look how they work. One important note: The difference between markers and regions is that regions are markers with a length > 0 but are markers too in an object's view.

For the the task you memtioned the somehow nearest example is "Extract Regions As Files.cs". It should be in the "script menu" folder inside your sound forge's application folder.

shaun-toole wrote on 2/15/2017, 9:54 AM

Thanks for that info! I will check it out. Probably will return with questions, too.

erick-wagner wrote on 4/8/2018, 7:07 PM

[1] Where is the Sound Forge object model documented? The documentation in the User Manual seems very high level.

[2] When the documentation in the User Manual says you can write scripts in VBScript. Is this referring to standalone .vbs files that execute within WScript? Does MAGIX provide any VBScript examples?

shaun-toole wrote on 4/9/2018, 8:24 AM

1. The best answer is to look in the Sound Forge Pro Online Help for "Scripting Overview." Links there for Hierarchy, Classes, Structures, etc.

2. Not sure, but I think you need to run the script in Sound Forge. Maybe I don't understand the question.

There's a link in the Overview called Sound Forge Script Development Kit, but it just leads to some sales literature about Vegas. It would be nice to know what's in the Kit.