Community Forums Archive

Go Back

Subject:Save.As Names
Posted by: GPD
Date:10/11/2006 9:20:59 PM

When using the following:

file.SaveAs("Knownfilename.wav", ".wav", "Default Template", RenderOptions.RenderOnly);
file.WaitForDoneOrCancel();
file.Close(CloseOptions.DiscardChanges);

is it possible to have the file name ("Knownfiename.wav") be pulled from variables defined in the namespace? Is it possible to combine/CONCATERNATE several variables along with text stings?

something like:

color = 1
size = 2

defined as variables in namespace that then becomes named: "sound color 1 size 2.wav" using Save.As??


Subject:RE: Save.As Names
Reply by: GPD
Date:10/11/2006 10:38:26 PM

This code:

__________________________________________________________


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

public class EntryPoint
{
public void Begin(IScriptableApp app)
{
SfWaveFormat wfx = new SfWaveFormat(44100, 24, 1, false);
ISfFileHost file = app.NewFile(wfx, false);

int cSeconds = 1 ; // total length
double norm = 1.0 / file.SampleRate ; // normalize period


Int64 cTotal = cSeconds * file.SampleRate;
int cBuffer = 4096;
double[] data = new double[cBuffer * file.Channels];
ISfWriteAudioStream was = file.OpenWriteAudioStream(file.SampleType, file.Channels, 0);


for (Int64 cs = 0; cs < cTotal; cs += cBuffer)
{
if (cTotal < cs)
cBuffer -= (int)(cs - cTotal);

for (int ix = 0; ix < cBuffer; ++ix)
{
double t = norm*(cs+ix) ; // one sample time increment
data[ix] = (double) 2*Math.Pow((t) , 2) -1 ; // Function
}

was.Append(data, 0, (int)(cTotal - cs), SfSampleType.WavDouble);
}

file.WriteAudio(file.Window.EditRegion, was);
//app.DoMenu("Process.Normalize", true); //normalize
//file.Close(SoundForge.CloseOptions.QuerySaveIfChanged);
file.SaveAs("Knownfilename.wav", ".wav", "Default Template", RenderOptions.AndClose);
file.WaitForDoneOrCancel();


}

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

_________________________________________________________

gives the following error message:

"The file being rendered has exceeded the maximum size allowed for the slected format."

Can you tell what the problem is? If I comment out the Save.As line, and then save manually everything is fine...

Subject:RE: Save.As Names
Reply by: GPD
Date:10/12/2006 12:22:06 PM

If I change:

file.SaveAs("Knownfilename.wav", ".wav", "Default Template", RenderOptions.AndClose);

to

file.SaveAs("Knownfilename.wav", ISfFileHost.SaveFormat.Guid, "Default Template", RenderOptions.AndClose);

I get the following error:

Compiler error 0x80004005 on Line 41,35 : An object reference is required for the nonstatic field, method, or property 'SoundForge.ISfFileHost.SaveFormat'

Help?

Subject:RE: Save.As Names
Reply by: _TJ
Date:10/13/2006 1:48:09 PM

ISfFileHost is an inteface, what you need to use is an object (i.e. variable) that has that inferface.

so the code would be:

file.SaveAs("Knownfilename.wav", file.SaveFormat.Guid, "Default Template", RenderOptions.AndClose);

tj

Subject:RE: Save.As Names
Reply by: GPD
Date:10/17/2006 5:25:44 PM

Thanks TJ.

With this change, I am back to my other error:

"The file being rendered has exceeded the maximum size allowed for the slected format."

Any ideas?

Subject:RE: Save.As Names
Reply by: _TJ
Date:10/20/2006 3:54:56 PM

I presume that that error message is accurate. That you have, in fact, exceeded the maximum allowable size for the format. (it may be that you are just out of disc space on the drive you are saving to).

So, the only thing I could suggest it to try a different format.

tj

Go Back