[英]Concatenating Audio using NAudio
I am trying to concatenate multiple audio files together using NAudio. 我正在尝试使用NAudio将多个音频文件连接在一起。
I have collection of byte arrays, where the byte arrays represent the individual audio tracks. 我有字节数组的集合,其中字节数组代表各个音频轨道。
var samples = new List<ISampleProvider>();
foreach (var item in collection) {
ISampleProvider tempAudio = new RawSourceWaveStream(new MemoryStream(item), new WaveFormat()).ToSampleProvider();
samples.Add(tempAudio);
}
var playlist = new ConcatenatingSampleProvider(samples);
WaveFileWriter.CreateWaveFile("playlist.wav", playlist.ToWaveProvider());
However, the audio that is saved to the file "playlist.wav" does not sound like the audio before attempting to concatenate it. 但是,保存到文件“ playlist.wav”的音频在尝试串联之前听起来不像是音频。 The audio sounds much faster and incoherent.
音频听起来更快且不连贯。
What audio format are the "items" in collection? 集合中的“项目”是哪种音频格式? The
WaveFormat
you provide to RawSourceWaveStream
must exactly match the audio in item
. 您提供给
RawSourceWaveStream
的WaveFormat
必须与item
中的音频完全匹配。 You're just creating a default WaveFormat
which IIRC is going to be 44.1kHz 16 bit stereo 您只是在创建默认的
WaveFormat
,而IIRC将是44.1kHz 16位立体声
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.