Multi-segment equalizer automatic pre-gain compensation method, system, device and storage medium
By calculating the combined gain value of the full-band scanning frequency points and pre-injecting the pre-gain compensation value, the problem of accurate assessment and prevention of clipping risk in multi-band equalizers is solved, realizing high-fidelity and high-flexibility audio signal processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- LINKPLAY TECHNOLOGY INC NANJING
- Filing Date
- 2026-04-13
- Publication Date
- 2026-06-19
AI Technical Summary
Existing technologies make it difficult to accurately predict clipping risks in the signal link gain management of multi-band equalizers, leading to clipping distortion and sound quality degradation. Furthermore, traditional protection solutions limit users' tuning freedom or affect audio quality.
By responding to equalizer parameter change events, the combined gain value of the full-band scanning frequency points is calculated, and the pre-gain compensation value is calculated based on the maximum combined gain. This value is then injected into the audio signal link preamplifier using smooth transition control to dynamically prevent clipping risks.
It enables accurate assessment and prevention of clipping risks, maintains high fidelity of audio signals and user tuning freedom, and improves the system's real-time protection capabilities and user experience.
Smart Images

Figure CN122245338A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital audio signal processing technology, and in particular to a method, system, device and storage medium for automatic pre-gain compensation of a multi-band equalizer. Background Technology
[0002] With the rapid development of digital audio processing technology, audio playback devices are showing a significant trend towards intelligence and personalization. Against this backdrop, to meet users' deep demands for customized sound, parametric equalizers (PEQs) and graphic equalizers (GEQs) have become indispensable core functional modules in audio equipment. Users can achieve fine-grained frequency adjustments to audio signals by applying positive gain boosts or negative attenuations across various frequency bands. However, the layering of multi-band equalizers introduces the technical challenge of managing signal link gain margin. Traditional techniques typically address this by using manual volume adjustment, end-limiting protection, or hard limiting of single-band gain.
[0003] The manual volume adjustment scheme relies on the user's auditory experience to actively reduce the master volume or output gain to avoid clipping. However, since ordinary users usually lack professional knowledge of the signal link gain structure, it is difficult to accurately predict and reserve sufficient safety margin in the complex configuration of multi-band equalizer superposition. In actual operation, clipping distortion often occurs due to adjustment lag or improper amplitude, which limits the system's real-time protection capability. The end-limiting protection scheme deploys a soft limiter or hard limiter at the output of the equalizer link. Once the signal level exceeds the preset threshold, the limiter compresses or flattens the signal peak. However, the limiter's non-linear processing of dynamic signals introduces perceptible harmonic distortion and dynamic compression, damaging the original sound quality of the audio. Furthermore, the limiter only operates at the end of the signal chain and cannot prevent internal spillover distortion that occurs in the intermediate stages of the equalization processing nodes, affecting the overall purity and fidelity of the system's sound quality. While the single-band gain hard limiting scheme controls the upper limit of each equalization gain from the source, effectively avoiding clipping risks, as users' demand for greater freedom in deep tuning increases, the hard upper limit sacrifices user operational flexibility and is difficult to meet the customization needs of professional users and audiophiles for complex equalization curves. In addition, the above protection schemes are all based on single-dimensional risk control. When users simultaneously enable multiple high-gain frequency bands with overlapping effects, even if the individual band gains do not exceed the limits, the combined gain across the entire frequency band may still far exceed the system's margin, and the entire signal chain will still fall into a clipping distortion state, making it difficult to guarantee continuous high-quality audio output.
[0004] In practical applications, the contribution of gain settings across different frequency bands in the equalizer link to clipping risk varies significantly. A few positive high-gain bands and their overlapping areas are the main sources of clipping risk, requiring extremely high precision in gain margin management. Conversely, most negative attenuation bands or low-gain bands contribute relatively little to clipping risk. However, traditional equalizer protection designs, once the protection mechanism is determined, struggle to dynamically adapt, employing a uniform, fixed strategy for all frequency band configurations. This forces audio systems to adopt a comprehensive protection layout based on the worst-case clipping risk, resulting in excessive restrictions on user tuning freedom or unnecessary signal compression. Consequently, audio systems struggle to balance sound quality and operational flexibility, exhibiting significant shortcomings in terms of economy and practicality. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of existing technologies and to provide an automatic pre-gain compensation method for multi-band equalizers, comprising the following steps: In response to equalizer parameter change events, calculate the frequency response amplitude of each enabled equalizer section on the full-band scan frequency point array; For each scanned frequency point, the frequency response amplitudes of all enabled equalizer sections are algebraically added in the decibel domain to obtain the combined gain value of that frequency point, and the maximum combined gain across the entire frequency band is extracted from the set of combined gain values of all scanned frequency points. If the maximum combining gain is greater than zero, then a negative pre-gain compensation value is calculated based on the maximum combining gain; The pre-gain compensation value is injected into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band. The injection process of the pre-gain compensation value is smoothly transition-controlled to eliminate the risk of clipping while avoiding perceptible volume jumps.
[0006] Preferably, the equalizer section includes at least one of the parametric equalizer (PEQ) section, graphic equalizer (GEQ) section, and room correction (RC) section. All types of equalizer sections are uniformly included in the global equalizer section linked list in the gain scan calculation and are traversed in the manner of equivalent nodes, so that when there is frequency overlap between adjacent frequency bands, the combined gain of the overlapping area can be accurately captured. The change event includes at least one of the following: gain value change, center frequency change, quality factor change, and enable state change; The full-band scanning frequency point array is an array that is logarithmically uniformly distributed in the range of 20Hz to 20kHz.
[0007] Preferably, the response to a change event in the equalizer parameters includes: Register change listeners on the global equalizer section linked list to monitor changes in the gain, center frequency, quality factor, or enable status of any equalizer section. Upon receiving the change event, a scan trigger is initiated at the next processing block boundary of the current audio processing thread; Based on the trigger signal, all enabled equalizer sections are extracted from the global equalizer section list as a unified input for the scan calculation.
[0008] Preferably, the method further includes a debouncing mechanism after receiving the change event: Upon receiving the change event, start or reset a silent window timer of a preset duration; The full-band gain scan process is triggered only when the silent timing window has been fully completed and no new change events have been received during the period. If a new change event is received within the silent timing window, the silent timing window is reset to ensure that only a single full scan is performed on the final parameter configuration after the operation has stabilized.
[0009] Preferably, the frequency response amplitude of each enabled equalizer section is calculated on the full-band scanning frequency point array, including: For each scanning frequency point in the scanning frequency point array, each enabled equalizer section is traversed. Based on the filter type, center frequency, gain value, and quality factor of the equalizer section, the corresponding filter transfer function amplitude response rule is used to calculate its frequency response amplitude at that scanning frequency point.
[0010] Preferably, the frequency response amplitudes at each frequency point are superimposed in the decibel domain to obtain the maximum combining gain, including: For each scanned frequency point, the frequency response amplitudes of all enabled equalizer sections at that frequency point are algebraically summed in the decibel domain to obtain the combined gain value of that frequency point. Traverse all scanned frequency points and extract the maximum value from the obtained set of combined gain values as the maximum combined gain value.
[0011] Preferably, calculating a negative pre-gain compensation value based on the maximum combined gain includes: Get the peak factor statistics of the currently playing audio content within a preset duration; The peak factor is obtained by performing an exponentially weighted average of the statistical values of the peak factor; The smoothing peak factor is continuously mapped to a dynamic safety margin value via an S-shaped function; The sum of the maximum combined gain value and the dynamic safety margin value is inverted and used as the pre-gain compensation value.
[0012] Preferably, the pre-gain compensation value is injected into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band, including: Identify several independent equalizer levels in the audio signal link, and independently calculate the corresponding level pre-gain compensation value for each independent equalizer level. The pre-gain compensation values of each level are serially superimposed in the order of the signal flow to generate a global pre-gain compensation value. The global pre-gain compensation value is injected into the position after the audio decoding output and before all equalizer processing nodes in the form of a uniform digital gain attenuation across the entire frequency band. When a user-defined pregain is detected, the automatic global pregain compensation value and the user-defined pregain are injected into the signal link in a series superposition manner. The two are calculated independently and do not overlap with each other.
[0013] Preferably, calculating the pre-gain compensation value further includes an asynchronous processing step: The calculation tasks for frequency response amplitude and maximum combined gain are assigned to separate background worker threads for asynchronous execution; After the background worker thread completes the calculation, the obtained pre-gain compensation value is written to the shared memory through an atomic write operation; The real-time audio processing thread reads the pre-gain compensation value from the shared memory at the boundary of the next audio processing block and applies it.
[0014] Preferably, the injection process of the pre-gain compensation value is subject to smooth transition control, including: Obtain the difference between the newly calculated target pre-gain compensation value and the currently effective pre-gain compensation value; Select the corresponding transition strategy based on the positive or negative direction of the difference; When a negative difference is detected, indicating that the attenuation needs to be increased to prevent clipping risk, the current pre-gain compensation value is updated to the target pre-gain compensation value using the first transition duration. When a positive difference is detected, indicating that the attenuation needs to be reduced to restore the signal level, a second transition duration longer than the first transition duration is used to smoothly transition the current pre-gain compensation value to the target pre-gain compensation value.
[0015] Preferably, the smooth transition process corresponding to the second transition duration is implemented using a first-order exponential smoothing algorithm, including: Within each audio processing block time step, the current pre-gain compensation value is updated exponentially weighted according to a preset time constant, so that the current pre-gain compensation value gradually converges to the target pre-gain compensation value. When the absolute value of the difference between the current pre-gain compensation value and the target pre-gain compensation value is less than a preset convergence threshold, the current pre-gain compensation value is directly set to the target pre-gain compensation value to complete a smooth transition.
[0016] Preferably, it also includes a real-time clipping detection and emergency hardening mechanism: A real-time clipping detector is deployed at the end of the audio signal link to detect whether the amplitude of the output signal exceeds a preset safety threshold at each sampling point. When a preset safety threshold is detected, an emergency pre-gain reinforcement is triggered. The currently effective pre-gain compensation value is directly reduced by a preset step value for the first transition time, and a clipping alarm log containing a timestamp, the pre-gain compensation value at the time of triggering, and an equalizer configuration snapshot is recorded.
[0017] Preferably, it also includes a dynamic safety margin adaptive update mechanism based on clipping alarm logs: Perform statistical analysis on the trigger events recorded in the clipping alarm log and extract the peak factor features of the corresponding audio content at the time of triggering; When the frequency of clipping alarm triggering for similar audio content exceeds a preset threshold, the dynamic safety margin corresponding to that type of audio content is increased by a preset increment so that subsequent similar content can have a greater gain protection margin. The updated dynamic safety margin is persisted and stored for use when calculating the pre-gain compensation value next time.
[0018] Based on the same concept, the present invention also provides a multi-segment equalizer automatic pre-gain compensation system, including an equalizer gain scanning module, a maximum combined gain calculation module, a pre-gain automatic compensation module, and a smooth transition control module. The equalizer gain scanning module, the maximum combined gain calculation module, the pre-gain automatic compensation module, and the smooth transition control module are connected in the audio signal processing link; The equalizer gain scanning module is used to calculate the frequency response amplitude of each enabled equalizer section on the full-band scanning frequency point array in response to equalizer parameter change events. The maximum combined gain calculation module is used to algebraically add the frequency response amplitudes of all enabled equalizer sections in the decibel domain for each scan frequency point to obtain the combined gain value of that frequency point, and extract the full-band maximum combined gain from the set of combined gain values of all scan frequency points. The pre-gain automatic compensation module is used to calculate a negative pre-gain compensation value based on the maximum combined gain if the maximum combined gain is greater than zero, and inject the pre-gain compensation value into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band. The smooth transition control module is used to perform smooth transition control on the injection process of the pre-gain compensation value, so as to eliminate the risk of clipping while avoiding perceptible volume jumps.
[0019] Based on the same concept, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, it implements the steps of the multi-segment equalizer automatic pre-gain compensation method as described in the embodiments.
[0020] Based on the same concept, the present invention also provides a computer-readable storage medium, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors perform the steps of the multi-segment equalizer automatic pre-gain compensation method as described in any one embodiment.
[0021] Compared with the prior art, the beneficial effects of the present invention are: (1) This invention calculates the frequency response amplitude of each enabled equalizer section on a preset full-band scanning frequency point array in response to equalizer parameter change events, and algebraically adds the frequency response amplitudes of each frequency point in the decibel domain to extract the maximum combined gain value of the entire frequency band, thereby achieving accurate reconstruction of the full-band gain response of the entire equalizer link. Compared with the traditional scheme that only focuses on the maximum gain of a single segment, this invention can accurately capture the hidden gain peak caused by the overlap of multiple equalization frequency bands, thus ensuring the accuracy of clipping risk assessment and the precision of pre-gain compensation.
[0022] (2) This invention injects the calculated negative pre-gain compensation value into the equalizer link before the first equalizer processing node in the equalizer link in the form of uniform attenuation across the entire frequency band. This achieves pre-attenuation of the signal level before it enters any frequency-selective gain adjustment. Compared with the traditional approach of setting a limiter at the end of the link, this invention fundamentally eliminates the risk of signal overflow at the processing node inside the equalizer link. Moreover, the uniform attenuation across the entire frequency band does not change the relative strength relationship between the frequency components. While eliminating the risk of digital clipping, it fully preserves the equalization effect set by the user, and has high fidelity and high transparency.
[0023] (3) This invention achieves immediate protection by smoothly controlling the injection process of the pre-gain compensation value. When it detects the need to increase the attenuation to prevent clipping risk, it adopts a fast transition mode to achieve immediate protection. When it detects the need to reduce the attenuation to restore the signal level, it adopts a slow transition mode to avoid perceptible volume surges. Compared with traditional solutions that involve abrupt changes in compensation value or fixed-rate transitions, this invention balances the real-time responsiveness of clipping protection with the smooth continuity of the listening experience, making the protection process transparent and imperceptible to the user, resulting in a high user experience.
[0024] (4) This invention automatically executes the complete process of full-band scanning, maximum gain extraction, compensation value calculation, and pre-injection, responding to equalizer parameter changes and applying corresponding protections in real time without user intervention. Compared to traditional solutions that rely on users manually lowering the volume, this invention eliminates users' concerns about clipping risks in complex equalizer overlay scenarios, allowing users to freely overlay any number and any gain of equalizer bands without worrying about clipping distortion. While ensuring system security, it significantly improves the operational freedom and usage depth of the equalizer function, exhibiting high practicality and flexibility. Attached Figure Description
[0025] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention.
[0026] Figure 1 This is a flowchart of an automatic pre-gain compensation method for a multi-segment equalizer according to the present invention; Figure 2 This is a schematic diagram of an automatic pre-gain compensation system for a multi-segment equalizer according to the present invention; Figure 3 This is a schematic diagram of one embodiment of the computer device of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. Obviously, the described embodiments are only some, not all, of the embodiments described in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without creative effort are within the scope of protection of this application.
[0028] Those skilled in the art will understand that, unless otherwise stated, the singular forms “a” and “an” used herein, and “the”, may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0029] First Embodiment Please see Figure 1 As shown, this embodiment provides an automatic pre-gain compensation method for multi-band equalizers, applied to the equalizer processing signal link of audio equipment, including the following steps: S1: The equalizer gain scanning module responds to equalizer parameter change events by calculating the frequency response amplitude of each enabled equalizer section on the full-band scanning frequency point array.
[0030] This step aims to detect any parameter adjustments made by the user to the equalizer link in real time, and after confirming that the adjustment is stable, trigger a precise calculation of the full-band gain response, providing an accurate data foundation for subsequent clipping risk assessment. The specific implementation process includes three main stages: parameter change monitoring and jitter reduction processing, construction of a scanned frequency point array, and point-by-point frequency response calculation.
[0031] Preferably, the equalizer section includes at least one of a parametric equalizer (PEQ) section, a graphic equalizer (GEQ) section, and a room correction RC section. All types of equalizer sections are uniformly incorporated into a global equalizer section linked list during gain scan calculations, and traversed as equivalent nodes. This ensures that when adjacent frequency bands overlap, the combined gain of the overlapping area can be accurately captured. Specifically, in this embodiment, all equalization processing units, such as the parametric equalizer (PEQ) section, graphic equalizer (GEQ) section, and room correction RC section, are uniformly abstracted into a standardized equalizer section structure for management. Each equalizer section includes attributes such as filter type (e.g., Peak, Low Shelf, High Shelf, High Pass, Low Pass), center frequency, gain, quality factor, and enable status. Change events include at least one of the following: gain value change, center frequency change, quality factor change, and enable state change; The full-band scanning frequency point array is an array logarithmically uniformly distributed within the range of 20Hz to 20kHz, generated by the following formula: Where i = 0, 1, 2, ..., N-1, and N is the total number of scan frequency points. In this embodiment, N is 1024, and the scan frequency points are distributed according to a logarithmic law, with dense sampling in the low-frequency region and relatively sparse sampling in the high-frequency region, ensuring balanced capture accuracy of gain changes across the entire frequency band. This array is calculated once during system initialization and stored in a high-speed cache, and then reused for each subsequent scan.
[0032] In one implementation scenario, a user configured five equalizer sections on the equalizer interface of a WiiM Amp Ultra audio device: Equalizer 1 (peak type, center frequency 80Hz, gain +7dB, Q=1.2, enabled); Equalizer 2 (peak type, center frequency 200Hz, gain +4dB, Q=2.0, enabled); Equalizer 3 (peak type, center frequency 1kHz, gain -3dB, Q=1.5, enabled); Equalizer 4 (high-frequency shelving type, center frequency 8kHz, gain +5dB, Q=0.7, enabled); and Equalizer 5 (peak type, center frequency 12kHz, gain +3dB, Q=1.0, enabled). The total positive gain of the equalizer sections is approximately +19dB, initially indicating a high risk of clipping.
[0033] Preferably, the response to a change event in the equalizer parameters includes: A change listener is registered on the global equalizer section linked list to monitor changes in the gain, center frequency, quality factor, or enable status of any equalizer section. When a user modifies these attributes of any equalizer section on the audio device interface, the change is immediately captured by the listening logic, generating an internal parameter change notification. For example, if a user adjusts the gain of equalizer section 4 (high-frequency shelf type, center frequency 8kHz) from the initial +5dB to +8dB, the system receives the parameter change event and prepares to start the gain scan process at the end of the current audio processing block (approximately 10ms later). Upon receiving a change event, a scan trigger is initiated at the next processing block boundary of the current audio processing thread; Based on the trigger signal, all enabled equalizer sections are extracted from the global equalizer section list as a unified input for the scan calculation. Specifically, in this embodiment, the system maintains a global equalizer section list, in which all enabled equalizer sections are arranged in the order of the signal flow.
[0034] Preferably, to avoid frequent triggering issues caused by users making rapid and continuous adjustments, a debouncing mechanism is also included after receiving a change event: Upon receiving a change event, start or reset a silent window timer for a preset duration; The full-band gain scan process is triggered only when the silent timing window has been fully completed and no new change events have been received during the timeout. If a new change event is received within the silent timing window, the silent timing window is reset to ensure that only a single complete scan is performed on the final parameter configuration after the operation has stabilized. For example, when a user adjusts the 80Hz band, continuously dragging the slider generates more than ten intermediate gain values. The system resets the 50ms timer each time the slider position changes. When the user's finger leaves the screen and the slider finally stops at the +7dB position, approximately 50ms later, the parameter is confirmed to be stable, and the scan process is initiated. Throughout the entire process, the system performs only one complete scan, avoiding unnecessary consumption of computational resources. As another example, if a user repeatedly enables / disables the +8dB equalizer section 4 at a frequency of 3 times per second in EQ comparison mode, the system detects continuous rapid switching events. Each event resets the 50ms silent timer, and the actual scan calculation is only performed once at the end of the 50ms silent window after the last switch. The total number of calculations is reduced from the theoretical 3 times per second to less than 0.5 times per second, and the CPU utilization remains stable.
[0035] After triggering the scanning process, parameter snapshots of all currently enabled equalizers are extracted from the global equalizer list. In this embodiment, the set of equalizers to be processed includes: equalizer 1 (peak type, center frequency 80Hz, gain +7dB, Q value 1.2), equalizer 2 (peak type, center frequency 200Hz, gain +4dB, Q value 2.0), equalizer 3 (peak type, center frequency 1kHz, gain -3dB, Q value 1.5), equalizer 4 (high-frequency shelf type, center frequency 8kHz, gain +5dB, Q value 0.7), and equalizer 5 (peak type, center frequency 12kHz, gain +3dB, Q value 1.0), for a total of 5 enabled equalizers.
[0036] Preferably, the frequency response amplitude of each enabled equalizer section is calculated on the full-band scanning frequency point array, including: For each scan frequency point in the scan frequency point array, iterate through each enabled equalizer section, and calculate its frequency response amplitude at that scan frequency point based on the filter type, center frequency, gain value, and quality factor of that equalizer section, using the corresponding filter Biquad transfer function amplitude response rule.
[0037] For example, for equalizer 1 (80Hz, +7dB, Q=1.2), its amplitude response is calculated to be approximately +7.0dB at the scan frequency point f=80Hz; at f=40Hz, the amplitude response decays to approximately +2.3dB; at f=160Hz, the amplitude response is approximately +2.1dB; and at f=20Hz, the amplitude response approaches 0dB. For equalizer 4 (8kHz high-frequency shelf, +8dB), the amplitude response is approximately +8.0dB at f=8kHz, also close to +8.0dB at f=16kHz, and approximately +4.0dB at f=4kHz.
[0038] S2: For each scanned frequency point, the maximum combining gain calculation module receives the frequency response amplitude, performs algebraic summation of the frequency response amplitudes of all enabled equalizer sections in the decibel domain to obtain the combining gain value of that frequency point, and extracts the full-band maximum combining gain from the set of combining gain values of all scanned frequency points.
[0039] This step is the core of the quantitative assessment of clipping risk, aiming to accurately capture the true gain peak generated by the multi-band equalizer after frequency domain superposition, especially the hidden gain superposition effect caused by the overlap of adjacent frequency bands.
[0040] Preferably, the frequency response amplitudes at each frequency point are superimposed in the decibel domain to obtain the maximum combining gain, including: For each scanned frequency point, the maximum combining gain calculation module algebraically adds the frequency response amplitudes of all enabled equalizer sections at that frequency point in the decibel domain to obtain the combining gain value for that frequency point. As shown below: The physical meaning of this operation is that in the cascaded link of the minimum phase system, the total frequency response amplitude is equal to the sum of the decibel values of the frequency response amplitudes of each stage.
[0041] Specifically, in this embodiment, at the scanning frequency point f=80Hz, the contributions of each equalizer section are as follows: equalizer section 1 contributes +7.0dB, equalizer section 2 (center frequency 200Hz) contributes approximately +0.3dB, and equalizer sections 3 to 5 all contribute close to 0dB, which can be ignored. Therefore, the combined gain at f=80Hz is +7.3dB. At the scanning frequency point f=8kHz, equalizer section 4 (high-frequency shelf) contributes +8.0dB, equalizer section 5 (center frequency 12kHz) contributes approximately +1.8dB at 8kHz due to frequency band overlap, and the contributions of the remaining equalizer sections at 8kHz are negligible. Therefore, the combined gain at f=8kHz is +9.8dB. Traverse all scanned frequency points (1024 scanned frequency points), extract the maximum value from the obtained set of combined gain values, and use it as the maximum combined gain value. The formula is as follows: , i=0,1,...,1023. In this embodiment, after the full-band scan is completed, the maximum value of the combining gain occurs at f=8kHz. This value represents the maximum positive gain that a broadband audio signal can achieve after passing through the link under the current equalizer link configuration.
[0042] Specifically, at the scanning frequency point f=122Hz (located in the overlapping region between the two peak filters at 80Hz and 200Hz), equalizer section 1 contributes approximately +4.7dB, and equalizer section 2 contributes approximately +3.8dB, resulting in a combined gain of +8.5dB. This value is higher than the set gain of any single equalizer section and represents a hidden gain peak caused by the overlap of frequency bands. Using only the maximum gain of a single band as the basis for risk assessment would severely underestimate the actual clipping risk.
[0043] S3: If the maximum merging gain is greater than zero, the pre-gain automatic compensation module calculates a negative pre-gain compensation value based on the maximum merging gain.
[0044] This step aims to calculate a safe and reasonable pre-attenuation amount based on the maximum combined gain value obtained from the scan, combined with the dynamic characteristics of the audio content, to ensure that the signal link does not exceed the clipping threshold at any frequency point.
[0045] First, determine if the maximum combined gain is greater than 0dB. If the maximum combined gain is less than or equal to 0dB, it indicates that the current equalizer link exhibits attenuation or no gain characteristics, and there is no risk of clipping. The pre-gain compensation value is set to 0dB, and the subsequent compensation process is terminated. If the maximum combined gain is greater than 0dB, it is determined that there is a risk of clipping, and the compensation value calculation process begins.
[0046] Preferably, a negative pre-gain compensation value is calculated based on the maximum combined gain, using a peak factor continuous dynamic margin mapping algorithm based on a sigmoid function, including: The peak factor statistics of the currently playing content within a preset duration are obtained. The peak factor is defined as the ratio between the instantaneous peak level of the signal and the average effective level. A higher value indicates a larger dynamic range and stronger transient impact. To eliminate the influence of single-frame fluctuations on the margin calculation, the measured peak factor CF(t) is first subjected to an exponentially weighted average to obtain the smoothed perceived peak factor. , Where λ is the exponential smoothing coefficient, with a value ranging from (0,1). The smaller the value of λ, the longer the smoothing time constant and the slower the response. In this embodiment, λ is set to 0.1.
[0047] Subsequently, the peak smoothing factor will be applied. Continuously mapped to dynamic safety margin using the sigmoid function. The mapping formula is: ,in, This is the lower limit of the margin, corresponding to the minimum protection margin for extremely low transient content such as pure tones and sine waves; This is the upper limit of the margin, corresponding to the maximum protection margin for high transient content such as percussion and large dynamic symphonic music; The inflection point peak factor value of the S-shaped curve, when equal At that time, the output margin is exactly 1 / 2. α is the kurtosis coefficient of the S-curve, in units of... The transition rate of the control margin as the peak factor changes is α. The larger the value of α, the steeper the curve and the more rapid the transition from the lower limit to the upper limit; e is the base of the natural logarithm. In this embodiment, the parameters are configured as follows: , , α=0.5 .
[0048] For example, the currently playing content is a classical symphony piece. The perceptual peak factor is obtained by analyzing nearly 10 audio samples and performing exponential smoothing. It is 14dB. Substituting into the S-shaped mapping formula, the result is calculated as follows: That is, the dynamic safety margin is output at approximately 1.87 dB after continuous mapping.
[0049] Maximum merged gain value With dynamic safety margin value Inverting the sum yields the pre-gain compensation value, Pre-gain, calculated using the following formula: Substitute =+9.8dB, The calculated Pre-gain is -(9.8+1.87) = -11.67dB. This value indicates that a uniform attenuation of 11.7dB across the entire frequency band needs to be applied at the front end of the equalizer link to suppress the net gain at the worst frequency point (f=8kHz) to -1.87dB, leaving sufficient safety buffer space.
[0050] For example, when the playback content switches to pop vocals, the perceived peak factor... Approximately 8dB, calculated using the S-shaped mapping formula: If at this time If it remains at +9.8dB, then Pre-gain = -(9.8+0.94) = -10.74dB. The attenuation is reduced compared to the symphony scene, preserving more effective dynamics.
[0051] When playing content such as a continuous sine wave from an electronic synthesizer or other extremely low transient content, the perceived peak factor is... Approaching 3dB, substituting into the calculation yields... ≈0.38dB, close to the lower limit The system retains only the minimum necessary margin to avoid applying unnecessary over-compression to the signal dynamically.
[0052] In the three typical scenarios mentioned above, the dynamic safety margins are approximately 0.38dB, 0.94dB, and 1.87dB, respectively, showing a smooth and continuous increase, which fundamentally eliminates the step change in margin at the threshold boundary in traditional discrete grading schemes.
[0053] The SCFM algorithm used in this embodiment offers at least four improvements in technical performance compared to traditional discrete grading schemes: Firstly, it eliminates abrupt changes in the margin. Traditional three-level schemes experience a 0.5dB jump in the dynamic safety margin when the peak factor crosses the 12dB or 6dB threshold. Even with subsequent smooth transition control, this can still introduce perceptible volume fluctuations during pre-gain adjustments. The SCFM algorithm defines the margin mapping as... The family of continuous functions with α as parameters has a continuously differentiable margin curve across the entire range, eliminating the step jump in margin calculation from the source. When working in conjunction with the smooth transition control module, the overall response is smoother and more natural.
[0054] Secondly, it reduces unnecessary compression of low-transient content. Traditional three-level schemes apply a fixed margin of 0.5dB to content with a peak factor below 6dB, while the SCFM algorithm allows this margin to converge further with the peak factor. Under the parameter configuration of this embodiment, for extremely low transient content such as pure tones and electronic synthesizers, the margin can converge to close to 0.3dB, which is about 0.2dB more effective dynamic range than the traditional solution, resulting in a more open and natural listening experience.
[0055] Third, the protection margin for high transient content is more ample. The traditional three-tier scheme has a fixed upper limit of 1.5dB, while the SCFM algorithm... It can be configured to 2.0dB or even higher. In this embodiment, for large dynamic symphonic content with a peak factor of 14dB, the margin output is about 1.87dB, which is about 33% higher than the 1.5dB of the traditional solution, and the clipping protection capability is improved, making the protection of high transient content such as percussion more reliable.
[0056] Fourth, the patent protection scope is broader and more difficult to circumvent. The protection scope of traditional discrete grading schemes is limited to specific thresholds and the number of gradations. Competitors can easily bypass this by simply changing three gradations to four gradations or fine-tuning the threshold. The SCFM algorithm defines the residual mapping as a family of continuous functions. Any implementation that uses a continuous monotonic mapping from the peak factor to the residual falls within the protection scope of this scheme.
[0057] To further improve computational efficiency and avoid blocking real-time audio processing during scanning calculations, an asynchronous background execution mechanism is adopted. The frequency response calculation and maximum combined gain extraction tasks are assigned to background worker threads independent of the real-time audio processing thread. Upon completion, the calculated pre-gain compensation target value is written to a shared memory region via atomic write operations. The real-time audio processing thread then reads and applies this value at the boundary of its next processing block. For example, if a user simultaneously enables 5-band PEQ, 10-band GEQ, and 15 double second-order equalizers for room correction, totaling 20 equalizer sections, the full-frequency scan calculation takes approximately 1.8 milliseconds. After the background thread completes the calculation, it uses atomic write operations to... The data is written to shared memory, and the main audio thread reads and initiates a smooth transition at the next processing block boundary 10ms later, with no audio stuttering or noise throughout. The total latency from when the user stops operating to when protection takes effect is no more than 65 milliseconds, providing near real-time protection to the user.
[0058] S4: The pre-gain automatic compensation module injects the pre-gain compensation value into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band.
[0059] This step is the execution stage of clipping protection. It aims to pre-attenuate the signal level before it enters any frequency-selective gain adjustment by injecting it in advance, thereby fundamentally eliminating the risk of signal overflow in the processing nodes inside the equalizer link.
[0060] Preferably, the pre-gain compensation value is injected into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band, including: First, determine the injection point of the pre-gain compensation value in the audio signal chain. This point is located after the audio decoding output and before all equalizer processing nodes, i.e., at the very beginning of the chain. The core logic of this pre-injection principle is that if an equal amount of attenuation is placed at the end of the equalizer chain, the internal level of the signal has been progressively increased as it flows through each positive gain equalizer section, and the overflow distortion at intermediate nodes is irreversible. Pre-injection ensures that the signal is suppressed as a whole before entering any gain boost stage, guaranteeing that the signal level at all nodes within the entire processing chain is within a safe range.
[0061] In this embodiment, the audio signal processing link structure is as follows: Audio decoding PCM output → Pre-gain injection point (-11.7dB full-band attenuation) → Equalizer 1 (80Hz +7dB) → Equalizer 2 (200Hz +4dB) → Equalizer 3 (1kHz -3dB) → Equalizer 4 (8kHz +8dB) → Equalizer 5 (12kHz +3dB) → Digital volume control → DAC output. At 8kHz: the signal is X-11.7dB after pre-gain, X-3.7dB after equalizer 4 (+8dB), and X-1.9dB after the +1.8dB contribution from EQ section 5. It remains below the original level and will not trigger clipping.
[0062] Identify several independent equalizer levels in the audio signal link (such as user PEQ layer, room correction RC layer, and input source dedicated EQ layer), and independently calculate the corresponding level pre-gain compensation value for each independent equalizer level.
[0063] The pre-gain compensation values of each level are concatenated and superimposed in the order of the signal flow to generate a global pre-gain compensation value. Specifically, in this embodiment, Each layer's Pre-gain is calculated independently and does not interfere with each other, avoiding the problem of excessive attenuation where a layer with no positive gain is mistakenly compressed because other layers have positive gain.
[0064] Example, user PEQ layer The safety margin calculated using the SCFM algorithm is approximately 1.87 dB. The Room Correction layer employs an AllowOnly Cuts constraint that only attenuates and does not boost. , ; Dedicated EQ layer for input source (HDMI input preset + 2dB low-frequency boost) , (Including a 1.0dB safety margin). Global injection: Each layer has a clear division of labor, and the RC layer does not introduce unnecessary additional compression.
[0065] The global pre-gain compensation value is injected as a digital gain with uniform attenuation across the entire frequency band, positioned after the audio decoding output and before all equalizer processing nodes. This converts the decibel-domain pre-gain compensation value into a linear gain factor, uniformly scaling each audio sample point it passes through. Because this factor applies the same attenuation ratio to all frequency components within the 20Hz to 20kHz range, the acoustic effect is a uniform volume reduction across the entire frequency band, without altering the relative strength of the frequency components in the signal, i.e., without changing the user-defined equalization effect.
[0066] For example, suppose the instantaneous level of the input audio signal at a certain moment is -6dBFS. This signal first passes through the pre-injection module, where it is attenuated by 11.7dB, reducing the level to -17.7dBFS. The signal then flows sequentially through each equalizer section. At the worst-case frequency f=8kHz, the equalizer link itself generates a +9.8dB combining gain, raising the signal level from -17.7dBFS to -7.9dBFS. This is well below the 0dBFS clipping threshold at all frequency points, with a safety margin of at least 1.87dB.
[0067] When a user-defined pregain is detected, the automatic global pregain compensation value and the user-defined pregain are injected into the signal link in a series superposition manner. The two are calculated independently and do not overlap with each other.
[0068] Preferably, before calculating the pre-gain compensation value, an asynchronous processing step is also included: The calculation tasks for frequency response amplitude and maximum combined gain are assigned to separate background worker threads for asynchronous execution; After the background worker thread completes the calculation, the obtained pre-gain compensation value is written to the shared memory through an atomic write operation; The real-time audio processing thread reads the pre-gain compensation value from shared memory at the boundary of the next audio processing block and applies it.
[0069] S5: The smooth transition control module performs smooth transition control on the injection process of the pre-gain compensation value to eliminate the risk of clipping while avoiding perceptible volume jumps.
[0070] This step is a crucial part of ensuring user experience, aiming to achieve the optimal balance between the rapid response requirements of clipping protection and the smooth continuity of auditory perception through differentiated transition strategies.
[0071] Preferably, the injection process of the pre-gain compensation value is subject to smooth transition control, including: Obtain the difference between the newly calculated target pre-gain compensation value and the currently effective pre-gain compensation value. The formula is as follows: ; Select the corresponding transition strategy based on the positive or negative direction of the difference; When a negative difference is detected, indicating that the attenuation needs to be increased to prevent clipping risk, the current pre-gain compensation value is updated to the target pre-gain compensation value using the first transition duration (the duration of a single audio processing block, approximately 10 milliseconds) to apply the necessary protection as quickly as possible. When a positive difference is detected, indicating that the attenuation needs to be reduced to restore the signal level, a second transition duration (approximately 500 milliseconds) longer than the first transition duration is used to smoothly transition the current pre-gain compensation value to the target pre-gain compensation value. This slow transition mode gradually adjusts the attenuation in an exponentially gradual manner to match the human ear's auditory perception characteristics of slow volume changes and avoids perceptible volume surges.
[0072] Preferably, it also includes a real-time clipping detection and emergency hardening mechanism: During the smooth transition process corresponding to the second transition duration, a first-order exponential smoothing algorithm is used to gradually adjust the current pre-gain compensation value until the difference between it and the target pre-gain compensation value is less than the preset convergence threshold. A real-time clipping detector is deployed at the end of the audio signal link to detect whether the amplitude of the output signal exceeds a preset safety threshold (such as -0.1dBFS) at each sampling point. When the preset safety threshold is exceeded, emergency pre-gain hardening is triggered, which directly reduces the currently effective pre-gain compensation value by a preset step value (e.g., 1.0dB) and records the clipping alarm log.
[0073] More preferably, the smooth transition process corresponding to the second transition duration is implemented using a first-order exponential smoothing algorithm, with a time constant τ = 150 ms. The current value is updated every 10 milliseconds, including: Within each audio processing block time step, the current pre-gain compensation value is updated exponentially weighted according to a preset time constant, so that the current pre-gain compensation value gradually converges to the target pre-gain compensation value. When the absolute value of the difference between the current pre-gain compensation value and the target pre-gain compensation value is less than a preset convergence threshold, the current pre-gain compensation value is directly set to the target pre-gain compensation value to complete a smooth transition, as shown in the following formula: Where dt=10ms (audio processing block duration). .when Direct order The transition is complete.
[0074] For example, suppose the currently active pre-gain compensation value is -11.7dB. If the user reduces the gain of equalizer section 4 (8kHz high-frequency shelf) from +8dB to +5dB, the system will recalculate the new maximum combined gain value. The safety margin is set at 1.0 dB, and the new target pre-gain compensation value is... ΔPre-gain = +3.4dB, which is a positive change, initiating a slow transition mode. The current values at each time point are as follows: at t = 10ms, At t=20ms, At t=50ms, At t=100ms, At t=200ms, At t=450ms, The difference between the volume and the target value of -8.3dB is less than 0.1dB, indicating a successful transition. Throughout the process, the volume perceived by the user is a very slight, smooth increase lasting about half a second, without any abruptness.
[0075] Conversely, if a user significantly increases the gain of a certain frequency band, causing the target pre-gain compensation value to drop sharply from -8.3dB to -14.0dB (ΔPre-gain = -5.7dB), the system adopts a fast transition mode, directly updating the current value to -14.0dB within a single 10-millisecond processing block to achieve immediate protection.
[0076] Preferably, it also includes user-transparent interaction processing: When injecting pre-gain compensation values, keep the audio device's master volume display value unchanged (the pre-gain change is not reflected in the display volume value). When the pre-gain compensation value is active, a gain protection status indicator icon (such as
GainProtection Active
[0077] To avoid blocking the real-time audio processing thread during scanning calculations, the system assigns the scanning calculation task to a separate background worker thread, which executes in parallel with the real-time audio processing thread. After the scan is completed, the new Pre-gain_target is written to shared memory via an atomic write operation. The audio processing thread reads and applies this value at the next processing block boundary, ensuring that the continuity of audio output is not affected by the scanning calculations.
[0078] The user simultaneously enabled 15 Biquad sections (5 PEQ sections + 10 GEQ sections + Room Correction), totaling 20 EQ sections. The system estimated the full-frequency scan calculation time to be approximately 1.8ms (20 sections × 1024 points × single Biquad calculation). After the background thread completed the calculation, it performed an atomic write operation. Write to shared memory, and the main audio thread reads and starts STCM smoothly at the next processing block boundary 10ms later, with no audio stuttering or noise throughout the process.
[0079] Through steps S1 to S5 described above, this embodiment achieves automatic, real-time, and transparent protection against clipping risks in multi-band parametric equalizer links. Users can obtain continuous and safe audio output without manual intervention when freely overlaying multiple positive gain equalizers, and the protection process has no negative impact on the listening experience.
[0080] Second Embodiment Please see Figure 2 As shown, based on the same concept, the present invention also provides a multi-segment equalizer automatic pre-gain compensation system, including an equalizer gain scanning module, a maximum merging gain calculation module, a pre-gain automatic compensation module, and a smooth transition control module; The equalizer gain scanning module, the maximum merging gain calculation module, the pre-gain automatic compensation module, and the smooth transition control module are connected in the audio signal processing link; The equalizer gain scanning module is used to calculate the frequency response amplitude of each enabled equalizer section on a full-band scanning frequency point array in response to equalizer parameter change events. The maximum combined gain calculation module is used to algebraically add the frequency response amplitudes of all enabled equalizer sections in the decibel domain for each scan frequency point to obtain the combined gain value of that frequency point, and extract the full-band maximum combined gain from the set of combined gain values of all scan frequency points. The pre-gain automatic compensation module is used to calculate a negative pre-gain compensation value based on the maximum combined gain if the maximum combined gain is greater than zero. The pre-gain compensation value is injected into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band. The smooth transition control module is used to smoothly control the injection process of the pre-gain compensation value, so as to eliminate the risk of clipping while avoiding perceptible volume jumps.
[0081] Third Embodiment In this embodiment, a computer device is provided, including a memory and one or more processors. The memory stores computer code. When the computer code is executed by one or more processors, it causes the one or more processors to perform the steps of the automatic pre-gain compensation method for a multi-segment equalizer in the first embodiment.
[0082] In some embodiments of this application, a computer-readable storage medium is also provided, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors perform the steps of a multi-segment equalizer automatic pre-gain compensation method as described in any one of the first embodiments.
[0083] The computer device in this embodiment will be described in detail below from the perspective of hardware processing.
[0084] Please see Figure 3 As shown, the computer device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described method for synchronizing state parameters across terminal devices.
[0085] further, Figure 3 The computer device shown also includes a bus 102 and a communication interface 103, with the processor 100, communication interface 103 and memory 101 connected via the bus 102.
[0086] The memory 101 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0087] The processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 100 or by instructions in software form. The processor 100 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information in memory 101 and, in conjunction with its hardware, completes the method steps of the aforementioned embodiments.
[0088] It is understood that, for the aforementioned multi-segment equalizer automatic pre-gain compensation method, if all components are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer server or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0089] Computer-readable storage media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0090] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A method for automatic pre-gain compensation of a multi-segment equalizer, characterized in that, Includes the following steps: In response to equalizer parameter change events, calculate the frequency response amplitude of each enabled equalizer section on the full-band scan frequency point array; For each scanned frequency point, the frequency response amplitudes of all enabled equalizer sections are algebraically added in the decibel domain to obtain the combined gain value of that frequency point, and the maximum combined gain across the entire frequency band is extracted from the set of combined gain values of all scanned frequency points. If the maximum combining gain is greater than zero, then a negative pre-gain compensation value is calculated based on the maximum combining gain; The pre-gain compensation value is injected into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band. The injection process of the pre-gain compensation value is smoothly transition-controlled to eliminate the risk of clipping while avoiding perceptible volume jumps.
2. The automatic pre-gain compensation method for multi-segment equalizers according to claim 1, characterized in that, The equalizer section includes at least one of the parametric equalizer (PEQ) section, graphic equalizer (GEQ) section, and room correction (RC) section. All types of equalizer sections are uniformly included in the global equalizer section linked list in the gain scan calculation and are traversed in the manner of equivalent nodes, so that when there is frequency overlap between adjacent frequency bands, the combined gain of the overlapping area can be accurately captured. The change event includes at least one of the following: gain value change, center frequency change, quality factor change, and enable state change; The full-band scanning frequency point array is an array that is logarithmically uniformly distributed in the range of 20Hz to 20kHz.
3. The automatic pre-gain compensation method for multi-segment equalizers according to claim 1, characterized in that, In response to equalizer parameter change events, including: Register change listeners on the global equalizer section linked list to monitor changes in the gain, center frequency, quality factor, or enable status of any equalizer section. Upon receiving the change event, a scan trigger is initiated at the next processing block boundary of the current audio processing thread; Based on the trigger signal, all enabled equalizer sections are extracted from the global equalizer section list as a unified input for the scan calculation.
4. The automatic pre-gain compensation method for multi-segment equalizers according to claim 3, characterized in that, The event of the change is followed by a debouncing mechanism: Upon receiving the change event, start or reset a silent window timer of a preset duration; The full-band gain scan process is triggered only when the silent timing window has been fully completed and no new change events have been received during the period. If a new change event is received within the silent timing window, the silent timing window is reset to ensure that only a single full scan is performed on the final parameter configuration after the operation has stabilized.
5. The automatic pre-gain compensation method for multi-segment equalizers according to claim 1, characterized in that, Calculate the frequency response amplitude of each enabled equalizer section on the full-band scan frequency point array, including: For each scanning frequency point in the scanning frequency point array, each enabled equalizer section is traversed. Based on the filter type, center frequency, gain value, and quality factor of the equalizer section, the corresponding filter transfer function amplitude response rule is used to calculate its frequency response amplitude at that scanning frequency point.
6. The automatic pre-gain compensation method for a multi-segment equalizer according to claim 1, characterized in that, Calculate a negative pre-gain compensation value based on the maximum combined gain, including: Get the peak factor statistics of the currently playing audio content within a preset duration; The peak factor is obtained by performing an exponentially weighted average of the statistical values of the peak factor; The smoothing peak factor is continuously mapped to a dynamic safety margin value via an S-shaped function; The sum of the maximum combined gain value and the dynamic safety margin value is inverted and used as the pre-gain compensation value.
7. The automatic pre-gain compensation method for multi-segment equalizers according to claim 1, characterized in that, The pre-gain compensation value is injected into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band, including: Determine several independent equalizer levels in the audio signal link, and independently calculate the corresponding level pre-gain compensation value for each independent equalizer level. The pre-gain compensation values of each level are serially superimposed in the order of the signal flow to generate a global pre-gain compensation value. The global pre-gain compensation value is injected into the position after the audio decoding output and before all equalizer processing nodes in the form of a uniform digital gain attenuation across the entire frequency band. When a user-defined pregain is detected, the automatic global pregain compensation value and the user-defined pregain are injected into the signal link in a series superposition manner. The two are calculated independently and do not overlap with each other.
8. The automatic pre-gain compensation method for a multi-segment equalizer according to claim 1, characterized in that, The calculation of the pre-gain compensation value also includes asynchronous processing steps: The calculation tasks for frequency response amplitude and maximum combined gain are assigned to separate background worker threads for asynchronous execution; After the background worker thread completes the calculation, the obtained pre-gain compensation value is written to the shared memory through an atomic write operation; The real-time audio processing thread reads the pre-gain compensation value from the shared memory at the boundary of the next audio processing block and applies it.
9. The automatic pre-gain compensation method for a multi-segment equalizer according to claim 1, characterized in that, Smooth transition control is performed on the injection process of the pre-gain compensation value, including: Obtain the difference between the newly calculated target pre-gain compensation value and the currently effective pre-gain compensation value; Select the corresponding transition strategy based on the positive or negative direction of the difference; When a negative difference is detected, indicating that the attenuation needs to be increased to prevent clipping risk, the current pre-gain compensation value is updated to the target pre-gain compensation value using the first transition duration. When a positive difference is detected, indicating that the attenuation needs to be reduced to restore the signal level, a second transition duration longer than the first transition duration is used to smoothly transition the current pre-gain compensation value to the target pre-gain compensation value.
10. The automatic pre-gain compensation method for a multi-segment equalizer according to claim 9, characterized in that, The smooth transition process corresponding to the second transition duration is implemented using a first-order exponential smoothing algorithm, including: Within each audio processing block time step, the current pre-gain compensation value is updated exponentially weighted according to a preset time constant, so that the current pre-gain compensation value gradually converges to the target pre-gain compensation value. When the absolute value of the difference between the current pre-gain compensation value and the target pre-gain compensation value is less than a preset convergence threshold, the current pre-gain compensation value is directly set to the target pre-gain compensation value to complete a smooth transition.
11. The automatic pre-gain compensation method for a multi-segment equalizer according to claim 9, characterized in that, It also includes real-time clipping detection and emergency hardening mechanisms: A real-time clipping detector is deployed at the end of the audio signal link to detect whether the amplitude of the output signal exceeds a preset safety threshold at each sampling point. When a preset safety threshold is detected, an emergency pre-gain reinforcement is triggered. The currently effective pre-gain compensation value is directly reduced by a preset step value for the first transition time, and a clipping alarm log is recorded.
12. The automatic pre-gain compensation method for a multi-segment equalizer according to claim 1, characterized in that, It also includes a dynamic safety margin adaptive update mechanism based on clipping alarm logs: Perform statistical analysis on the trigger events recorded in the clipping alarm log and extract the peak factor features of the corresponding audio content at the time of triggering; When the frequency of clipping alarm triggering for similar audio content exceeds a preset threshold, the dynamic safety margin corresponding to that type of audio content is increased by a preset increment so that subsequent similar content can have a greater gain protection margin. The updated dynamic safety margin is persisted and stored for use when calculating the pre-gain compensation value next time.
13. A multi-segment equalizer automatic pre-gain compensation system, characterized in that, It includes an equalizer gain scanning module, a maximum combined gain calculation module, a pre-gain automatic compensation module, and a smooth transition control module; The equalizer gain scanning module, the maximum combined gain calculation module, the pre-gain automatic compensation module, and the smooth transition control module are connected in the audio signal processing link; The equalizer gain scanning module is used to calculate the frequency response amplitude of each enabled equalizer section on the full-band scanning frequency point array in response to equalizer parameter change events. The maximum combined gain calculation module is used to algebraically add the frequency response amplitudes of all enabled equalizer sections in the decibel domain for each scan frequency point to obtain the combined gain value of that frequency point, and extract the full-band maximum combined gain from the set of combined gain values of all scan frequency points. The pre-gain automatic compensation module is used to calculate a negative pre-gain compensation value based on the maximum combined gain if the maximum combined gain is greater than zero, and inject the pre-gain compensation value into the audio signal link after the audio decoding output and before all equalizer processing nodes in the form of uniform attenuation across the entire frequency band. The smooth transition control module is used to perform smooth transition control on the injection process of the pre-gain compensation value, so as to eliminate the risk of clipping while avoiding perceptible volume jumps.
14. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it implements the steps of the automatic pre-gain compensation method for multi-segment equalizers as described in any one of claims 1-12.
15. A computer-readable storage medium, characterized in that, When the computer-readable instructions are executed by one or more processors, the one or more processors perform the steps of the multi-band equalizer automatic pre-gain compensation method as described in any one of claims 1 to 12.