Subject:How to set the mp3 ID3 data in Script?
Date:4/1/2013 8:30:51 PM
I am using a script, which I believe is modified from "Save Region As Files". The script is C# and saves each region as an mp3 file. During this process; I would like to use the region name as the Title of the mp3 tag. If possible; I'd also set the track number / total tracks values.
The rest of the ID3 values, such as artist name and album name can be set via the preset template.
How can this be done?
This is a screen shot sample from Sound Forge; with the named regions:
http://www.jeffryhouser.com/images/temp/soundforgeregions.png
This is the Script:
/* =======================================================================================================
* Script Name: Save Regions as Files
* Description: This script iterates through regions in the open file, renders the region to a specified
* format, and saves the rendered file to a specified location.
*
* Initial State: Run with a file open that contains regions.
*
* Parameters (Args):
* type - the extension of the format to render regions to - DEFAULT: .pca
* preset - the name of the template to use for rendering - DEFAULT: prompt user
* dir - the directory the files should be rendered to - DEFAULT: c:\media\rips
*
* Output: The queueing up of the file and the path name of the file
*
* ==================================================================================================== */
using System;
using System.IO;
using System.Windows.Forms;
using SoundForge;
//Run with a file that contains regions
//Iterates through the regions, renders to MP3 and saves the rendered file to c:\media\rip
//Scan the file for MODIFY HERE to see how to quickly customize for your own use
public class EntryPoint {
public string Begin(IScriptableApp app) {
//start MODIFY HERE-----------------------------------------------
string szType = GETARG("type", ".mp3"); //choose any valid extension: .avi .wav .w64 .mpg .mp3 .wma .mov .rm .aif .ogg .raw .au .dig .ivc .vox .pca
object vPreset = GETARG("preset", ""); //put the name of the template between the quotes, or leave blank to pop the Template chooser.
string szDir = GETARG("dir", ""); //hardcode a target path 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: type=.wav&dir=f:\RegionFiles
//end MODIFY HERE -----------------------------------
ISfFileHost file = app.CurrentFile;
if (null == file)
return "Open a file containing regions before running this script. Script stopped.";
if (null == file.Markers || file.Markers.Count <= 0)
return "The file does not have any markers.";
bool showMsg = true;
if (szDir == null || szDir.Length <= 0)
{
szDir = SfHelpers.ChooseDirectory("Select the target folder for saved files:", @"C:\");
showMsg = false;
}
if (szDir == null || szDir.Length <= 0)
return "no output directory";
//make sure the directory exists
if(!Path.IsPathRooted(szDir))
{
string szBase2 = Path.GetDirectoryName(file.Filename);
szDir = Path.Combine(szBase2, szDir);
}
Directory.CreateDirectory(szDir);
ISfRenderer rend = null;
if (szType.StartsWith("."))
rend = app.FindRenderer(null, szType);
else
rend = app.FindRenderer(szType, null);
if (null == rend)
return String.Format("renderer for {0} not found.", szType);
// if the preset parses as a valid integer, then use it as such, otherwise assume it's a string.
try {
int iPreset = int.Parse((string)vPreset);
vPreset = iPreset;
} catch (FormatException) {}
ISfGenericPreset template = null;
if ((string)vPreset != "")
template = rend.GetTemplate(vPreset);
else
template = rend.ChooseTemplate((IntPtr)null, vPreset);
if (null == template)
return "Template not found. Script stopped.";
string szBase = file.Window.Title;
// JH adding this counter in order to keep track of count for naming files which is not always contigious when having markers and regions in file
int counter = 1;
foreach (SfAudioMarker mk in file.Markers)
{
if (mk.Length <= 0)
continue;
// string szName = String.Format("{0:d2}-{1}-({2}).{3}", mk.Ident, szBase, mk.Name, rend.Extension);
string szName = String.Format("{0}-{1}-{2}.{3}", counter.ToString("00"), szBase, mk.Name, rend.Extension);
szName = SfHelpers.CleanForFilename(szName);
DPF("Queueing: '{0}'", szName);
string szFullName = Path.Combine(szDir, szName);
if (File.Exists(szFullName))
File.Delete(szFullName);
SfAudioSelection range = new SfAudioSelection(mk.Start, mk.Length);
// **********************
// Presumably somehow we want to change the template name here; but I couldn't
// figure out how
// ******************
file.RenderAs(szFullName, rend.Guid, template, range, RenderOptions.RenderOnly);
DPF("Path: '{0}'", szFullName);
counter++;
}
if(showMsg)
MessageBox.Show(String.Format("Files are saving to: {0}", szDir), "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
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
Message last edited on4/2/2013 2:18:25 PM
byReboog711.
|
Subject:RE: How to set the mp3 ID3 data in Script?
Date:4/2/2013 8:35:36 AM
Make sure you use CODE tags when you post code into the forums. Does this script do what you want it to do?
In regards to your track number out of the total number of tracks issue, can we assume that each file you apply this script to will be one album, or will we need to reset the counter at some point? Your statement about this not always being contiguous is what is throwing a flag for me.
Rob.
|
Subject:RE: How to set the mp3 ID3 data in Script?
Date:4/2/2013 2:42:54 PM
I had no idea about the CODE Tag; sorry. I believe I was able to successfully edit the post to make use of it.
The script does not do what I want it to do.
I'd like to set the ID3 metadata to the Title to the region title; which is.mk.Name
I'd like to set the ID3 metadata for TrackNo to "Counter/TotalRegions"
Neither of these are done in the script I originally posted.
I am applying this script to a single, open file. The file has both markers and regions; and looping over file.Markers appears to try to process both of them; thus making the mk.Ident value not consecutive.
There is a marker at the beginning and end of every region; so the numbering is like this:
1. Region 1; create a file
2. Marker 1: Do nothing
3. Region 2; create a file [that gets named as 3 instead of 2]
4. Marker 2: Do nothing
5. Region 3: Create a file [that gets named as 5 instead of 3]
etc...
You can see this in the screenshot I linked to.
I have continued to tweak the script and have got something that is closer to what I want but is far from ideal and permanently changes the metadata on the original file:
/* =======================================================================================================
* Script Name: Save Regions as Files
* Description: This script iterates through regions in the open file, renders the region to a specified
* format, and saves the rendered file to a specified location.
*
* Initial State: Run with a file open that contains regions.
*
* Parameters (Args):
* type - the extension of the format to render regions to - DEFAULT: .pca
* preset - the name of the template to use for rendering - DEFAULT: prompt user
* dir - the directory the files should be rendered to - DEFAULT: c:\media\rips
*
* Output: The queueing up of the file and the path name of the file
*
* ==================================================================================================== */
using System;
using System.IO;
using System.Windows.Forms;
using SoundForge;
//Run with a file that contains regions
//Iterates through the regions, renders to MP3 and saves the rendered file to c:\media\rip
//Scan the file for MODIFY HERE to see how to quickly customize for your own use
public class EntryPoint {
public string Begin(IScriptableApp app) {
//start MODIFY HERE-----------------------------------------------
string szType = GETARG("type", ".mp3"); //choose any valid extension: .avi .wav .w64 .mpg .mp3 .wma .mov .rm .aif .ogg .raw .au .dig .ivc .vox .pca
object vPreset = GETARG("preset", ""); //put the name of the template between the quotes, or leave blank to pop the Template chooser.
string szDir = GETARG("dir", ""); //hardcode a target path 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: type=.wav&dir=f:\RegionFiles
//end MODIFY HERE -----------------------------------
ISfFileHost file = app.CurrentFile;
if (null == file)
return "Open a file containing regions before running this script. Script stopped.";
if (null == file.Markers || file.Markers.Count <= 0)
return "The file does not have any markers.";
bool showMsg = true;
if (szDir == null || szDir.Length <= 0)
{
szDir = SfHelpers.ChooseDirectory("Select the target folder for saved files:", @"C:\");
showMsg = false;
}
if (szDir == null || szDir.Length <= 0)
return "no output directory";
//make sure the directory exists
if(!Path.IsPathRooted(szDir))
{
string szBase2 = Path.GetDirectoryName(file.Filename);
szDir = Path.Combine(szBase2, szDir);
}
Directory.CreateDirectory(szDir);
ISfRenderer rend = null;
if (szType.StartsWith("."))
rend = app.FindRenderer(null, szType);
else
rend = app.FindRenderer(szType, null);
if (null == rend)
return String.Format("renderer for {0} not found.", szType);
// if the preset parses as a valid integer, then use it as such, otherwise assume it's a string.
try {
int iPreset = int.Parse((string)vPreset);
vPreset = iPreset;
} catch (FormatException) {}
ISfGenericPreset template = null;
if ((string)vPreset != "")
template = rend.GetTemplate(vPreset);
else
template = rend.ChooseTemplate((IntPtr)null, vPreset);
if (null == template)
return "Template not found. Script stopped.";
string szBase = file.Window.Title;
// **********************************************************
// JH added this loop to calculate the total number of regions
// I wish I could do this without two loops
// **********************************************************
int numberOfRegions = 0;
foreach (SfAudioMarker mk in file.Markers)
{
if (mk.Length <= 0)
continue;
numberOfRegions++;
}
// JH adding this counter in order to keep track of count for naming files which is not always contigious when having markers and regions in file
int counter = 1;
foreach (SfAudioMarker mk in file.Markers)
{
if (mk.Length <= 0)
continue;
// string szName = String.Format("{0:d2}-{1}-({2}).{3}", mk.Ident, szBase, mk.Name, rend.Extension);
string szName = String.Format("{0}-{1}-{2}.{3}", counter.ToString("00"), szBase, mk.Name, rend.Extension);
szName = SfHelpers.CleanForFilename(szName);
DPF("Queueing: '{0}'", szName);
string szFullName = Path.Combine(szDir, szName);
if (File.Exists(szFullName))
File.Delete(szFullName);
SfAudioSelection range = new SfAudioSelection(mk.Start, mk.Length);
// **********************************************************
// JH Added this section to set the Summary Info in the open file
// this will be used when generating the mp3 in render as
// it works; but alters the original file which is undesirable
// ideally it seems it would be better if I could modify the template in each iteration through the look
// **********************************************************
SfSummaryInfo sumy = new SfSummaryInfo();
sumy.Title = mk.Name;
sumy.TrackNo = String.Format("{0}/{1}",counter.ToString(), numberOfRegions.ToString());
ApplySummaryInfo(file,sumy);
file.RenderAs(szFullName, rend.Guid, template, range, RenderOptions.RenderOnly);
DPF("Path: '{0}'", szFullName);
counter++;
}
// **********************************************************
// This was an attempt to remove the summary info we set on the file and put it
// back to its original state. It did not work;
// instead the open file's metadata is set to the value from the last loop iteration
// **********************************************************
SfSummaryInfo newOptions = new SfSummaryInfo();
newOptions.Title = "";
newOptions.TrackNo = "";
ApplySummaryInfo(file,newOptions);
// file.Save(SaveOptions.WaitForDoneOrCancel);
if(showMsg)
MessageBox.Show(String.Format("Files are saving to: {0}", szDir), "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
return null;
}
// borrowed from other script
// this function applies the info in sumyIn to the file one
// field at a time. We do it this way because if we try to
// set the entire sumyIn structure into the file in on call
// it will have the side effect of clearing all of the existing
// values, including those that aren't in the new sumyIn struct
//
public void ApplySummaryInfo(ISfFileHost file, SfSummaryInfo sumyIn)
{
ISfFileSummaryInfo sumy = file.Summary;
foreach (uint fcc in sumyIn)
{
sumy[fcc] = sumyIn[fcc];
}
}
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
Message last edited on4/2/2013 2:45:01 PM
byReboog711.
|
Subject:RE: How to set the mp3 ID3 data in Script?
Date:4/2/2013 7:50:14 PM
Your script was a little complicated, so I wrote my own. It should give you a place to start.
This script asks the user for an output path and goes through a renderer list to select a rendering template. This could be hard-coded to a specific output format if you'd rather.
Note: You wanted the track number to list as "track number/total tracks," which isn't possible with the TrackNo field. It defaults to a non-zero padded integer for the ID3 tag.
Give it a try and let me know if something isn't working correctly.
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)
{
//Get output folder. You can also hard code an output path by replacing the SfHelpers statement with your path.
string outFolder = SfHelpers.ChooseDirectory("Choose the output folder.", @"C:\");
//get renderer and template.
int cRend = app.Renderers.Count;
string[] renderers = new string[cRend];
for (int ix = 0; ix < cRend; ix++)
renderers[ix] = app.Renderers[ix].Name;
//allows you to choose a renderer from a list of all available renderers, in case you want something other than MP3. Otherwise, this can be hard-coded.
object item = SfHelpers.ChooseItemFromList("Select destination file type:", renderers);
ISfRenderer rend = app.FindRenderer(item.ToString(), null);
if (null == rend)
DPF("No Renderer Found.");
ISfGenericPreset tpl = rend.ChooseTemplate(IntPtr.Zero, 0);
if (null == tpl)
{
DPF("No template.");
//if no template is selected, this will automatically select the default template.
tpl = rend.GetTemplate(0);
}
//start our operation
ISfFileHost file = app.CurrentFile;
int counter = 0;
string windowTitle = file.Window.Title;
string szBase;
//check to see if the window title contains a file extension. If so, remove it for save name. Remove this if you want that extension and just set the szBase var to the windowTitle.
if (windowTitle.Contains("."))
{
int indexOf = windowTitle.LastIndexOf('.');
szBase = windowTitle.Remove(indexOf, (windowTitle.Length - indexOf));
}
else
szBase = windowTitle;
//cycle through markers, determine if they are regions. If so, pull them out and save them.
foreach (SfAudioMarker marker in file.Markers)
{
if (marker.IsRegion)
{
counter++;
SfAudioSelection asel = new SfAudioSelection(marker.Start, marker.Length);
//create a temporary file to paste audio into.
ISfFileHost temp = app.NewFile(file.DataFormat, true);
temp.OverwriteAudio(0, 0, file, asel);
//Change summary info for ID3 tag.
temp.Summary.Title = marker.Name;
temp.Summary.TrackNo = String.Format(counter.ToString());
//build our file name and file path for rendering.
string fileName = SfHelpers.CleanForFilename(String.Format("{0}-{1}-{2}.{3}", counter.ToString("00"), szBase, marker.Name, rend.Extension));
string outPath = Path.Combine(outFolder, fileName);
DPF("Queueing: '{0}'", fileName);
//Save and close file.
temp.SaveAs(outPath, rend.Guid, tpl, RenderOptions.OverwriteExisting | RenderOptions.SaveMetadata | RenderOptions.WaitForDoneOrCancel);
temp.Close(CloseOptions.DiscardChanges);
}
}
}
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: How to set the mp3 ID3 data in Script?
Date:4/3/2013 5:00:09 PM
I'll give it a try.
One thing I'll add is that--based on my understanding--setting the TrackNo field to track number/total tracks is how audio players--such as iTunes or DoubleTwist--tell the total tracks and display things like "2 of 10" or something similar.
In my second script; I do indeed set the TrackNo to "2/10" and that does indeed display the track number and total track in those tools. |
Subject:RE: How to set the mp3 ID3 data in Script?
Date:4/3/2013 5:18:59 PM
You could add that functionality in by running through the foreach loop an extra time initially and incrementing an integer counter of some kind. Then you would just need to reformat the TrackNo assignment in the main foreach loop. It could be that this will work in some players, but Windows wouldn't show anything besides the integer track number.
Rob. |
Subject:RE: How to set the mp3 ID3 data in Script?
Date:4/7/2013 9:41:54 AM
That script does appear to work; although it created .sfk files in the output directory; which the original script did not. I assume it is a difference between renderAs and saveAs.
It did give me an idea of how to set the metadata directly, though. Adding this segment after the processing loop removed the metadata from the original file.
file.Summary.Title = "";
file.Summary.TrackNo = "";
I do not know why the original code was not doing that. I'm doing some tweaking and clean up and I'll post the final script.
This is the final script. I'll note that it is primarily based off the "Save regions as files" script which I believe was included in Sound Forge 10. I'm sorry it is too complicated. I did borrow the section to remove the extension from the window title.
/* =======================================================================================================
* Script Name: Save Regions as Files
* Description: This script iterates through regions in the open file, renders the region to a specified
* format, and saves the rendered file to a specified location.
*
* Initial State: Run with a file open that contains regions.
*
* Parameters (Args):
* type - the extension of the format to render regions to - DEFAULT: .pca
* preset - the name of the template to use for rendering - DEFAULT: prompt user
* dir - the directory the files should be rendered to - DEFAULT: c:\media\rips
*
* Output: The queueing up of the file and the path name of the file
*
* ==================================================================================================== */
using System;
using System.IO;
using System.Windows.Forms;
using SoundForge;
//Run with a file that contains regions
//Iterates through the regions, renders to MP3 and saves the rendered file to c:\media\rip
//Scan the file for MODIFY HERE to see how to quickly customize for your own use
public class EntryPoint {
public string Begin(IScriptableApp app) {
//start MODIFY HERE-----------------------------------------------
string szType = GETARG("type", ".mp3"); //choose any valid extension: .avi .wav .w64 .mpg .mp3 .wma .mov .rm .aif .ogg .raw .au .dig .ivc .vox .pca
object vPreset = GETARG("preset", ""); //put the name of the template between the quotes, or leave blank to pop the Template chooser.
string szDir = GETARG("dir", ""); //hardcode a target path 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: type=.wav&dir=f:\RegionFiles
//end MODIFY HERE -----------------------------------
ISfFileHost file = app.CurrentFile;
if (null == file)
return "Open a file containing regions before running this script. Script stopped.";
if (null == file.Markers || file.Markers.Count <= 0)
return "The file does not have any markers.";
bool showMsg = true;
if (szDir == null || szDir.Length <= 0)
{
szDir = SfHelpers.ChooseDirectory("Select the target folder for saved files:", @"C:\");
showMsg = false;
}
if (szDir == null || szDir.Length <= 0)
return "no output directory";
//make sure the directory exists
if(!Path.IsPathRooted(szDir))
{
string szBase2 = Path.GetDirectoryName(file.Filename);
szDir = Path.Combine(szBase2, szDir);
}
Directory.CreateDirectory(szDir);
ISfRenderer rend = null;
if (szType.StartsWith("."))
rend = app.FindRenderer(null, szType);
else
rend = app.FindRenderer(szType, null);
if (null == rend)
return String.Format("renderer for {0} not found.", szType);
// if the preset parses as a valid integer, then use it as such, otherwise assume it's a string.
try {
int iPreset = int.Parse((string)vPreset);
vPreset = iPreset;
} catch (FormatException) {}
ISfGenericPreset template = null;
if ((string)vPreset != "")
template = rend.GetTemplate(vPreset);
else
template = rend.ChooseTemplate((IntPtr)null, vPreset);
if (null == template)
return "Template not found. Script stopped.";
string szBase = file.Window.Title;
//check to see if the window title contains a file extension. If so, remove it for save name. Remove this if you want that extension.
if (szBase.Contains("."))
{
int indexOf = szBase.LastIndexOf('.');
szBase = szBase.Remove(indexOf, (szBase.Length - indexOf));
}
// JH adding this counter in order to keep track of count for naming files which is not always consecutive when having markers and regions in file
int counter = 1;
// calculate the number of regions
// wish I could do this without two loops
int numberOfRegions = 0;
foreach (SfAudioMarker mk in file.Markers)
{
if (mk.Length <= 0)
continue;
numberOfRegions++;
}
// loop through all markers and generate files from regions
foreach (SfAudioMarker mk in file.Markers)
{
if (mk.Length <= 0)
continue;
// set filename to TwoDigitTrackNumber-originalFileTitle-RegionName.mp3
string szName = String.Format("{0}-{1}-{2}.{3}", counter.ToString("00"), szBase, mk.Name, rend.Extension);
szName = SfHelpers.CleanForFilename(szName);
DPF("Queueing: '{0}'", szName);
string szFullName = Path.Combine(szDir, szName);
if (File.Exists(szFullName))
File.Delete(szFullName);
SfAudioSelection range = new SfAudioSelection(mk.Start, mk.Length);
// set the name and track metadata for the output mp3
// all other mp3 metadata will come from the template; which the user selected
file.Summary.Title = mk.Name;
file.Summary.TrackNo = String.Format("{0}/{1}",counter.ToString(), numberOfRegions.ToString());
file.RenderAs(szFullName, rend.Guid, template, range, RenderOptions.RenderOnly);
DPF("Path: '{0}'", szFullName);
// increment the track number counter
counter++;
}
// remove the summary info we set on the file
file.Summary.Title = "";
file.Summary.TrackNo = "";
if(showMsg)
MessageBox.Show(String.Format("Files are saving to: {0}", szDir), "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
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
Message last edited on4/7/2013 10:10:06 AM
byReboog711.
|
Subject:RE: How to set the mp3 ID3 data in Script?
Date:4/8/2013 7:05:25 AM
Glad you've got something working that you like. A thought occurred to me with regards to the two loop situation. You could do the initial run through the markers checking for regions to get your total count. Store the regions that loop finds in an array ([,] with the start position and length of the region). Then you would only have to loop through that array of regions the second time, instead of the whole file of markers. It doesn't eliminate running two loops, but it might improve the efficiency just a touch.
Just a thought.
R. |
Subject:RE: How to set the mp3 ID3 data in Script?
Date:4/8/2013 5:49:32 PM
That's a great idea. I'll keep it in mind if performance becomes an issue. As it stands now; the loops run blazing fast and the roadblock is in the conversion. |