Common Knowledge Points in Audio Embedded Product Development

Common Knowledge Points in Audio Embedded Product Development1. Digital Gain Adjustment Method 20 * ln x = 8dB, calculating the value of x gives the multiple of the digital gain to be increased.

for(int i=0;i<samples;i++){ pcm[i] = pcm[i] * powf(10.0,要调节增益大小/20.0);}

2. Dynamic Range Formula

Dynamic Range = 20 * log( Maximum Value / Minimum Value)

Example: The integer range represented by a 16-bit fixed-point DSP is 1-65536, and its dynamic range is 20 * log(65536/1) = 96dB, while 1 bit is 20 * log(2/1) = 6dB.

3. Signal-to-Noise Ratio Calculation Formula

For 16-bit audio, the best test result for the signal-to-noise ratio is: SNR = 20 * lg(65536/1) = 96dB. For 24-bit audio, the best test result for the signal-to-noise ratio is: SNR = 144dB.

4. Unit Introduction

dBSPL, commonly referred to as dB, uses sound pressure as the measured quantity, with a reference value of 20μPa.

dBm, uses power as the measured quantity, with a reference value of 1mW.

dBu, uses voltage as the measured quantity, with a reference value of 0.775V.

dBV, similar to dBu, uses voltage as the measured quantity, with a reference value of 1V.

dBFS, unlike the above quantities which measure analog values, dBFS measures digital audio, with the reference value being the maximum sample value at 0dBFS, and all other values being negative. For example, for a 16-bit unsigned digital audio sample, the maximum value is 65536, thus the calculation formula for dBFS is: dBFS = 20 * lg(sample/65536), making the minimum value 20 * lg(1/65536) = -96dB, hence its dynamic range is 0~-96dBFS.

5. Amplitude Calculation Formula

for(int j = 0;j < nsample;j++){ fudu0 = pow(pd0[j],2)+ fudu 0; fudu1 = pow(pd1[j],2)+ fudu 1;} fudu 0 = fudu 0/nsample; fudu 1 = fudu 1/nsample;

6. Common Audio Processing Algorithms

Noise suppression, commonly referred to as noise reduction. This type of noise reduction distinguishes between human voice and non-human voice, treating non-human voice as noise. An audio segment containing both human voice and noise, after processing through this module, theoretically only retains the human voice.

The principle of webrtc‘s ns is as follows: it uses the data from the first 50 frames before activation to construct a noise model, and the signal strength from the first 200 frames to calculate the normalized spectral difference. Based on these two models, a probabilistic objective function is used to calculate the signal-to-noise ratio for each frame and distinguish between noise and sound. Then, using the calculated signal-to-noise ratio in the frequency domain, a Wiener filter is applied to eliminate the noise signal, and finally, the data after noise reduction is repaired and adjusted based on the energy ratio before and after noise reduction and the signal noise likelihood ratio.

ANC (Active Noise Control) works by collecting external environmental noise through a microphone, then transforming it into an inverted sound wave that is added to the speaker output. The final sound heard by the ear is: environmental noise + inverted environmental noise, where the two noises combine to achieve noise reduction.

ENC (Environmental Noise Cancellation) technology uses a dual-microphone array to accurately calculate the direction of the speaker’s voice, while removing various interference noises from the environment. It can effectively suppress up to 90% of reverse environmental noise, thus reducing environmental noise by more than 35dB. (ANC makes the listening environment quieter, while ENC makes the listening environment on the other end of the call quieter.)

AEC is an Acoustic Echo Canceller, which can eliminate various delayed echoes.

Echo is a clear, distinguishable repeated sound that occurs when sound encounters distant obstacles (such as valleys or walls) and reflects back after a long time (usually ≥50 milliseconds). It is similar to a “mirror of sound”: after the original sound is emitted, part of the energy is directly received by the ear, while another part is reflected by the obstacle. Due to the distance, there is a noticeable time gap between the reflected sound and the original sound, making it sound like a “repeated copy”. For example, shouting “hello” in a valley and hearing a clear “hello” echo a few seconds later is a typical echo.

Room Reverb is the “sustained residual sound” formed by sound reflecting multiple times, densely, and in a short time within a closed space (such as a room or hall). After the sound is emitted, it is repeatedly reflected by multiple surfaces such as walls, ceilings, and furniture. The time interval between the reflected sound and the original sound is very short (usually <50 milliseconds), and the number of reflections is extremely high, ultimately merging into a continuous “sound tail” that cannot distinguish individual reflections, but presents as a “natural continuation” of sound. For example, speaking in an empty room gives a feeling of “echoing sound”, which is reverb.

Common Knowledge Points in Audio Embedded Product Development

AGC (Automatic Gain Control is a system that automatically adjusts gain. In simpler terms, when the speaker’s voice is too loud, AGC will automatically reduce the gain to maintain a constant volume during the meeting; conversely, if the speaker’s voice is too soft, AGC will automatically increase the gain to ensure the system remains at a constant volume.

7. Calculation Formula for the Number of Bytes Transmitted for Different Frame Lengths of Audio Data

Example: 5ms frame length, 48k sampling rate, 16bit

The number of bytes to be transmitted for each 5ms frame is ((sampling rate * bit depth) / (8bit * 1000ms)) * 5 —> 480 bytes. Similarly, if the frame length is 2.5ms, it would be 240 bytes.

However, generally, audio wireless transmission does not send all 480 or 240 bytes of data, but compresses it before sending, greatly reducing the pressure on wireless transmission bandwidth. The compression rate corresponding to a 64k bitrate is: (64k / sampling rate * bit depth).

The calculation formula for the actual number of bytes transmitted per frame after compression is: Number of bytes to be transmitted per frame * Compression rate. Thus, the actual number of bytes transmitted for a 5ms frame length is 40, and for a 2.5ms frame length, it is 20.

That’s all for today, I will continue to add more later~

Leave a Comment