Hi mark,
I used your code from the NAudio Demo. This is the AudioAvailable Function:
Jan
I used your code from the NAudio Demo. This is the AudioAvailable Function:
void asioOut_AudioAvailable(object sender, AsioAudioAvailableEventArgs e)
{
// audio output is dumped to wav file
// output format is ALWAYS 32Bit float, convert with sox if required
var samples = e.GetAsInterleavedSamples();
wavWriter.WriteSamples(samples, 0, samples.Length);
sampleType = e.AsioSampleType ;
//Console.WriteLine((int)sampleType);
}
The Wav-Writer is initialized with fixed settings, maybe that's the trick?!this.wavWriter = new WaveFileWriter(wavPath, new WaveFormat(sampleFrq, channels));
And when hitting the "Stop"button:private void Stop()
{
this.asioOut.Stop();
//this.asioOut.Pause();
if (this.wavWriter != null)
{
this.asioOut.AudioAvailable -= asioOut_AudioAvailable;
this.wavWriter.Flush();//test
this.wavWriter.Close();//test
this.wavWriter.Dispose();
this.wavWriter = null;
}
this.recStateTimer.Enabled = false;
CleanUp();
gbDevice.Enabled= true;
SetButtonStates();
}
Cheers Jan