filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.14k stars 450 forks source link

Concatenate multiple m4a files. #444

Open Jozefpodlecki opened 3 years ago

Jozefpodlecki commented 3 years ago

Hello,

Are there any samples which show how to combine multiple m4a audio files?

I tried to do something like:

var audioClips = new[]
{
    "sample1.m4a",
    "sample2.m4a",
};

var firstClip = CodecFactory.Instance
    .GetCodec(audioClips.First())
    .ToSampleSource();

foreach (var audioClip in audioClips.Skip(1))
{
    var clip = CodecFactory.Instance
        .GetCodec(audioClip);

    firstClip.AppendSource((x) => {
        return clip;
      });
}

But I think this is too naive.