An MP3 decoder written in VB

I cannot keep track of the number of times I needed an easy way to decode an MP3 file from a .NET program.
Sure there are many libraries available and sure there are many ways you can do it but I just wish I could do it natively (with managed code) and have complete control over the decoding process.

Well, I guess that’s why I created the CMP3Decoder class, a .NET VB wrapper that encapsulates a native MP3 decoder, also written in VB, and provides an abstraction layer to facilitate the decoding process.

This is a very old project since the first version was written for VB6 and although it worked, the code was so damn slow that it was unusable for a real-time MP3 player.
The MP3 decoding stuff is a port from Krister Lagerström‘s C version of the decoder and it was initially ported to VB6 by Murphy McCauley from


An MP3 decoding class for .NET

When Visual Studio 2003 was released I started porting (that is, re-creating by hand) most of my VB6 projects to VB.NET and this was one of them.
As the language matured I started to optimize the code up to the point where the decoder is now able to run without any considerable impact on the CPU. In simpler words, it runs pretty fast.

The quality of the decoded audio is not very good but for basic purposes it does its job and its a nice proof of concept project.

Update (9/2/2012): The library has been updated so that it no longer depends on DirectX’s SDK, instead it relies on the amazing SlimDX library.

Feel free to grab the source code for this project from this link:
VB MP3 Decoder 1.0a [460.91 kB]

  • Thiago

    How to know if the media came at the end?

    • The easiest way is to monitor the StateChanged event and check changes in the State property.
      If Stateis set to “Play” and then changes to “Idle” it means that the playback has stopped.

      To differentiate between a call to the Stop method, which would also set the State property to “Idle”, and an end of play situation, you can compare the value of the Position property with the FileLength property if their value is similar or if the Position is zero or even negative, this would indicate that playback has ended.

  • Akash Rajendra

    I Get an out of memory exception if i try to play BIG Files!! Please Help

    • How large (in MB) is the file you are trying to play?

      • Akash Rajendra

        Its 289 MB..a DJ Remix 🙂

    • Please disregard my last question.
      I just remembered that the vbMP3Decoder.dll will attempt to load the whole file into memory.

      As soon as I have the time, I will update the library so that it loads the file in chunks, and not in its entirely. This will allow it handle files of any size.

      • Akash Rajendra

        Ok Thanks…

      • Akash Rajendra

        OK but can i limit the file size and how can i do it???

  • Gary DeYoung

    Great work on this. This is exactly what I’m looking for – a VB.Net MP3 decoder that uses SlimDX. It works great on my music MP3s, however I’m getting garbled audio when I try to decode and play some mp3’s that I’m creating programmatically. These mp3’s play fine using Managed DirectX, but we are trying to port our app to 64-bit and so we need to migrate to SlimDX. So my question – might you be available for a small bit of consulting? Basically, I would just need this library updated to support the mp3’s I’m creating. Not sure why they aren’t working, but I’d be happy to send you a sample mp3 file and of course, pay you for your time. You can e-mail me at, if you are interested. Thank you!

  • Oren

    There is an option to create button
    that “jump” 5 seconds back?

    • Sure; you can do it your self by controlling the Position property of the player.