Hello,
I'm using NAudio library in my C# project for recording audio. I write below the description of my trouble:
Before recording of audio (Wave) starts, a user selects one of available input devices. We want to record audio in 16bits and sample rate of 48kHz so we use WaveFormat object in initialization of WaveFileWriter. The code looks like this:
waveSource = new WaveIn();
waveSource.DeviceNumber = deviceNumber;
WaveFormat waveFormat = new WaveFormat(sampleRate, bits, waveSource.WaveFormat.Channels);
waveSource.WaveFormat = waveFormat;
waveSource.DataAvailable += OnDataAvailable;
waveSource.RecordingStopped += OnRecordingStopped;
memoryStream = new MemoryStream();
waveWriter = new WaveFileWriter(memoryStream, waveSource.WaveFormat);
It works as expected on some sound cards, but the same code has a problem on proffesional high-end sound card. The problem is, that only half of the range is used, i.e. when setting 16bits/sample, the output wave has ranges in <-16384, 16384> or <-2^14, 2^14> instead of <-2^15, 2^15>. Moreover, when I switch bit depth to 8bits/sample, samples are -32640 -32641 -32640 32640 -32640 etc, which is really strange.
Is there any way how to fix this?
Thanks for your help!