문제

I have an ISampleProvider I want to pad with 10 seconds of silence, how would I achieve this in NAudio?

  var songDelayed = new AudioFileReader(filePath_1);

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

    myDirectSoundObj.Init(songDelayed);
    myDirectSoundObj.Play();
도움이 되었습니까?

해결책

You can do this with 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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top