About audio mixing algorithms

1. Commonly used mixing algorithms

Explanation : The mixing algorithm is the process of operating multiple audio input signals according to certain rules (multiple audio signals are added and then limited), to obtain a mixed audio, and use it as an output process.

There are basically the following mixing algorithms:

a>Add multiple audio input signals directly and take the sum as output;
b>After directly adding and summing multiple audio input signals, divide by the number of mixing channels to prevent overflow;
c>Use multiple audio input signals After directly adding and summing, do a Clip operation (limit the data between the maximum value and the minimum value), and set the maximum value if there is overflow;

d> After directly adding the multi-channel audio input signals, perform saturation processing, and perform distortion when approaching the maximum value;

e> After directly adding up the multi-channel audio input signals, perform normalization processing, and multiply them all by a coefficient to normalize the amplitude;

f>After directly adding the multiple audio input signals, use the attenuation factor to limit the amplitude;

2. Precautions

Not any two audio streams can be mixed directly.
Two audio and video streams must meet the following conditions before they can be mixed:

  • 1) The format is the same and needs to be decompressed into PCM format;
  • 2) The sampling rates are the same and must be converted to the same sampling rate. Mainstream sampling rates include: 16k Hz, 32k Hz, 44.1k Hz and 48k Hz;
  • 3) The frame length is the same, and the frame length is determined by the encoding format. PCM has no concept of frame length, and the developer decides the frame length by himself. In order to be consistent with the frame length of mainstream audio encoding formats, it is recommended to use 20ms as the frame length;
  • 4) The bit-depth (Bit-Depth) or sampling format (Sample Format) is the same, and the number of bits carrying the data of each sampling point must be the same;
  • 5) The number of channels is the same, and must also be mono or dual channels (stereo). In this way, after aligning the format, sampling rate, frame length, bit depth, and number of channels, the two audio streams can be mixed.

3. Volume adjustment

IIS only handles data transmission and does not have volume control. There are three main ways to control volume:

1. Directly reducing the corresponding data in data processing is equivalent to reducing the volume (scaling the data proportionally);

2. Control the part after the DAC output on the output, that is, add attenuation after the DAC to reduce the volume;

3. The power amplification part after the DAC reduces the amplification ratio to reduce the final output volume;

Guess you like

Origin blog.csdn.net/Damon_Sandy/article/details/130343171