Trying to modify 'save regions as files' script to run autotrimcrop

porkchop wrote on 5/18/2023, 9:11 AM

version 13.

I've added these lines just before try { int iPreset in the hopes of generating markers for the rest of the script to use.

 SfAudioSelection frange = new SfAudioSelection(0, app.CurrentFile.Length);
    file.DoEffect("Process.AutoTrimCrop", "ANSWER01", frange, EffectOptions.EffectOnly | EffectOptions.WaitForDoneOrCancel);

however, nothing happens. I've tried preselecting the entire file, but still the only thing that shows is a message that there are no markers.

If I run auto trim prior, then the 'save regions' script works fine. I've looked and looked and tried to borrow from other scripts; I can't get it to work.

What am I missing, here?

Comments

SP. wrote on 5/18/2023, 9:59 AM

@porkchop Does the AutoTrimCrop preset with the name "ANSWER01" exist? If not, try something like "[Sys] Phrase concatenator 1" or create the preset "ANSWER01" before running the script. .

There was also a problem some time ago, that the preset couldn't be loaded, even if it existed. This problem could be solved by changing EffectOptions.EffectOnly to EffectOptions.DialogFirst. Run the script, create the preset and save it. The change it back to EffectOptions.DialogFirst. It seemed that the Sound Forge script is looking at the wrong place for presets. The problem appeared for me in later versions of Sound Forge 15. Not sure if this will help for version 13. Maybe this problem doesn't exist in your version.

porkchop wrote on 5/18/2023, 11:08 AM

Thanks so much for your reply.

Yes, it exists. And it runs as expected on it's own. I tried your suggestion with 'DialogFirst' and then it works.

I also created a new preset, changed the script to the new preset and set 'EffectOnly', and I'm back to square 1.

What I notice is that the entire clip is selected when the dialog comes up.

When I run the script, nothing get's selected.

what command is there the selects the entire clip. Perhaps if I run that first, it'll work.

 

SP. wrote on 5/18/2023, 2:02 PM

@porkchop The following line selects the complete audio file, but of course there are multiple ways to do it.

 //remove all silence with the Auto Trim/Crop function and export the resulting regions
   app.CurrentFile.DoEffect("Process.AutoTrimCrop", "[Sys] Phrase concatenator 1", new SfAudioSelection(0, -1), EffectOptions.EffectOnly | EffectOptions.WaitForDoneOrCancel);

porkchop wrote on 5/18/2023, 11:06 PM

Well, I thought your thing was just to make a selection so, I put it at the 'start here' note of the script. Then it started working. I removed the one that was after all the file and directory checks and it now works great with my preset.

Thanks for the assist.

xman_charl wrote on 5/21/2023, 1:46 PM

works very well