views:

1264

answers:

6

I'm looking for a good audio compression library for .NET. Anything using MP3 is out (because of the licensing issue). Basically I just need to be able to compress regular WAV audio data into some format, and decompress back to WAV. Preferably the code would be all .NET (C# or VB.NET), but I don't think this is likely. It should either be lossless or relatively lossless (as good as 192 MP3s, preferably), with a compression ratio at least as good as 4:1. I'd prefer a buffer-based API, but a file-based API is OK too.

Does anyone know of anything like this?

+1  A: 

You might look into OGG codecs. I'm not sure if there are any written in .NET, but it's open source, so if this is important to you, you should be able to to port one easily enough.

OGG Vorbis codec

Matthew Scharley
Define "easily". :)
MusiGenesis
True enough. "Easy" compared to writing/designing your own?
Matthew Scharley
I've written my own (non-FFT) algorithm, but it only gets 2:1. I at least understand conceptually how MP3-style compression works, better than I understand how the OGG Vorbis code is structured.
MusiGenesis
+2  A: 

You've thought about the .OGG format yet? I don't know if a .net library is available, but the libogg and libvorbis C libs aren't rocket-science and well tested. For a simple compress/decompress job you may get away with a two function wrapper that handles all the details.

It should be easy to write a .net wrapper around them.

Benefits:

  • patent free
  • usable licence even for closed source projects
  • very good compression ratio
  • cross platform (maybe not that important since you aim .net, but nevertheless nice to have).
  • last but not least: a very mature library without known bugs and good support.
Nils Pipenbrinck
I was hoping to find something to use that wouldn't turn into a major project in and of itself. My C is too weak and old to figure out the libvorbis code.
MusiGenesis
You can use C DLL's in .NET easily enough. You might need to watch your marshalling, but it's possible.
Matthew Scharley
I want to support Windows and Windows Mobile, so I'd need to compile different versions of the DLL, and I'm way took weak at C to figure out how to do that.
MusiGenesis
+1  A: 

FLAC looks interesting.

MusiGenesis
Depending on the content you're encoding, you might be struggling to hit the 2:1 compression you mentioned above. For music (well... the bulk of my CD collection, anyway), I can only compress to an average of about 68%.
moobaa
Yeesh, that's terrible. Thanks for warning me.
MusiGenesis
FLAC is lossless. That's actually really good for a lossless algorithm. There's only so much info you can compress without losing some of it.
Matthew Scharley
+1  A: 

Monkey's Audio is another one (it might even work in .NET).

MusiGenesis
+2  A: 

Have you thought about using WMA? If you use managed C++ or C++/CLI it's very easy to write a managed wrapper around the Windows Media Format SDK. This assembly can then be easily used by a higher level VB.Net or C# assembly. As long as you have WMP installed it even has the advantage of not requiring any additional dependencies.

Stu Mackellar
A: 

Have a look at FMod. Is has good audio compression, playing, as well as 3d effects features. It supports lots of audio formats. It is written in C but has a good C# wrapper along with it.

[[http://www.fmod.org/]]

codymanix