Community Forums Archive

Go Back

Subject:Extract and Encode: Slight Mod?
Posted by: BradlyMusic
Date:8/7/2008 9:56:37 AM

I have a large project, where I'm ripping about 300 CDs to my hard drive into individual Track .Wav files.

The included Extract and Encode Script in Sound Forge is "almost" perfect for my needs. What I want to know....is it possible to not have Sound Forge Open the Wave editor window view after it extracts a CD Track? The CDs I'm ripping have 80-99 tracks on them each. I just want them to be Ripped from the CD and put directly to my Hard Drive in .Wav format. Then automatically named by the Track number with an added file descriptor, like the Script does.

The problem with the script for me, is that now I have 90 plus Windows open in Sound Forge that I have to individually close out and each one of these Windows prompts me if I want to save changes.....now that becomes a big pain and it now takes me more time and clicking like a mad man to close the windows out then it takes me to extract the CD Tracks.

Right now to avoid this, I installed Musicmatch Jukebox, which does the job...but for some reason it seems extremely slow on extracting the tracks compared to what I'm used to in Sound Forge. It seems to be taking me about 30 minutes per CD in Musicmatch right now.

I don't know anything about scripting....but I'm wondering if one of you programming types can let me know if this is possible....and even modify the script for me? :)

Also automatically selecting ALL the tracks would be nice too. That would save me up to 99 extra mouse clicks since you have to individually click on each track.

Subject:RE: Extract and Encode: Slight Mod?
Reply by: _TJ
Date:8/7/2008 5:39:37 PM

Unfortunately, there is no way to extract without also creating a window in Sound Forge.

But you can have the script close the windows for you, and avoid getting the 'Do you want to save' prompt.

There is a script that will discard (without asking if you want to save) all open files. I use it when testing a lot.

I think this is one of the samples. look for Discard All Files.cs

In case you can't find it. here's the code.

using System;
using SoundForge;
public class EntryPoint {
public void FromSoundForge(IScriptableApp app) {
try {
foreach (ISfFileHost file in app.Files)
file.Close(CloseOptions.DiscardChanges);
} catch(Exception e) {
app.OutputText(e.ToString());
}
app.SetStatusText("all files discarded.");
}
} //EntryPoint


Also, with regard to having to select the tracks, There are several ripping script samples. You might find RipWholeCD.cs or RipWithFreeDB_Multi.cs or one of the others
to be closer to what you need.

tj


Subject:RE: Extract and Encode: Slight Mod?
Reply by: _TJ
Date:8/7/2008 5:58:51 PM

at about line 190 in the Extract CD and Encode.cs script, there this line of code


this.listBox2.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;


Change it to this


this.listBox2.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;


And you will be able to select all of the tracks by clicking on the first one, then shift+clicking on the last one.

tj

Subject:RE: Extract and Encode: Slight Mod?
Reply by: BradlyMusic
Date:8/7/2008 8:39:36 PM

Thanks TJ. That sounds exactly what I was looking for with both solutions. I'll give it a shot!!!

One other thing while I have your helpful attention. In the Track selection Window where it lists the tracks ala Track1,Track2,....Track99. Is there a mod in the track number naming convention where I could have tracks 1-9 come up as Track01, Track02...etc, while the others 10-99 track naming remain the same?

I'm sure you might understand the need for this already, due to Windows folder naming alphabetical listing convention. I want the .Wav files to be listed in the Windows folder view in the order they where on the CD. Otherwise you have Track 1 followed by Track10..etc.

This one is not a big deal because I can always just go into Windows and rename Tracks1-9 afterwards.

Ultimately, here's what the final result would look like:
http://stashbox.org/176636/Naming%20Convention.JPG

Regarding the other script samples that you mentioned, where would I find those? Should I do search in this forum or is there a download section for scripts available some where on this site? I'm using SF8.0d....so if the scripts you mentioned are in 9.0...that might be why I haven't seen them yet.

phew!!! I just finished extracting CD#28...only about 270 to go now. :(

Message last edited on8/7/2008 9:38:10 PM byBradlyMusic.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: BradlyMusic
Date:8/12/2008 8:02:19 AM

Help!?

Ok Everything works.. except I'ld like to try and include the Close all windows and discard changes code block into the Extract and Encode Script. I haven't been able to figure out how to do that. I tried just pasting everything at the end of the script and then commenting out

/// using System;
/// using SoundForge;

but that didn't work. I pasted the code block into a separate script and that works fine of course, but I'ld like to not have to run 2 separate scripts.

Can someone help me out with Which lines, and where I should place them within the Extract and Encode script so that it closes out the windows in Forge and discards changes?

I've been reading thru the script and I have some idea of the flow of it, thanks to the comments...but no matter where I've tried to place the code so far I haven't got it to work right. :(

Message last edited on8/12/2008 8:30:48 AM byBradlyMusic.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: _TJ
Date:8/12/2008 12:57:57 PM

Regarding the other script samples that you mentioned, where would I find those? Should I do search in this forum or is there a download section for scripts available some where on this site? I'm using SF8.0d....so if the scripts you mentioned are in 9.0...that might be why I haven't seen them yet.

Download the Sound Forge Script SDK, the samples are in there. Most of the scripts from the Sound Forge 9 Script SDK will work for Sound Forge 8, You'll just have to try them and see.

tj

Subject:RE: Extract and Encode: Slight Mod?
Reply by: _TJ
Date:8/12/2008 1:03:46 PM

Can someone help me out with Which lines, and where I should place them within the Extract and Encode script so that it closes out the windows in Forge and discards changes?

at about line 390 in the Extract and Encode.cs script, you will see the following lines of code


// render, wait for render to complete
forge.ActiveWindow.File.RenderAs(this.textBox1.Text + fileprefix + " - " + ....
forge.WaitForDoneOrCancel();


You just need to close the file after the WaitForDoneOrCancel, like this:


....
forge.WaitForDoneOrCancel();
forge.ActiveWindow.Close(CloseOptions.DiscardChanges);


Now each Sound Forge window will close after it has been saved to disk.

Message last edited on8/12/2008 1:04:18 PM by_TJ.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: BradlyMusic
Date:8/12/2008 2:31:12 PM


Bad Code
....
forge.WaitForDoneOrCancel();
file.Close(CloseOptions.DiscardChanges);
[/Code]

Thank you TJ!!! I was so close, yet so far. I was in the right location...yet so far, since I was using the wrong command line. I tried to use parts of the previous code you had posted above and I was stumped and trying to figure out what was wrong.

One of these days, I will be able to understand what the code really means, and I'll probably feel really stupid. :)

Thanks for your help!!!

Message last edited on8/12/2008 3:13:20 PM byBradlyMusic.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: BradlyMusic
Date:8/12/2008 3:12:30 PM

//Close out and discard all active Windows make sure to include "File" in command
forge.ActiveWindow.File.Close(CloseOptions.DiscardChanges); [/Code]

Ok, one small correction in the code you posted above....but luckily I was able to figure this one out.

Message last edited on8/12/2008 3:14:07 PM byBradlyMusic.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: BradlyMusic
Date:8/24/2008 3:54:31 PM

// if the user has entered a prefix, use that, otherwise use DiscID
if(this.textBox3.Text == "")
fileprefix = "CD - " + cddrive.DiscID;
else
fileprefix = this.textBox3.Text;
//Rename Tracks 1-9
if (forge.ActiveWindow.Title == "Track 1")
forge.ActiveWindow.Title = "Track 01";
if (forge.ActiveWindow.Title == "Track 2")
forge.ActiveWindow.Title = "Track 02";
if (forge.ActiveWindow.Title == "Track 3")
forge.ActiveWindow.Title = "Track 03";
if (forge.ActiveWindow.Title == "Track 4")
forge.ActiveWindow.Title = "Track 04";
if (forge.ActiveWindow.Title == "Track 5")
forge.ActiveWindow.Title = "Track 05";
if (forge.ActiveWindow.Title == "Track 6")
forge.ActiveWindow.Title = "Track 06";
if (forge.ActiveWindow.Title == "Track 7")
forge.ActiveWindow.Title = "Track 07";
if (forge.ActiveWindow.Title == "Track 8")
forge.ActiveWindow.Title = "Track 08";
if (forge.ActiveWindow.Title == "Track 9")
forge.ActiveWindow.Title = "Track 09";

// render, wait for render to complete
forge.ActiveWindow.File.RenderAs(this.textBox1.Text + fileprefix + " - " + forge.ActiveWindow.Title + "." + renderer.Extension, renderer.Name, Preset, mySelection, SoundForge.RenderOptions.RenderOnly | SoundForge.RenderOptions.AndClose);
forge.WaitForDoneOrCancel();[/Code]

I need a further bit of assistance. My modified script has been working great, except I'm reaching the point where it's getting a little tedious to go to Windows explorer and rename tracks 1-9. So with my limited understanding I tried doing a crude rename function on tracks 1-9 in the script. I didn't get any compiler errors, but it didn't do what I had hoped for either.

So above is what I did in an attempt to rename Tracks 1-9, so when it saved the file in the naming convention outlined, instead of Track 1 being named "Track 1" it would be named "Track 01"....etc. for tracks 1-9 . So I added all these "if" statements following my comment line to the current script in an attempt to change the value of "forge.ActiveWindow.Title"

What am I doing wrong in my "if" command lines. The script writes the names the same like it never got caught by the "if" command line.

Message last edited on8/24/2008 4:02:51 PM byBradlyMusic.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: _TJ
Date:8/26/2008 12:56:17 PM

try this instead


//Rename Tracks 1-9
string strTitle = forge.ActiveWindow.Title;
if (strTitle == "Track 1")
strTitle = "Track 01";
if (strTitle == "Track 2")
strTitle = "Track 02";
if (strTitle == "Track 3")
strTitle = "Track 03";
if (strTitle == "Track 4")
strTitle = "Track 04";
if (strTitle == "Track 5")
strTitle = "Track 05";
if (strTitle == "Track 6")
strTitle = "Track 06";
if (strTitle == "Track 7")
strTitle = "Track 07";
if (strTitle == "Track 8")
strTitle = "Track 08";
if (strTitle == "Track 9")
strTitle = "Track 09";

// render, wait for render to complete
forge.ActiveWindow.File.RenderAs(this.textBox1.Text + fileprefix + " - " + strTitle + "." + renderer.Extension, renderer.Name, Preset, mySelection, SoundForge.RenderOptions.RenderOnly | SoundForge.RenderOptions.AndClose);



Don't forget to change the forge.ActiveWindow.Title to strTitle in the last line.


Subject:RE: Extract and Encode: Slight Mod?
Reply by: BradlyMusic
Date:8/26/2008 2:48:13 PM

Thanks for bearing with me TJ.

Today, I'm on Day #3 of "Teach Yourself C in 21 Days" and I learned about "Symbolic Constants". Which made a light bulb go off of what I was probably doing wrong in the code I posted. While I didn't see "forge.ActiveWindow.Title" defined anywhere in the script, I came to the conclusion that it is probably defined as a CONSTANT variable within Sound Forge, and thus, why the script would not allow me to change the value. That would be my best guess with my 3 days of knowledge anyways...but it gave me some ideas of things to try.

The code you posted makes sense as what I had thought the problem might be, so I understand most of it and why. I just haven't reached the understanding of the keyword "string" yet....I'm not sure which day of 21 that falls on. :)

I'll insert the code you posted later today and let you know how it goes. I've now got 140 CDs extracted.....only about 160 to go now!!! Using Sound Forge and the scripting function has sped up the entire process tremendously though. This last piece of code should make things even easier!!!

Message last edited on8/26/2008 2:51:59 PM byBradlyMusic.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: BradlyMusic
Date:8/26/2008 4:34:08 PM

Ok, I inserted your code and everything works PERFECTLY for what I was trying to achieve.

Thanks a million TJ!!!

I think since I've become pretty familiar with this script and as I learn more C, one of these days you might see me post an "Extract and Encode v2.0". I have a few ideas on improving the functionality of this script to make it more versatile.

Here's some of my ideas for a v2.0 feature enhancement revision.
1. Add basic transport functions (Stop, Play)
2. Add An Auto-play with single click of Track check box option.
3. Double Click CD Track Renaming capability
4. Add a CD Eject button.
5. Add a "Eject CD after complete" check box option
6. File Naming convention options and name order preference (ie Artist - CD Title - TrackName -Track # or any order of those options)
7. CD scan refresh button. (In the current script once you finish ripping a CD, eject it and insert another CD, it doesn't refresh that there's been a new CD inserted). The way around this currently is that I have 2 CD ROMs installed and I have to chose the CDrom I'm not currently using and then go back to the original CDrom drive for the script to refresh and scan the new CD and update the track list. This gave me some troubles on my laptop since I only had one CDrom drive installed. I connected an external USB CDrom drive and all is well again.
8. User Check box option to leave Forge Windows open or auto close.

Hopefully all of that is doable with the current Sound Forge scripting capabilities.

After that I might look at custom ID3 tagging options for MP3 and WMA file encoding.

So right now I have some ideas...but just not the knowledge on doing most of it.

Message last edited on8/26/2008 6:50:36 PM byBradlyMusic.
Subject:RE: Extract and Encode: Slight Mod?
Reply by: Piano Peddler
Date:12/16/2008 10:51:17 AM

Another way to avoid having to close out all the windows is to bring up Windows Task Manager and kill the forge90.exe process. Then go into your SF temp folder and delete the orphaned temp files.

Eugene

Go Back