Audio signal processing method and apparatus, electronic device, and storage medium
This application discloses an audio signal processing method and apparatus, an electronic device, and a storage medium. The method includes: determining, when a first audio signal is a single-frequency signal or a frequency-sweeping signal and a frequency point of the first audio signal belongs to a target frequency band, a power protection gain based on a power and the frequency point of the first audio signal; and performing compression processing on the first audio signal based on the power protection gain.
1 . An audio signal processing method, comprising:
determining, when a first audio signal is a single-frequency signal or a frequency-sweeping signal and a frequency point of the first audio signal belongs to a target frequency band, a power protection gain based on a power and the frequency point of the first audio signal; and
performing compression processing on the first audio signal based on the power protection gain.
2 . The audio signal processing method according to claim 1 , wherein before the determining, when the first audio signal is the single-frequency signal or the frequency-sweeping signal and the frequency point of the first audio signal belongs to the target frequency band, the power protection gain based on the power and the frequency point of the first audio signal, the method further comprises:
performing frequency response compensation processing on a second audio signal to obtain the first audio signal,
wherein the second audio signal is an audio signal to be output through a speaker.
3 . The audio signal processing method according to claim 1 , wherein the determining the power protection gain based on the power and the frequency point of the first audio signal comprises:
determining a first gain based on the power of the first audio signal, and determining a second gain based on the frequency point and a gain model of the first audio signal; and
determining the power protection gain based on the first gain and the second gain,
wherein the gain model is used to map the relationship between the frequency point and the gain.
4 . The audio signal processing method according to claim 3 , wherein before the determining the second gain based on the frequency point and the gain model of the first audio signal, the method further comprises:
determining a gain model based on an equal loudness contour of target loudness and the target frequency band.
5 . The audio signal processing method according to claim 3 , wherein the determining the first gain based on the power of the first audio signal comprises:
determining the first gain as a preset value when the power of the first audio signal exceeds the target power,
wherein the preset value is less than 1.
6 . The audio signal processing method according to claim 1 , wherein the performing the compression processing on the first audio signal based on the power protection gain comprises:
performing the compression processing on the first audio signal based on the power protection gain and a temperature protection gain obtained in advance.
7 . The audio signal processing method according to claim 6 , wherein before the performing the compression processing on the first audio signal based on the power protection gain and the temperature protection gain obtained in advance, the method comprises:
predicting an instantaneous temperature of a speaker; and
when a prediction result of the instantaneous temperature of the speaker exceeds a maximum safe temperature, determining the temperature protection gain based on the prediction result of the instantaneous temperature of the speaker.
8 . An electronic device, comprising:
a memory storing a computer program; and
a processor coupled to the memory and configured to execute the computer program to perform operations comprising:
determining, when a first audio signal is a single-frequency signal or a frequency-sweeping signal and a frequency point of the first audio signal belongs to a target frequency band, a power protection gain based on a power and the frequency point of the first audio signal; and
performing compression processing on the first audio signal based on the power protection gain.
9 . The electronic device according to claim 8 , wherein before the determining, when the first audio signal is the single-frequency signal or the frequency-sweeping signal and the frequency point of the first audio signal belongs to the target frequency band, the power protection gain based on the power and the frequency point of the first audio signal, the operations further comprise:
performing frequency response compensation processing on a second audio signal to obtain the first audio signal,
wherein the second audio signal is an audio signal to be output through a speaker.
10 . The electronic device according to claim 8 , wherein the determining the power protection gain based on the power and the frequency point of the first audio signal comprises:
determining a first gain based on the power of the first audio signal, and determining a second gain based on the frequency point and a gain model of the first audio signal; and
determining the power protection gain based on the first gain and the second gain,
wherein the gain model is used to map the relationship between the frequency point and the gain.
11 . The electronic device according to claim 10 , wherein before the determining the second gain based on the frequency point and the gain model of the first audio signal, the operations further comprise:
determining a gain model based on an equal loudness contour of target loudness and the target frequency band.
12 . The electronic device according to claim 10 , wherein the determining the first gain based on the power of the first audio signal comprises:
determining the first gain as a preset value when the power of the first audio signal exceeds the target power,
wherein the preset value is less than 1.
13 . The electronic device according to claim 8 , wherein the performing the compression processing on the first audio signal based on the power protection gain comprises:
performing the compression processing on the first audio signal based on the power protection gain and a temperature protection gain obtained in advance.
14 . The electronic device according to claim 13 , wherein before the performing the compression processing on the first audio signal based on the power protection gain and the temperature protection gain obtained in advance, the operations comprise:
predicting an instantaneous temperature of a speaker; and
when a prediction result of the instantaneous temperature of the speaker exceeds a maximum safe temperature, determining the temperature protection gain based on the prediction result of the instantaneous temperature of the speaker.
15 . A non-transitory computer-readable storage medium, storing a computer program, when the computer program is executed by a processor, causes the processor to perform operations comprising:
determining, when a first audio signal is a single-frequency signal or a frequency-sweeping signal and a frequency point of the first audio signal belongs to a target frequency band, a power protection gain based on a power and the frequency point of the first audio signal; and
performing compression processing on the first audio signal based on the power protection gain.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein before the determining, when the first audio signal is the single-frequency signal or the frequency-sweeping signal and the frequency point of the first audio signal belongs to the target frequency band, the power protection gain based on the power and the frequency point of the first audio signal, the operations further comprise:
performing frequency response compensation processing on a second audio signal to obtain the first audio signal,
wherein the second audio signal is an audio signal to be output through a speaker.
17 . The non-transitory computer-readable storage medium according to claim 15 , wherein the determining the power protection gain based on the power and the frequency point of the first audio signal comprises:
determining a first gain based on the power of the first audio signal, and determining a second gain based on the frequency point and a gain model of the first audio signal; and
determining the power protection gain based on the first gain and the second gain,
wherein the gain model is used to map the relationship between the frequency point and the gain.
18 . The non-transitory computer-readable storage medium according to claim 17 , wherein before the determining the second gain based on the frequency point and the gain model of the first audio signal, the operations further comprise:
determining a gain model based on an equal loudness contour of target loudness and the target frequency band.
19 . The non-transitory computer-readable storage medium according to claim 17 , wherein the determining the first gain based on the power of the first audio signal comprises:
determining the first gain as a preset value when the power of the first audio signal exceeds the target power,
wherein the preset value is less than 1.
20 . The non-transitory computer-readable storage medium according to claim 15 , wherein the performing the compression processing on the first audio signal based on the power protection gain comprises:
performing the compression processing on the first audio signal based on the power protection gain and a temperature protection gain obtained in advance.