开发者

How does one programmatically mix multiple audio tracks into one track?

开发者 https://www.devze.com 2023-02-08 20:51 出处:网络
What is the algorithm used by Audacity (or any other audio editing program) 开发者_StackOverflow中文版to mix separate sound tracks?

What is the algorithm used by Audacity (or any other audio editing program) 开发者_StackOverflow中文版to mix separate sound tracks?

ie. what is the process of merging the tracks to a single one when the "Mix and Render" command is used.


you just add the signals.

// fill the destination (output) with the sum of signals: input1, input2, input3
for (size_t idx(0); idx < samplesToWrite; ++idx) {
    output[idx] = input1[idx] + input2[idx] + input3[idx];
}

to apply volume or panning to a signal, use multiplication.

// to halve the amplitude of an audio signal:
const double halfVolume = 0.5;
for (size_t idx(0); idx < samplesToWrite; ++idx) {
    signal[idx] *= halfVolume;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号