Pergunta

How can I convert a wave with Encoding: ALaw, SampleRate: 8000, BitsPerSample: 8, Channels: 1, Block Align Channels: 1, Bits per Second: 8000 to wave with pcm encoding and the same parameters of first wave? I'v been use ALawDecoder from http://www.codeproject.com/Articles/14237/Using-the-G711-standard, now I have an array of shorts (not bytes)! how can I convert short array to byte array and play it using NAudio.WaveOut and how can I write it to a wave file?

Foi útil?

Solução

You decode Alaw into PCM, which is 16 BitsPerSample - that's why you end up with an array of shorts.

You could use Buffer.BlockCopy() to copy them into a byte[]:

byte[] result = new byte[shortArray.Length * sizeof(short)];
Buffer.BlockCopy(shortArray, 0, result, 0, result.Length);

Outras dicas

Instead of this long path, I used this simple line of code :

WaveFormatConversionStream conv = new WaveFormatConversionStream(WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, 8000, 1, 16000, 2, 16), inputStream);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top