如何用静音填充音频流

时间:2014-04-03 12:57:18

标签: c# naudio

我有一个ISampleProvider我想用10秒的沉默来填充,我将如何在NAudio中实现这一目标?

  var songDelayed = new AudioFileReader(filePath_1);

    //Delay "songDelayed" by 10 secs
    //What do I do here?

    myDirectSoundObj.Init(songDelayed);
    myDirectSoundObj.Play();

1 个答案:

答案 0 :(得分:3)

您可以使用OffsetSampleProvider

执行此操作
var songDelayed = new AudioFileReader(filePath_1);


var offset = new OffsetSampleProvider(songDelayed);

offset.DelayBy = TimeSpan.FromSeconds(10);
// or if you don't have latest NAudio source:
// offset.DelayBySamples = songDelayed.WaveFormat.SampleRate * 
//     songDelayed.WaveFormat.Channels * 10;


myDirectSoundObj.Init(offset);
myDirectSoundObj.Play();