Community Forums Archive

Go Back

Subject:How to work with selected regions?
Posted by: Kit
Date:5/1/2011 4:07:32 AM

I know how to process all the regions in the active file but I don't know how to process just the selected regions. How can I do that, or alternatively tell the script to process, say the next three regions occurring on the timeline after the current cursor position? Thanks

Kit

Subject:RE: How to work with selected regions?
Reply by: Kit
Date:5/1/2011 7:23:09 AM

I think I figured it out. The following test seems to work - it successfully ignores a partially selected region:


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

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

/*begin here*/
String n;
int i = 0;

ISfDataWnd wnd = app.ActiveWindow;
if (null == wnd)
return;

SfAudioSelection asel = wnd.Selection;
if (asel.ccLength == 0)
{
MessageBox.Show("Select some regions to rename","Error: no regions found!");
return;
}

ISfFileHost file = app.CurrentFile;
Int64 ccSelection = app.ActiveWindow.SelectionLength;

foreach (SfAudioMarker mk in file.Markers)

{
i++;
n = i.ToString();
if (mk.Start > asel.Start && asel.Length - mk.Length > mk.Start )
mk.Name = "Test" + n;
}
}

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;
public static void DPF(string sz) { ForgeApp.OutputText(sz); }
public static void DPF(string fmt, params object [] args) { ForgeApp.OutputText(String.Format(fmt, args)); }
} //EntryPoint

Message last edited on5/1/2011 7:23:24 AM byKit.

Go Back