How To pad Audio stream with silence

谁说胖子不能爱 提交于 2019-12-08 08:24:25

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/22838479/how-to-pad-audio-stream-with-silence

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!