AcmNotPossible calling acmStreamOpen, naudio

别说谁变了你拦得住时间么 提交于 2019-12-12 20:03:47

问题


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.


回答1:


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);


来源:https://stackoverflow.com/questions/13628145/acmnotpossible-calling-acmstreamopen-naudio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!