Click here to Skip to main content
15,923,168 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to make a .exe 64 Bit useable Pin
Mschauder7-Feb-11 2:36
Mschauder7-Feb-11 2:36 
Answer- SOLVED -: How to make a .exe 64 Bit useable Pin
Mschauder6-Feb-11 22:15
Mschauder6-Feb-11 22:15 
GeneralRe: - SOLVED -: How to make a .exe 64 Bit useable Pin
Thomas Krojer7-Feb-11 1:27
Thomas Krojer7-Feb-11 1:27 
GeneralRe: - SOLVED -: How to make a .exe 64 Bit useable Pin
Dave Kreskowiak7-Feb-11 2:05
mveDave Kreskowiak7-Feb-11 2:05 
Questioni want to learn MVC2 Pin
S.Aijaz6-Feb-11 20:36
S.Aijaz6-Feb-11 20:36 
AnswerRe: i want to learn MVC2 Pin
Pravin Patil, Mumbai6-Feb-11 20:46
Pravin Patil, Mumbai6-Feb-11 20:46 
AnswerRe: i want to learn MVC2 Pin
Abhinav S6-Feb-11 21:20
Abhinav S6-Feb-11 21:20 
GeneralRe: i want to learn MVC2 Pin
S.Aijaz10-Feb-11 18:09
S.Aijaz10-Feb-11 18:09 
AnswerRe: i want to learn MVC2 Pin
RobCroll7-Feb-11 1:34
RobCroll7-Feb-11 1:34 
Questionquestion on code and video Pin
Rei ho6-Feb-11 18:47
Rei ho6-Feb-11 18:47 
AnswerRe: question on code and video Pin
Abhinav S6-Feb-11 20:33
Abhinav S6-Feb-11 20:33 
GeneralRe: question on code and video Pin
Rei ho6-Feb-11 21:09
Rei ho6-Feb-11 21:09 
QuestionSmall Dialogs - How Small Can I Go ?? Pin
iltallman6-Feb-11 9:12
iltallman6-Feb-11 9:12 
AnswerRe: Small Dialogs - How Small Can I Go ?? Pin
dan!sh 6-Feb-11 10:03
professional dan!sh 6-Feb-11 10:03 
AnswerRe: Small Dialogs - How Small Can I Go ?? [modified] Pin
RobCroll7-Feb-11 1:52
RobCroll7-Feb-11 1:52 
GeneralRe: Small Dialogs - How Small Can I Go ?? Pin
iltallman7-Feb-11 12:31
iltallman7-Feb-11 12:31 
AnswerRe: Small Dialogs - How Small Can I Go ?? Pin
#realJSOP7-Feb-11 2:33
professional#realJSOP7-Feb-11 2:33 
QuestionC# Object reference not set to an instance of an object Pin
LAPEC6-Feb-11 8:45
LAPEC6-Feb-11 8:45 
AnswerRe: C# Object reference not set to an instance of an object Pin
fjdiewornncalwe6-Feb-11 8:56
professionalfjdiewornncalwe6-Feb-11 8:56 
GeneralRe: C# Object reference not set to an instance of an object Pin
LAPEC6-Feb-11 10:31
LAPEC6-Feb-11 10:31 
GeneralRe: C# Object reference not set to an instance of an object Pin
RobCroll7-Feb-11 2:12
RobCroll7-Feb-11 2:12 
GeneralRe: C# Object reference not set to an instance of an object Pin
Rob Philpott7-Feb-11 3:51
Rob Philpott7-Feb-11 3:51 
AnswerRe: C# Object reference not set to an instance of an object Pin
Luc Pattyn6-Feb-11 9:15
sitebuilderLuc Pattyn6-Feb-11 9:15 
AnswerRe: C# Object reference not set to an instance of an object Pin
dan!sh 6-Feb-11 10:07
professional dan!sh 6-Feb-11 10:07 
QuestionObtain the path and save the file. Pin
sososm6-Feb-11 2:45
sososm6-Feb-11 2:45 
Hy everyone,

I am desperate, a newbie to programming and I really need your help guys. I work a lot with sound files in Sound Forge 10 and I started to use the included C# scripts, but I don't know how to personalize them for my personal use. If somebody can help me I'll appreciate it very much.

Here is what I want my script to do:
1. - with the file open, get the path and name of the file.
2. - render the file in the same format to a specified location with the name from an .xml file in the same location and
the same name as the sound file ex:
The name of the opened file is : oldies_20110206144516.wav there is a oldies_20110206144516.xml also,
and I want to replace "oldies" with <artist> from the xml file, insert a character between date and time like
20110206144516 to 2011-02-06_14.45.16 then add two more fields from xml; final name should be something like
<artist>_2011-02-06_14.45.16_<song>-<album>.wav
3. - Close the opened file without saving and without confirmation.

Here is a sample script from sound forge:
______________________________________________________________________________
/* =======================================================================================================
* Script Name: Normalize and Render to Multiple Formats
* Description: This script applies an effect the open file and renders it to each of the given formats.
*
* Initial State: Run with one file open and the Script Editor visible (Menu: View, Script Editor)
*
* Parameters (Args):
* Dir - the directory to render the file to - DEFAULT: prompts user
* fx - the effect to apply - DEFAULT: Normalize
* preset - the preset to use for the given effect - DEFAULT: Maximize peak values
*
* Output: The rendered file names and the format used
*
* ==================================================================================================== */

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

//Run with a file open and the Script Editor visible (Menu: View, Script Editor)
//BEHAVIOR:
//- Normalize to maximize peak value
//- If needed, prompts for a target folder
//- Saves the file to one or more formats
//NOTE: Look for MODIFY HERE to quickly update the Script Args with your own preferences

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

//start MODIFY HERE -------------------------
// the array called outputs stores the file formats used for rendering
//NOTE: some file formats share extensions (WAV) (MPG)
// For MainConcept MPEG-1 use this : "6529C198-A432-409f-8A91-3F62198B0E1A|Default Template"
// For Scott Studio WAV use this: "D284C499-FE95-11d3-BB48-0050DA1A5B06|Default Template"

string[] outputs = new string[] {
".pca|Default Template",
".wma|64 Kbps Stereo Music",
// ".mp3|192 Kbps, CD Transparent Audio", //Commented out because MP3 fails until it's registered.
};

string szDir = GETARG("Dir", @""); //type a default output folder between the quotes
string szPlug = GETARG("fx", "Normalize"); //change the effect here
string szPreset = GETARG("preset", "Maximize peak value"); //change the preset for the effect here

// GETARG is a function that defines the default script settings. You can use the Script Args field to over-ride
// the values within GETARG().
// Example: To over-ride GETARG(Key, valueA), type Key=valueB in the Script Args field.
// Use an ampersand (&) to separate different Script Args: KeyOne=valueB&KeyTwo=valueC

//Example Script Args: Dir=f:\Media&fx=Insert Silence&preset=[Sys] 1 second at end of file

//end MODIFY HERE -------------------------

ISfFileHost file = app.CurrentFile;
if (null == file)
return "No files are open. Script canceled.";


// make sure that the directory exists...
if (szDir == null || szDir.Length <= 0)
szDir = PromptForPath("C:\\");
if (szDir == null || szDir.Length <= 0)
return "No output directory. Script canceled.";

ISfRendererList rends = app.Renderers; // this can take a while, so do it before we show the dialog.

Directory.CreateDirectory(szDir);

// ok, now do the deed.

try
{
file.DoEffect(szPlug, szPreset,
new SfAudioSelection(0, file.Length),
EffectOptions.EffectOnly | EffectOptions.WaitForDoneOrCancel);
} catch(Exception)
{
return "Normalize did not complete, script canceled.";
}

string szBase = file.Window.Title;

DPF("Start Rendering... ");
foreach (string output in outputs)
{

string[] fmt = output.Split(new char[]{'|',';'},2);
if (fmt.Length != 2)
{
DPF("'{0}' is not a valid render format specifier - use \"<renderer name>|<preset name>\" ", output);
continue;
}

// find the renderer
//
ISfRenderer rend = null;
if (fmt[0].StartsWith("."))
rend = app.FindRenderer(null, fmt[0]);
else
rend = app.FindRenderer(fmt[0], null);
if (null == rend)
{
DPF("renderer for type {0} not found - skipping to next", fmt[0]);
continue;
}

// determine if the preset is a string or an integer
//
object vPreset = fmt[1];
try {
int iPreset = int.Parse(fmt[1]);
vPreset = iPreset;
} catch (FormatException) {}

string szName = String.Format("{0}-({1}).{2}", szBase, fmt[1], rend.Extension);
DPF("rendering {0}", szName);
string szFilename = Path.Combine(szDir, szName);
DPF(" ~ {0}", szFilename);

DPF(rend.Guid + " " + vPreset + " '" + szDir + "'");

// now, render the file
//
file.RenderAs(szFilename, rend.Guid, vPreset, null, RenderOptions.RenderOnly);
SfStatus result = file.WaitForDoneOrCancel();
if (result != SfStatus.Success)
continue;

} // foreach

return null;
}

public string PromptForPath(string szDir) {

FolderBrowserDialog dlg = new FolderBrowserDialog();

dlg.Description = "Select folder for rendered files:";
if (null != szDir && "" != szDir)
dlg.SelectedPath = szDir;
else
dlg.SelectedPath = @"C:\";
dlg.ShowNewFolderButton = true;
DialogResult res = dlg.ShowDialog();
if (res == DialogResult.OK)
return dlg.SelectedPath;
return null;
}

public void FromSoundForge(IScriptableApp app) {
ForgeApp = app; //execution begins here
app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
string msg = Begin(app);
app.SetStatusText(msg != null ? msg : 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, object o) { ForgeApp.OutputText(String.Format(fmt,o)); }
public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); }
public static void DPF(string fmt, object o, object o2, object o3) { ForgeApp.OutputText(String.Format(fmt,o,o2,o3)); }
public static string GETARG(string k, string d) { string val = Script.Args.ValueOf(k); if (val == null || val.Length == 0) val = d; return val; }
public static int GETARG(string k, int d) { string s = Script.Args.ValueOf(k); if (s == null || s.Length == 0) return d; else return Script.Args.AsInt(k); }
public static bool GETARG(string k, bool d) { string s = Script.Args.ValueOf(k); if (s == null || s.Length == 0) return d; else return Script.Args.AsBool(k); }
} //EntryPoint

_______________________________________________________________________________

Thank you in advance for your time.
1000000xxxxxxx

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.