AcmNotPossible calling acmStreamOpen, naudio

2019-07-21 12:18发布

I am trying to convert a

PCM S16 LE (araw)
Mono, Sample rate 22050, Bit pr. sample 16 

to

PCM mulaw (PCM MU-LAW)
Mono, Sample rate 8000hz, Bit pr. sample is 8. 

WaveFormat.CreateMuLawFormat(8000,1) or even a more generic WaveFormat.CreateCustomFormat where I have specified the same WaveFormatEncoding as the source stream is throwing the same exception.

AcmNotPossible calling acmStreamOpen

Am I missing something here?

Any leads will be greatly appreciated.

标签: c# wav naudio
1条回答
对你真心纯属浪费
2楼-- · 2019-07-21 12:42

The ACM mu-law encoder expects its input to be 16 bit. If you're working with mu or a-law, the sample rate is likely to be low as well. The following two lines of code will create a zero-length stream of PCM 16 bit and pass it into a WaveFormatConversionStream to convert it to a-law. It should not throw a "conversion not possible" error unless for some reason you don't have the G.711 encoder installed on your machine.

var s = new RawSourceWaveStream(new MemoryStream(), new WaveFormat(8000,16,1));
var c = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000,1), s);
查看更多
登录 后发表回答