I'm new to C# and confused on the differences between the C++ interface to MC12 and the C# interface. I would appreciate any help I can get.
I've got a working C# start to an application (not a plugin) that populates a list box based on the JRiver interface. It simply lists all of the songs. To do this, I use MCAutomation (I'm not doing anything with events at this point). The code looks something like this:
IMJFilesAutomation mySongs = pMC.Search("[Media Type]=audio");
StringBuilder sBuild = new StringBuilder();
for (int i = 0; i < mySongs.GetNumberFiles(); i++)
{
IMJFileAutomation myFile = mySongs.GetFile(i);
sBuild.AppendFormat("{0}\n",myFile.Name);
}
This code takes about 3-5 seconds to run, which seems pretty slow to me (I've only got about 2000 tracks in my library). I'm not sure if I'm not the right track or not, but I implemented something similar in C++ (C++ 2005 express vs. C# 2005 express, if that matters). The following C++ code takes about 1/2 second (including creating the MC instance):
IMJFilesAutomationPtr pFiles = pMJ->Search("[Media Type]=audio");
IMJFileAutomationPtr pFile;
for (int i = 0; i < pFiles->GetNumberFiles(); i++)
{
pFile = pFiles->GetFile(i);
}
Yes, I know I'm not doing any string processing in the C++, but I can comment out that line in the C# and the time it takes to run doesn't change.
My thinking (I'm really curious if I'm on the right track or not) is that the C# code is doing a copy (probably shallow) of each file, whereas the C++ is just keeping the pointer. I tried to change the C# code, using unsafe, to use pointers, but I keep getting errors like the following:
Cannot take the address of, get the size of, or declare a pointer to a managed type
Now I know that both my C++ and C# started by pointing to "Media Center 12.tlb", but that C# creates a proxy interface. Is that why C# thinks that the MCAutomation is managed code? Is there a way around this?
I can't find a way to use MCAutomation in C++, nor IMJAutomationPtr in C#. I'm hoping someone can explain the differences and let me know if there is a way to get the performance boost I seem to get from C++.
Thanks!
Brett