Convert WAV to WMA using .NET
Asked Answered
M

5

7

What is the best solution for converting WAV files to WMA (and vice versa) in C#? I have actually implemented this once already using the Windows Media Encoder SDK, but having to distribute Windows Media Encoder with my application is cumbersome to say the least. The Windows Media Format SDK has large sections of the API marked as deprecated. It looks like there might be some DirectX Media Objects (DMOs) I could use from the Windows SDK, but there would be an awful lot of interop to write.

I am wondering if there perhaps is a good managed wrapper for an unmanaged library that can perform the conversions. It would need a license that allows it to be distributed as part of a closed source commercial application.

Maltzman answered 15/9, 2008 at 16:11 Comment(1)
Do you have any samples of converting a wma to wav? All samples I've seen have only been wav to wmaFireresistant
F
1

I haven't tried it personally (so not sure if it's the 'best' solution), but http://www.codeproject.com/KB/audio-video/WmaCompressor.aspx looks like it should meet your requirements...

Fruge answered 15/9, 2008 at 16:29 Comment(1)
yes, I think this is the most promising solution available at the moment. The same author has also done a C# port of the Windows Media Format SDK. My only concern is that it is very unclear whether the code can be used in a commercial project.Maltzman
S
1

You can take a look at the BASS library. It has add-ons, such as BASSWMA and BASSEnc for doing encoding/decoding. All its API's are accessible from .NET using the BASS.Net wrapper.

Both BASS and BASS.Net could be licensed for commercial use, with a reasonable fee (€100 each).

Stretto answered 18/9, 2008 at 10:39 Comment(0)
F
1

If you're comfortable writing a bit of C++/CLI then you don't need much code to create a wrapper around DirectShow to do this. This can then be called directly from a C# assembly with no need to mess about with interop. Doing it with DirectShow is much easier than using WMF directly because you don't have to do any file parsing or I/O - it's all done for you. For reference, I have code in a commercial app that can encode/decode WMA to/from WAV files in less than 100 lines of C++, all wrapped up in a friendly .Net class. Judicious use of smart pointers helps if you go down this route...

Felid answered 17/10, 2008 at 15:34 Comment(0)
L
1

First of all, look at this:

http://windowsmedianet.sourceforge.net/

Then, search for IWMWritter - and various ways of initializing it. You will supply raw PCM data, and it will write out wma file.

Tag my answer please for more info on this.

Lakes answered 2/9, 2010 at 9:32 Comment(0)
H
0

You might look at www.mitov.com. There are some libraries there that may help. You'll need to buy a copy to ship in a commercial product, I believe, but I think it's a reasonable price.

Hemipterous answered 20/10, 2008 at 17:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.