hi..
i am recording from my sound device.
iam using the WaveFileWriter to record the incoming data to a wav file.
it should be saved as pcm format
now i am doing the following
WaveFileWriter writer;
this.writer = new WaveFileWriter(this.outputFilePath, this.waveIn.WaveFormat);
this.bufferedWaveProvider = new BufferedWaveProvider(this.waveIn.WaveFormat);
// should be enough to buffer 1 minute in front
this.bufferedWaveProvider.BufferDuration = new TimeSpan(0, 1, 0);
this.bufferedWaveProvider.DiscardOnBufferOverflow = true;
this.waveIn.ShareMode = WaveInShareMode;
this.waveIn.StartRecording();
...
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
try
{
if (saveToFile)
{
this.writer.Write(e.Buffer, 0, e.BytesRecorded);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
}
whereas the waveIn.WaveFormat looks like this:
this.waveIn.WaveFormat = {32 bit PCM: 48kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22}
AverageBytesPerSecond = 384000
BitsPerSample = 32
BlockAlign = 8
Channels = 2
Encoding = Extensible
ExtraSize = 22
SampleRate = 48000
now when i try to play the recorded wav file on my playback sound device, which has the following properties
MixFormat = {32 bit PCM: 48kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22}
i tried using the AudioFileReader but it gives an exception no driver calling acmformatsuggest
and if i try the MediaFoundationReader i get
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in NAudio.dll
Additional information: Exception from HRESULT: 0xC00D5212
at NAudio.MediaFoundation.IMFSourceReader.SetCurrentMediaType(Int32 dwStreamIndex, IntPtr pdwReserved, IMFMediaType pMediaType)
at NAudio.Wave.MediaFoundationReader.CreateReader(MediaFoundationReaderSettings settings)
and the wave file i recorded has the following properties:
Stereo, 48kHz 32-bit float
Can be downloaded here
if i use audacity to change the float to pcm, then it works.
so my question is
can i tell the writer to write directly to a pcm format?
iam setting the writer waveformat as you can see above, but still it is not working probably.
Any help is really appreciated
thanks in advance