简体   繁体   English

acmStreamConvert - 目标缓冲区始终为空

[英]acmStreamConvert - destination buffer is always empty

I have an encoded adpcm file (sample rate is 9600 and bit depth is 4) and I want to play it with NAudio.我有一个编码的 adpcm 文件(采样率为 9600,位深度为 4),我想用 NAudio 播放它。

I read the file with RawSourceWaveStream and then do:我使用 RawSourceWaveStream 读取文件,然后执行以下操作:

var reader = new RawSourceWaveStream(new MemoryStream(File.ReadAllBytes(path)), new AdpcmWaveFormat(9600,1));
var convert = WaveFormatConversionStream.CreatePcmStream(reader);
waveOut.Init(new BlockAlignReductionStream(convert));

PS If it makes any difference, I actually envelop the stream with SampleProvider too. PS 如果它有什么不同,我实际上也用 SampleProvider 包围了流。

When I try to play the file, in the acmStreamConvert the destination buffer is always empty and therefore no buffer is filled to the waveOut buffer.当我尝试播放文件时,在 acmStreamConvert 中,目标缓冲区始终为空,因此没有缓冲区填充到 waveOut 缓冲区。

I got no errors in all acm functions include the convert function so I understand that the formats (source and suggested) are correct so why is the buffer returned from the acmConvert - empty?我在所有 acm 函数中都没有错误,包括转换函数,所以我知道格式(来源和建议)是正确的,那么为什么从 acmConvert 返回的缓冲区是空的?

Edit编辑

I adding some info that maybe will help..我添加了一些可能会有所帮助的信息。

That adpcm file that I try to play is file that I created with the following steps:我尝试播放的那个 adpcm 文件是我通过以下步骤创建的文件:

  1. I have a raw pcm file (without wav header) sample rate=9600, bits per sample=16, channels=mono我有一个原始 pcm 文件(没有 wav 标头)采样率 = 9600,每个样本的位数 = 16,通道 = 单声道
  2. I create a wav file from the raw我从原始文件创建了一个 wav 文件
  3. I read this wav file and convert it to adpcm file sample rate=9600, bits per sample=4, channels=mono我阅读了这个 wav 文件并将其转换为 adpcm 文件采样率 = 9600,每个样本的位数 = 4,通道 = 单声道
  4. I read the encoded adpcm file and try to play it but without success我阅读了编码的 adpcm 文件并尝试播放它但没有成功

All the steps done with NAudio.所有步骤都是用 NAudio 完成的。

I checked the signal of all output files (raw, wav, adpcm) and the signal looks correct.我检查了所有输出文件(raw、wav、adpcm)的信号,信号看起来是正确的。 The check done with Audacity.通过 Audacity 完成的检查。

I also tried to read the adpcm with WaveFileReader but then in the read method of WavFormatConversionStream the 'count' is always zero (because the blockalign check).我还尝试使用 WaveFileReader 读取 adpcm 但随后在 WavFormatConversionStream 的读取方法中,“计数”始终为零(因为块对齐检查)。

The raw sample rate is 9600 is it can make problem?原始采样率为 9600 会出问题吗?

One more thing, I just saw that WaveFileWriter can't create files with bit per sample=4 so my encoded file actually created with 16 bits per sample and not 4.还有一件事,我刚刚看到 WaveFileWriter 无法创建每个样本位 = 4 的文件,所以我的编码文件实际上是用每个样本 16 位而不是 4 位创建的。

Most likely the file is compressed by a third-party packer.该文件很可能是由第三方打包程序压缩的。 If you are trying to decode game audio, try digging into the dump of the game during startup.如果您正在尝试解码游戏音频,请尝试在启动期间挖掘游戏的转储。

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

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