开发者

NAudio - control which ACM codec used

I'm using NAudio to convert mp3 to WAV, using the WaveFormatConversionStream.CreatePcmStream() method.

As I understand it, this asks the OS about the available ACM开发者_JS百科 codecs and then chooses one.

How do I control which ACMs are used, or set a priority for them? Is there an option for that in the Windows OS or in NAudio?

Currently it seems to be using the ones that come with Windows Media Player, and they fail for certain mp3s that play/convert fine in other places.

Basically I want to tell it to use a decent codec.


Under the hood it calls acmFormatSuggest to try to find its way to a conversion to PCM. You can actually set the priority in Windows for each installed ACM. I used to know how to get to this in Windows XP but I don't know where Windows 7 keeps the equivalent dialog. There are ways to specify exactly which ACM driver you want using acmDriverEnum and acmDriverOpen.

I did implement this capability for ACM filters (i.e. effects not codecs) with an extra constructor on the AcmStream class to allow a driver Id and a WaveFilter to be passed in. You could try calling this with a null WaveFilter and the driver Id of your selected ACM codec using AcmDriver.EnumerateAcmDrivers or AcmDriver.FindByShortName. I'm afraid I didn't put a constructor onto WaveFormatConversionStream that let you pass in your own AcmDriver though, so you'd have to make your own mod.

Also, what MP3s does it fail for, and what is the error message? It may be an MP3 frame parsing issue rather than the codec. Also, NAudio has an alternative MP3 frame decoder - the DmoMp3FrameDecompressor, which may give better results although isn't available on XP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜