title
Products            Buy            Support Forum            Professional            About            Codec Central
 

[C# .NET] Calling DMC from external program with selected files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Speed_Sheep

    • May 2005
    • 3

    [C# .NET] Calling DMC from external program with selected files

    I have my own music manager build in C# with Visual Studio .NET 2003, now running Visual Studio .NET 2005 Beta 2 using the Microsoft Beta Experience Kit.

    I made it so I can view my directories with MP3 files, have my own options for renaming those files automaticly, etcetera.
    The only thing I'm still doing manually is converting files with DBPoweramp to .ogg using the Ogg Vorbis aoTuV b3 SSE2 codec (64-bit machine with WinXP x64 Edition).

    Now I have seen the DMC File Selector and that does exactly what I want also. When I select a few files, it opens the Music Converter, but it has on the background the files selected that were selected in the DMCfs. That's exactly what I want!

    Did a bit research and was expecting that DMCfs was calling MusicConverter.exe when I push the "Convert To" button on the toolbar. Instead a new process doesn't get started for showing the converting options.

    Is there a way to simply add files to DMC without using the DMCfs?
    Can it be done using a COM component? I tried the example, but I get a lot errors. Looks like the COM components doesn't get recognized. In VS I tried add items to the toolbox -> COM components. But something like DMC is not listed.

    Or using the commandline?
    Or an DLL that I can call?

    I like DMC very much! The only thing for me it the above problem I would like to tackle :smile2:
  • Spoon
    Administrator
    • Apr 2002
    • 44574

    #2
    Re: [C# .NET] Calling DMC from external program with selected files

    See:

    Spoon
    www.dbpoweramp.com

    Comment

    • iTunesIsEvil
      dBpoweramp Enthusiast

      • Dec 2004
      • 94

      #3
      Re: [C# .NET] Calling DMC from external program with selected files

      Alrighty... this could turn into babbling, so if it does, just ignore me.

      What I did to do what I think you want to do...

      1) Created a new project, then in the solution explorer (right side of the IDE in VS .NET 03), right click "References," then select "Add A Reference." In the resulting window select the COM tab, and scroll down to "DMC Scripting 1.0 Type Library." Double-click it, and then click Ok at the bottom of the window.

      2) In the code for your project, preferably in the code for the form that you're going to be calling DMC from, up at the top, below the other "using" statements type the following
      Code:
      using DMCSCRIPTINGLib;
      3) Now in your code wherever youre going to do the call to the MusicConverter do something like this:
      Code:
      DMCSCRIPTINGLib.Converter dMC = new DMCSCRIPTINGLib.ConverterClass();
      
      dMC.VolumeNormalize = 0;
      dMC.PreserveTags = 1;
      
      if (System.IO.Directory.Exists("c:\\ConvertedMusic\\")) {
      	dMC.ConvertToFolder = 1;
      	dMC.ToFolder = "C:\\ConvertedMusic\\";
      }
      else {
      	dMC.ConvertToFolder = 0;
      }
      
      // for this part im assuming youve got an object string[] fileQueue of file names.
      string[] fileQueue = {"c:\\file1.mp3", "c:\\file2.mp3"};
      for (int i = 0; i < fileQueue.Length; i++) {
              if (System.IO.File.Exists(fileQueue[i]) {
      		dMC.AddFromFile(fileQueue[i]);
      	}
      }
      
      dMC.GoConversion("Wave", 0, 0, 1, 1);
      In Spoon's example in the developer section, there are some differences. For instance the GoConversion method in the examples works like this:

      Code:
      GoConversion(string, bool, bool, bool, bool)
      While the Scripting Library I have works like this:

      Code:
      GoConversion(string, int, int, int, int)
      I assumed 0 = false 1 = true.
      I didn't actually run what I've got there, but it compiles just fine.

      Hopefully that helps! If not, then I'll just erase this monster.
      Last edited by iTunesIsEvil; May 17, 2005, 08:14 PM.

      Comment

      • Speed_Sheep

        • May 2005
        • 3

        #4
        Re: [C# .NET] Calling DMC from external program with selected files

        I already explained in my post with the corresponding URL that I tried that with no luck...


        Anyway I just read the startpost of iTunesIsEvil and that works like a charm. Thousands of thanks Now I really think DMC is da bomb! :smile2:

        The only thing I did wrong was searching for the COM component at the wrong place :(
        Had to tune some, fixed a syntax typo in your code. I'll post a part of my code for those who like it maybe later, sadly got some other work to do tonight.

        About iTunesIsEvil's question: In the GoConversion function setting e.g. NoOverwrite to 1 will overwrite a file, but not display a message asking "whether or not to overwrite the existing file". So indeed 1 = true, 0 = false.

        Comment

        • iTunesIsEvil
          dBpoweramp Enthusiast

          • Dec 2004
          • 94

          #5
          Re: [C# .NET] Calling DMC from external program with selected files

          Originally posted by Speed_Sheep
          Had to tune some, fixed a syntax typo in your code.
          Yeah... I kinda slapped that together in like 5 min. It actually took longer to get it posted on here Ok, than it did to code the darn thing. I wasn't getting any syntax errors though, I was compiling just fine... I'd be interested to see what that was. Anyway: Cheers, and good luck with doing the rest of whatever you're trying to do with this idea

          Comment

          • Speed_Sheep

            • May 2005
            • 3

            #6
            Re: [C# .NET] Calling DMC from external program with selected files

            Originally posted by iTunesIsEvil
            I was compiling just fine... I'd be interested to see what that was.
            Ok, here is the line of your code:
            Code:
                    if (System.IO.File.Exists(fileQueue[i]) {
            Just 1 closing tag for the if statement. So this is correct:
            Code:
                    if (System.IO.File.Exists(fileQueue[i])) {
            And for the conversion call I use Ogg vorbis instead of Wave, so this is what I use:
            Code:
            dMC.GoConversion("Ogg Vorbis aoTuV b3 SSE2", 1, 1, 1, 0);
            But remember it's a great job you did!
            Last edited by Speed_Sheep; May 17, 2005, 11:39 PM.

            Comment

            • Spoon
              Administrator
              • Apr 2002
              • 44574

              #7
              Re: [C# .NET] Calling DMC from external program with selected files

              Thanks iTunesIsEvil
              Spoon
              www.dbpoweramp.com

              Comment

              • iTunesIsEvil
                dBpoweramp Enthusiast

                • Dec 2004
                • 94

                #8
                Re: [C# .NET] Calling DMC from external program with selected files

                Originally posted by Spoon
                Thanks iTunesIsEvil
                NP... Since I got VS.NET '05 I've been on a C# kick (moreso than usual) anyway. I'm currently rewriting iRevolt in 05 and trying to use some of the new pretty stuff MS has put in there. So far it's going unexpectedly well! I plan to uhhh... "release" it as a beta for anyone that actually feels like downloading the .NET Framework 2.0 Beta.

                PS: If anyone *does* feel like downloading the Framework 2.0, and helping to test iRevolt soonish, please feel free to PM me, or e-mail development@NO_SPAM.gk-soft.net (after removing the obvious spam filter).

                Comment

                • Spoon
                  Administrator
                  • Apr 2002
                  • 44574

                  #9
                  Re: [C# .NET] Calling DMC from external program with selected files

                  That is the killer for .net, the ~20 MB framework :(
                  Spoon
                  www.dbpoweramp.com

                  Comment

                  • iTunesIsEvil
                    dBpoweramp Enthusiast

                    • Dec 2004
                    • 94

                    #10
                    Re: [C# .NET] Calling DMC from external program with selected files

                    Originally posted by Spoon
                    That is the killer for .net, the ~20 MB framework
                    Yeah... It's not too nice of a dl... Though before I managed to get the 2005 VS on DVD, I just downloaded C# 2005 Express Edition, and went ahead and downloaded the MSDN Express Collection. 204MB. Ouch. :yawn: I think I took a nap while that downloaded. Sheesh.

                    Comment

                    Working...

                    ]]>