0

我正在使用 NAudio 和 ASIO 播放一系列 wav 文件。我需要使用 ASIO,因为声卡只支持它。我能够以这种方式播放每个 wav:

     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();

现在我需要在 wav 开始之前插入 1 秒的静音。我发现的唯一方法是使用 OffsetSampleProvider,但如果我喜欢这样

     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();

第一个 wav 播放得很好,但是一旦我 stop() waveOutDevice 或者我尝试重新实例化一个新的,程序的执行就会在那个位置停止

System.ExecutionEngineException
Cannot intercept exception. Debugged program can not be continued and properties can not be evaluated.

我不明白为什么。请帮忙。谢谢

4

1 回答 1

0

使用 ASIO,最好只打开一次输出设备,让它播放,然后更改其输入。MixingSampleProvider例如,您可以从用作输入的对象中添加和删除项目。

于 2017-03-04T11:33:25.893 回答