Community Forums Archive

Go Back

Subject:Do I need scripts?
Posted by: Robin_Hood
Date:12/3/2005 2:07:51 PM

I'm wondering whether I need 'scripts' or whether it's possible to do what I want to do without them. Don't really know much about them, but I did a little bit of Lingo in a Web Design HNC course a few years ago, so I'm assuming that scripts are something similar.

Basically, I've used SoundForge 8.0 File < Extract Audio From CD to create .wav + .sfk copies of a few CDs. My intention is to convert the tracks in them into individual files (I've already done this bit, with the Convert Markers Into Regions command &c). Then I want to do some standard editing on them, so I can convert them into .shn files and use a WinAmp player for them on my PC.

The editing that I need to do in SoundForge is designed to avoid a sort of 'thwacking' noise that would otherwise occur whenever a new track starts. I've found out that the required edits are as follows:

Convert to 32 bit .wav file (actually, I do this bit on the whole CD file, before converting markers into regions)

and then

Remove DC Offset about 3 times
Select first 1/10th of a second of the file
Fade in
Go to Start
Add 0.5 seconds silence at cursor
Select final 1/10th of a second
Fade out
Go to End
Add 0.5 seconds silence at cursor
Save As 16 bit .wav file without metadata

So, do I need scripts to do this?

I'm able to describe a standard series of keystrokes that can accomplish the task. If I knew of a way to 'record' these keystrokes, which can be the same for every track, and repeat the same set of keystrokes for each track, I would do so. But I don't know how to do that.

I've tried using the SoundForge 'Batch Converter'. However, I can't find anything in the Batch Converter that would accomplish the bit about selecting the first and final 1/10th of a second. When I tried to use the Batch Converter, I got a 'fade in' and 'fade out' over the whole of the track, rather than just 1/10th of a second.

Subject:RE: Do I need scripts?
Reply by: jetdv
Date:12/3/2005 5:46:14 PM

Scripts only automate the things you can do manually. So... No, you don't "NEED" scripts. However, scripts can automate processes so that you don't have to do it manually and spend a lot of time doing so. Instead, it can perform all the operations FOR you in a very short period of time. However, you DO need to have a script that performs your desired operation(s).

Subject:RE: Do I need scripts?
Reply by: _TJ
Date:12/3/2005 10:13:32 PM

You can do all of this except the 1/10 second fade with the batch converter.
So, I guess the answer is - yes - you need a to use a script if you want to automate all of this.

You are correct that scripts in Sound Forge are much like web scripts.

Sound Forge ships with a standard script called CropAndFade.cs, this script shows how to add fades to the window, although it won't do exactly what you want unless you first select the whole file.

Also it uses a 1/4 (.25) second fade size rather than 1/10 second. But you can easily change that. Just open up that script in the Script Editor, scroll down to line 25 or so, and change (.25) to (.10). Then select the whole file and run the script.

Ripping from a CD will not introduce any DC offset, so there should be no need to remove it. Also,adding silence and fading the edges are the sort of edits that can be safely done on 16 bit data without any loss of signal. So converting the files to 32 bit is not really necessary. Of course, it sounds like the files are already 32 bits . But if you do more of this in the future, you can save yourself some steps by skipping the 32 bit conversion and DC offset steps.

On the other hand, if you want to invest some time in learning Sound Forge scripting, you can do ALL of this (including ripping the CD) in a single script.

tj

Message last edited on12/3/2005 10:54:33 PM by_TJ.
Subject:RE: Do I need scripts?
Reply by: _TJ
Date:12/3/2005 11:12:29 PM

Here's a script that does what you describe using the DoMenuAndWait method.

This is not the most efficient or powerful way to do things, but it's often the easiest way. The only complication is that in this case, we need to select the first 1/10 of a second of the file, and then later, select that last 1/10, and there is no way to do that using DoMenuAndWait, so instead we have to use some properties of the ActiveWindow to move the cursor and change the selection size. Then a subsequent call to DoMenuAndWait will process the selection.

Also, since there happens to be a method to insert silence, I used that method.

The DoMenuAndWait() method makes for scripts are a straightforward transcription of a sequence of menu operations, They can be very easy to write,
but usually require a certain amount of user interaction. In this case, the user has to pick a DCOffset preset, and choose the correct output format in Save As.


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

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

app.DoMenuAndWait("Process: DCOffset", false);
app.DoMenuAndWait("Process: DCOffset", true); // use same settings as last time
app.DoMenuAndWait("Process: DCOffset", true); // use same settings as last time

// calculate 1/10 of a second and 1/2 second in samples, we will need these later
Int64 ccFade = app.ActiveWindow.File.SecondsToPosition(0.10);
Int64 ccSilence = app.ActiveWindow.File.SecondsToPosition(0.5);

// move the cursor to the start of the window
app.ActiveWindow.Cursor = 0;

// select 1/10 of a second.
app.ActiveWindow.SelectionLength = ccFade;

// fade in
app.DoMenuAndWait("Process: Fade In", false);

// insert 1/2 second of silence at the beginning of the file.
app.ActiveWindow.File.InsertSilence(0, ccSilence);

// move the cursor to the end of the file.
app.ActiveWindow.Cursor = app.ActiveWindow.File.Length;

// select 1/10 of a second BEFORE the cursor
app.ActiveWindow.SelectionLength = -ccFade;

// fade out
app.DoMenuAndWait("Process: Fade Out", false);

// insert 1/2 second of silence at the end of the file.
app.ActiveWindow.File.InsertSilence(app.ActiveWindow.File.Length, ccSilence);

// bring up the Save As dialog.
app.DoMenuAndWait("File: Save As", false);
}

public void FromSoundForge(IScriptableApp app) {
ForgeApp = app; //execution begins here
app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
Begin(app);
app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name));
}
public static IScriptableApp ForgeApp = null;
} //EntryPoint

Message last edited on12/3/2005 11:35:22 PM by_TJ.
Subject:RE: Do I need scripts?
Reply by: Robin_Hood
Date:12/9/2005 5:07:18 AM

Thank you. Looks pretty complicated, but perhaps that is necessary. I hope it didn't take too long for you to write.

I'll get down to examining it closely in a few days.

Subject:RE: Do I need scripts?
Reply by: Robin_Hood
Date:12/9/2005 5:11:58 AM

Thanks for the tip about 'Crop & Fade'.

In practice, I find that I *do* need DC Offset, as it's the only way to stop that funny sound in between tracks when playing .shn files with WinAmp.

I hope some day, Sony include the Selection command in their batch converter.

Go Back