Subject:Apply Saved Region Markers to .Raw File
Posted by: stoi2m1
Date:8/2/2006 2:28:51 PM
Im looking for a way to apply a saved region marker list. I have a file that needs to be of a certain size in samples (not time) always. Within this file are various voice samples. I have repeatedly built the region marker list (from within the view region list menu item) but it is a horribly long process. If I try to save the audio file as any other file type then .raw I have found that my region locations are are not at the same sample location as I had origional marked them to be, this is a problem, the file has data between the audio samples that can not be shifted from its location. Its data intended for a processor to read these location are know by the firmware that will read the file. So my intent is to be able to open this file, apply a region list to. So I can replace the regions with others sounds from other files and then save the file as a new .raw file, where the designated regions will not loose there location. The only thing I really need to have automated is applying the regions to the .raw file. I will only be exporting the region list once for the file and it will not change once its setup. Thanks, Jesse Message last edited on8/3/2006 2:13:14 PM bystoi2m1. |
Subject:RE: Apply Saved Region Markers to .Raw File
Reply by: stoi2m1
Date:8/3/2006 2:44:35 PM
Above message edited to better explain what I am trying to do. I was thinking all I really need it a script the can apply a given region. Seeming how my regions are fixed and will always be the same there is no need to read the region markers from a file. I was looking through some of the documents for the SDK package and I found this: construct a marker of type Region with a given Start and Length public SfAudioMarker(long,long); What is the simples way to use this to implement a single region Thanks, Jesse |
Subject:RE: Apply Saved Region Markers to .Raw File
Reply by: stoi2m1
Date:8/3/2006 5:03:05 PM
Ok this is what Ive got so far. I made a new script in the scriopt editor and I added: int ccStart = 0; int ccLength = 17641; ISfFileHost file = app.CurrentFile; SfAudioMarker mk = new SfAudioMarker(ccStart,ccLength); file.Markers.Add(mk); where, /*begin here*/, was. This creates my first region just fine. I have 2 questions: 1. How does the script know that the parameters I entered above where in samples and not in time or seconds? 2. How do I give that newly defined region a name? Thanks for all of the help so far, hehe... (You have helped you jsut dont know it, Ive been reading other posts while waiting) At least this has given me a place to gather all my thoughts! Jesse Message last edited on8/3/2006 8:30:03 PM bystoi2m1. |
Subject:RE: Apply Saved Region Markers to .Raw File
Reply by: stoi2m1
Date:8/4/2006 12:59:42 PM
Well I got it working. I will post my code later once I clean it up and make comments. Jesse Message last edited on8/4/2006 1:17:11 PM bystoi2m1. |
Subject:RE: Apply Saved Region Markers to .Raw File
Reply by: _TJ
Date:8/7/2006 10:24:30 AM
How does the script know that the parameters I entered above where in samples and not in time or seconds? the Sound Forge script API always expects start and length parameters to be in samples. There are helper functions that you can use to convert samples to seconds and seconds to samples for the convenience of the code. Everything else expects to see values in samples. tj |
Subject:RE: Apply Saved Region Markers to .Raw File
Reply by: stoi2m1
Date:8/7/2006 12:16:36 PM
Thanks for the response, samples is my desired measurment seeming how I need to be exact with what I am doing. My audio will become binary and programmed on an eprom where it is then addressed and this all matters. Thanks, Jesse |
Subject:RE: Apply Saved Region Markers to .Raw File
Reply by: stoi2m1
Date:8/7/2006 4:43:02 PM
Heres the final code that I have came up with. Im quite sure there is a better way to have written the code but this is what I came up with. using System; using System.Windows.Forms; using SoundForge; public class EntryPoint { public void Begin(IScriptableApp app) { ISfFileHost file = app.CurrentFile; int i=0; // this counter is for the while loop int S=0; // this counter is for the region start location int L=1; // this counter is for the region length int N=2; // this counter is for the region name //***Start of array element 1 start of region element 2 region length element 3 region name*** //need to match the physical location of region to the name virtual name in the firmware of the HR-16 int[] intArray = new int[] { 0, 8826, 1, 8832, 5002, 2, 13840, 16522, 3, 30368, 10002, 4, 40376, 12502, 5, 52888, 7502, 6, 60400, 4002, 7, 64408, 7502, 8, 71920, 13002, 9, 84928, 15002, 10, 99936, 5002, 11, 104944, 11002, 12, 115952, 15002, 13, 130960, 7502, 14, 138472, 6502, 15, 144984, 9738, 16, 154728, 15002, 17, 169736, 20002, 18, 189744, 20002, 19, 209752, 23502, 20, 233264, 15002, 21, 248272, 11502, 22, 259785, 2360, 23,}; //1st pos is start location 2nd pos is region length 3rd is for the name of the region name while (i < intArray.Length/3) { // loop to create each region, the equation breaks up the array into groups of 3, 3 elements for each Region SfAudioMarker mk = new SfAudioMarker(intArray[S],intArray[L]); mk.Name = intArray[N].ToString(); file.Markers.Add(mk); i++; //increases the counter to the next region S=S+3; //increases the counter to the next region start location 3 elements for each region with in the array L=L+3; //increases the counter to the next region length location 3 elements for each region with in the array N=N+3; //increases the counter to the next region name location 3 elements for each region with in the array } } 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, 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)); } } //EntryPoint Message last edited on8/7/2006 4:44:05 PM bystoi2m1. |
Subject:RE: Apply Saved Region Markers to .Raw File
Reply by: _TJ
Date:8/8/2006 1:30:31 PM
Thank you for sharing your script with us. tj |