Using VB.NET to get audio file extended attributes?

Hi everyone... I'm an intermediate VB.NET user. I have a couple of applications that finds all the .WAV and .MP3 files in a folder (and its subfolders), reads their headers, and reports their sample rates, lengths, and number of channels. They run on XP and 2003 Server.


I'd like to extend this to .WMA and .AIF files, and I'm starting to think that an easier way of accomplishing this task is to leverage some sort of Windows API. Considering that all three of those attributes are reported in Windows Explorer (by right-clicking on an audio file, selecting "Properties...", clicking the "Summary" tab, and then clicking the "Advanced" button), this should be possible.


I've just spent the day Googling for possible methods. It seemed that I could use Indexing Service to dig up the PSGUID_AUDIO property set, but I don't have the faintest idea of how to do that in VB.NET. All the examples of using Windows Indexing Service I found used VB 6, and I couldn't figure out how to alter the code to make the transition, let alone implement the PSGUID_AUDIO property set.

Then I came across WMI, but I couldn't figure out how to get it to report on the extended stats I needed (audio sample rate, length, and number of channels). The System.Management namespace turned out to be a dead end too.

Finally, I looked at the Windows Media Player SDK, but it doesn't seem to be able to report sample rate.


My brain is now cabbage, and I'm crying uncle.

Thanks for your time!




Answer this question

Using VB.NET to get audio file extended attributes?

  • tlathrop

    I think the PSGUID_AUDIO is from the file indexing service, not sure if you can use that or not. Have you attempted to parse the information yourself You can find out about the WMA header information at http://www.microsoft.com/windows/windowsmedia/format/asfspec.aspx


  • El Pea

    Thanks Renee! I wish it was as easy as opening an ID3; unfortunately, WAVs, AIFs, and (AFAIK) WMAs don't have ID3 info, so you have to get all that stuff from the header. And alas, ID3 doesn't hold sample rate information. :(

    That's a good idea about trying to ping the people who do WinAmp plugins. I'll give it a shot...


  • Jessica.Weiner

    I'm starting to think that the answer is in the PSGUID_AUDIO property set (http://msdn.microsoft.com/library/default.asp url=/library/en-us/indexsrv/html/ixrefint_5l7z.asp). Trouble is, I can't figure out how to implement it in my code (VB.NET, using VB Express). I don't know which DLL or API to use to open the file, and then how exactly to access the PSGUID_AUDIO property set. Is there a brave soul who can help me with this

    Thanks for your time!


  • www.GaaLive.com

    Hello Anyone Still spinning my wheels here...


  • Raja Annamalai

    Hi ingedient,

    I seem to remember an ID3 editior in VBAccelerator. But be warned, it's VB6.

    I think you're on the right track in considering a windows API. You noticed the exact thing I've noticed and this Windows can do it. There are tons of places that do things like WinAmp interfaces. These people seem to really know about these tags.

    Generally, when I have a problem like this, it's nomenclatural. I don't have the right nouns to find what I'm looking for and you are looking for a couple of the rarer formats which makes it a challenge.

    Good luck!



  • eLliDKraM

    My best suggestion in that case would be to add a COM reference to the Windows Media Encoder and then use the object browser to disect it.

    Or, if you haven't already, you can download the Widows Media SDK and look to see if any of the VB examples they provide have routines you are interested in.


  • jaxrpc

    Hi Richard...

     What I'm trying to do here is avoid parsing the information.  I'm already reading the headers of two file types (WAV and MP3).  I'm adding WMA and AIF compatibility to my project.  Instead of creating routines for two more file types, I'd (ideally) like to have Windows parse the file for me - as it does itself anyway - and report to me the properties that I need.  This way, if I need to become compatible with another format down the road, then I'll be compatible with it as long as Windows is.

     I have no idea whether or not if this is possible, but I figure it's worth a shot.  If not, then the document you linked me to will be very handy.  And either way, it's a learning experience.  :)

     Thanks!



  • Bob.K.

    I'll give it a shot tomorrow. Thanks!

  • Using VB.NET to get audio file extended attributes?