2014-04-03 52 views
1

我有一個ISampleProvider我想沉默10秒鐘,我如何在NAudio中實現這一點?如何填充沉默的音頻流

var songDelayed = new AudioFileReader(filePath_1); 

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

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

回答

2

您可以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(); 
做到這一點