Community Forums Archive

Go Back

Subject:Simple Script Help - move cursor back 350ms
Posted by: Blakus
Date:4/20/2013 6:24:33 AM

Hi there,

I'm right in the middle of a massive amount of sample editing, and I need a script that sees where my cursor is, and then simply moves it backwards a specified time, i.e. 350ms.

If possible it would be even more excellent if it could then select from this new cursor location to the next silence and then create a region, but that's probably asking too much haha!

Thank you in advance for any help!
Blake

Subject:RE: Simple Script Help - move cursor back 350ms
Reply by: roblesinge
Date:4/21/2013 2:38:07 PM

Is it always a fixed time, or do you need to be able to input the time on each execution of the script?

Rob.

Subject:RE: Simple Script Help - move cursor back 350ms
Reply by: roblesinge
Date:4/21/2013 3:55:01 PM

This takes you back 350ms from the current cursor position. You are correct that finding the next silence will be a bit of a challenge.

Rob.


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

public class EntryPoint
{
public void Begin(IScriptableApp app)
{
ISfDataWnd wnd = app.ActiveWindow;
long currentPos = wnd.Cursor;
long secToSamp = app.CurrentFile.SecondsToPosition(.350);
wnd.SetCursorAndScroll(currentPos - secToSamp, DataWndScrollTo.NoMove);
}

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

Subject:RE: Simple Script Help - move cursor back 350ms
Reply by: Blakus
Date:4/21/2013 7:24:28 PM

Wow thank you so much!! It works perfectly :)

Go Back