Decode MP3 Files natively in .NET using a Managed application written in C#

Robert Burke


Updated 25 Feb 04:
  - New Stream interface
  - ManagedDX sample

Minor rev. 9 Mar 04

Updated 1 Sep 04:
  - Cleaned up interface
  - tekHedd's speed optimization! 
Updated 31 May 15: license changed to LGPL to match JavaLayer's update to that license.

Here's a C# port of JavaLayer, an MP3 decoder for Java written by the JavaZoom team.  Hopefully it will be useful to other people who want to decode Mp3s in .NET managed code.  I've tested it with a variety of MP3s and - props to the JavaZoom team! - it seems to do the trick.

Update 25 Feb 04: This page was getting a bunch of traffic, so I took another bit of time to change the interface to the Mp3Sharp assembly to a single class, Mp3Sharp.Mp3Stream, which derives from System.IO.Stream, and provides the decoded data as a 16-bit stereo, PCM-encoded bytestream.  I also wrote a sample, using Managed DirectSound 9.0b, that shows how to play a streaming MP3 file.  Hopefully that will be helpful for people getting started.   

I used Beta2 of the Java Language Conversion Assistant as a starting point for this project, and spent the rest of the day cleaning up after it.  There were some bizarre bit-shifting bugs introduced by the JLCA that I corrected.  I also removed the dependency on serialized files. 

Honestly, this was a half-day project that's taken on a life of its own, so please forgive the state of the code. 
But I welcome comments, requests, suggestions and contributions

Download Mp3Sharp: C# Port of JavaLayer

Note: Mp3Sharp is released under the LGPL. Go nuts.