Search code examples
.netmonomp3wavoggvorbis

How to decode wav, mp3, and/or ogg in .Net/Mono?


I am looking for a cross-platform (.Net and Mono on Windows, MacOSX, and Linux) way to decode wav, mp3, or ogg files such that I can then play the decoded streams through DirectSound or OpenAL as desired.

A solution that can decode either mp3 or ogg would be sufficient -- decoding both is not necessary. If it (or another solution) can decode wav as well, that would be ideal, but isn't strictly necessary since I could potentially convert my wav files to mp3 or ogg.

A solution that can only decode wav files is only a partial solution, but I'll take what I can get. ;-)

Here's what I've already looked at:

  • DirectSound and Alut both support WAV decoding, but Alut has been deprecated.
  • ffmpeg will decode just about anything, but it doesn't seem to have a common stable release across platforms?
  • I have not tried csvorbis yet, but it's very old and I'm not sure what its current status is.

You are more than welcome to try to pursuade me that one of these above solutions is actually the best option.

Thanks.


Solution

  • For simple support for WAV files you can look at mono's implementation in mcs/class/System/System.Media/AudioData.cs (http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/System/System.Media/).

    For decoding ogg audio files you can look at the csvorbis module in mono's sn server: http://anonsvn.mono-project.com/viewvc/trunk/csvorbis/