简体   繁体   中英

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.

I read the file with RawSourceWaveStream and then do:

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.

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.

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?

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:

  1. I have a raw pcm file (without wav header) sample rate=9600, bits per sample=16, channels=mono
  2. I create a wav file from the raw
  3. I read this wav file and convert it to adpcm file sample rate=9600, bits per sample=4, channels=mono
  4. I read the encoded adpcm file and try to play it but without success

All the steps done with NAudio.

I checked the signal of all output files (raw, wav, adpcm) and the signal looks correct. The check done with 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).

The raw sample rate is 9600 is it can make problem?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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