简体   繁体   English

NAdio ImaAdpcm输入重新采样AcmNotPossible错误

[英]NAdio ImaAdpcm input re sampling AcmNotPossible error

I'm trying to encode audio stream into IMA ADPCM, here is my code. 我正在尝试将音频流编码为IMA ADPCM,这是我的代码。

public Byte[] EncodeDVI(Byte[] source)
        {
            var resampleStream = new AcmStream(new WaveFormat(11025, 16, 1), new ImaAdpcmWaveFormat(11025, 16, 1));
            Buffer.BlockCopy(source, 0, resampleStream.SourceBuffer, 0, source.Length);

            int sourceBytesConverted = 0;
            var convertedBytes = resampleStream.Convert(source.Length, out sourceBytesConverted);
            if (sourceBytesConverted != source.Length)
            {
                Console.WriteLine("We didn't convert everything {0} bytes in, {1} bytes converted");
            }

            var converted = new byte[convertedBytes];
            Buffer.BlockCopy(resampleStream.DestBuffer, 0, converted, 0, convertedBytes);

            return converted;
        }

Each time i run the code i got this error "NAudio.MmException: 'AcmNotPossible calling acmStreamOpen'" 每次我运行代码时,都会收到此错误“ NAudio.MmException:'AcmNotPossible调用acmStreamOpen'”

ACM codecs only have a limited number of conversions they are able to perform. ACM编解码器只能执行有限数量的转换。 You can use the NAudio demo application to explore in more detail what ACM codecs are installed on your system and what they can convert between. 您可以使用NAudio演示应用程序来更详细地研究系统上安装了哪些ACM编解码器以及它们之间可以转换的内容。

I suspect in this case it might be your sample rate that is not supported. 我怀疑在这种情况下,可能不支持您的采样率。 I've written a more detailed guide on format conversion here , which explains how you sometimes need to make your conversion in a few stages. 我已经写了格式转换的更详细的指南在这里 ,这也解释了,有时候你需要使你的转换在几个阶段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM