0

I am attempting to use the NAudio lib like the below. When I have a WAV file saved as Mono, 4KHz, the AudioBytesOriginal array has all zeroes. The file does play when double-clicked in Windows, so the data is there. It also plays in Audacity.

using ( var waveFileReader = new WaveFileReader( FileNameIn ) )
                {
                    var thisIsWhat = waveFileReader.WaveFormat; // reports as 8KHz
                    AudioBytesOriginal = new byte[waveFileReader.Length];
                    int read = waveFileReader.Read( AudioBytesOriginal , 0 , AudioBytesOriginal.Length );
                    short[] sampleBuffer = new short[read/2];
                    Buffer.BlockCopy( AudioBytesOriginal , 0 , sampleBuffer , 0 , read );

                }

I need the extremely low sample rate for playback on a limited device, but am using .NET Framework 4.6.1 with NAudio to handle the byte work.

Thanks.

Snowy
  • 5,942
  • 19
  • 65
  • 119

1 Answers1

0

a couple of things to check

1) what is the value of read? Is it 0?

2) how far into sampleBuffer did you check? Even half a second of silence at the start of an audio file will result in several thousand samples with 0 value

Mark Heath
  • 48,273
  • 29
  • 137
  • 194
  • read value is 16184. samplebuffer is 8092, value of zero in every array element. – Snowy Jun 09 '16 at 23:56
  • i can send you the original wav (16k) if you need it. – Snowy Jun 10 '16 at 00:07
  • what about audio bytes original. is that all zeros? – Mark Heath Jun 10 '16 at 07:06
  • Original is not all zeroes. I discovered that nAudio can resample so I will see if I can load at 8KHz and then lower it http://mark-dot-net.blogspot.com/2014/05/how-to-resample-audio-with-naudio.html?m=1 – Snowy Jun 10 '16 at 13:26