I'm using NAudio and ASIO to play a sequence of wav files. I need to use ASIO because the audio card supports only that. I was able to play each wav in this way:
waveRead = new WaveFileReader(completeStreamMS); //completeStreamMS is a memorystream
waveRead.Position = 0;
pcm = new WaveChannel32(waveRead);
reductionStream = new BlockAlignReductionStream(pcm);
reductionStream.Position = 0;
waveOutDevice.Init(reductionStream);
waveOutDevice.Play();
Now I need to insert 1 second of silent before the starting of the wav. The only way I found is to use an OffsetSampleProvider, but if I do like this
ISampleProvider isp = WaveExtensionMethods.ToSampleProvider(waveRead);
var offset = new SampleProviders.OffsetSampleProvider(isp);
offset.DelayBy = TimeSpan.FromSeconds(1);
var wp = new SampleProviders.SampleToWaveProvider(offset);
waveOutDevice.Init(wp);`
waveOutDevice.Play();
The first wav plays just fine, but as soon as I stop() the waveOutDevice or I try to reinstantiate a new one the execution of the program stops at that position with
System.ExecutionEngineException
Cannot intercept exception. Debugged program can not be continued and properties can not be evaluated.
I'm not able to understand why. Please help. Thanks