Summary of the invention
The technical problem that the present invention will solve provides a kind of digital audio automatic gain control method, and distortion does not to a certain degree appear in the signal after it can guarantee to gain, and background noise is not gained.For this reason, the present invention also will provide a kind of DAB AGC system.
For solving the problems of the technologies described above, digital audio automatic gain control method of the present invention, it may further comprise the steps:
(1) the instantaneous power P of calculating input signal x (n)
x(n);
(2) whether be background noise according to the signal in the power detection step (1), the instantaneous power P of input signal in the step (1)
x(n) be lower than and preset power P
Min, be background noise, directly carry out saturated control and output; Instantaneous power P
x(n) greater than presetting power P
Min, get into next step;
(3) upgrade according to the power information and the adaptive-filtering study step-length of the input signal of step (1), upgrade gain coefficient g (n);
(4) utilize new gain coefficient in the step (3), produce new output signal y (n)=g (n) x (n);
(5) calculate the instantaneous power P that exports signal y (n)
yAnd utilize the instantaneous power P of estimation (n),
y(n) with the echo signal power P of preassignment
RefAsk irregular energy, and it is fed back to the gain coefficient lastest imformation of step (3) as next signal;
(6) according to the power P of input signal
x(n), the shaping that gains;
(7) carry out saturated control and outputting digital audio signal.
DAB AGC system of the present invention is used for the automatic gain digital audio and video signals, and it comprises one first power computation module, is used to calculate the power of input signal; One adaptive-filtering module is used to receive the signal from said first power computation module and output, upgrades gain coefficient, and produces new output signal according to new gain coefficient; One second power computation module is used to calculate the power from the adaptive-filtering module output signal, and feedback signal to adaptive-filtering module, as the gain coefficient lastest imformation of next signal; One gain Shaping Module is used for the signal from adaptive-filtering module output is carried out the gain coefficient adjustment, with the excessive situation of reduction gain coefficient with strengthen the too small situation of gain coefficient, the signal of output after the shaping that gains.
DAB AGC system of the present invention and method; Through upgrading the gain coefficient of the digital audio and video signals of importing; And produce new output signal according to the gain coefficient of this renewal, to the shaping that gains of new output signal, excessive gain and strengthen too small gain effect weakens; The digital audio and video signals that distortion to a certain degree do not occur and background noise is not gained after output one gain makes voice after the processing reach perfect distance and holds weighing apparatus level with both hands.
Embodiment
Fig. 1 is the sketch map of DAB AGC system of the present invention, is divided into following functional module:
(1) first power computation module 101.This module is used to calculate the power P of input signal x (n)
x(n), wherein n is the time sequence number.Computing formula can be
P
x(n)=αP
x(n-1)+(1-α)x
2(n) (1)
Wherein α is a smoothing factor, and α is big more, and then variable power is mild more; α is more little, and then power changes with the rapid variation of signal.For the fluctuation that better reflects signal and be unlikely to violent shake, generally select 0<α<<1.
(2) the adaptive-filtering module 103.This module comprises three sub-module: adaptive-filtering study step-length update module, filter factor update module and new output calculated signals module.Filter factor, promptly the more new formula of gain coefficient g (n) does
g(n)=g(n-1)(1+μ(n)P
x(n)(P
ref-P
y(n-1))) (3)
Wherein μ (n) is the study step-length of adaptive-filtering, P
RefBe a constant, representative of consumer expected objective signal energy level.Adaptive-filtering study step-length more new formula does
μ
0Be the constant between 0 to 1, μ
0Value have influence on the convergence rate and the stability of adaptive algorithm, bigger μ
0Can cause restraining faster, but the less stable after the convergence, less μ
0Can make that algorithmic statement is slack-off, but the stability after the convergence better, in order to consider convergence of algorithm speed and stability, operated by rotary motion μ simultaneously
0Between 0 to 0.1.γ approaches 0 the disturbance factor, the constant of scope between 0 to 0.1, and the purpose of γ is in order to prevent that denominator from being 0, so generally get the value below 0.1 in this formula.Utilize new gain coefficient, produce new output signal y (n), computing formula does
(3) second power computation module 102.This module is used to calculate y (n) power P of output signal
y(n), wherein n is the time sequence number.Computing formula can be
P
y(n)=αP
y(n-1)+(1-α)y
2(n) (2)
0<α<<1 wherein.And result of calculation fed back to the gain coefficient lastest imformation of adaptive-filtering module 103 as next signal.
(4) gain Shaping Module 104.Signal from 103 outputs of adaptive-filtering module is carried out the gain coefficient adjustment, and computing formula does
Y (n)=K
1Y (n) (+K
2(P
a-P
x(n))) (work as P
a<P
x(n)<P
b) (6)
P wherein
MinBe the minimum signal power threshold values of gain, instantaneous power is lower than P
MinSignal be background noise, do not carry out gain controlling.K
1And K
2Be constant coefficient, 0.5≤K
1≤1,1≤K
2≤8, K
1Effect be as required the overall magnitude of signal to be certain adjustment, K
1Value is 1 o'clock, and signal integral body does not gain, K
2Effect according to the fluctuation of signal, the adjustment of certain ratio, K are done in the part of signal
2Value can obtain preferably effect during integer 1 between 8.P
aAnd P
bThe lower limit and the upper limit for the signal energy that needs shaping.The purpose of gain shaping is two kinds of situation when adjusting gain coefficient, to occur in order to overcome adaptive filter algorithm: (1) is when gain coefficient is excessive; The energy rank of input signal is also excessive, and it is excessive at this time may to gain, even signal overflows; At this time need do the gain finishing, the reduction gain; When (2) gain coefficient was too small, the energy rank of input signal was too small, and at this time gain effect is obvious inadequately, needed the finishing coefficient, strengthened gain effect.Adaptive filter algorithm has certain robustness, and gain coefficient (weight) is not to change along with the rapid variation of the waveform of signal fully, and the amplitude of coefficient adjustment has certain delay, therefore, need do corresponding gain finishing according to the fluctuation of signal.
Fig. 2 is the flow chart of the inventive method, and it may further comprise the steps:
Step 401, the instantaneous power P of estimation input signal x (n)
x(n), the power calculation method is taked the method for above-mentioned formula (1).
Step 402, whether the power detection of calculating according to step 401 is background noise, the detection method of background noise takes to set P
MinBeing the minimum signal power threshold values, being worth less than this like current demand signal power, then is the direct execution in step 407 of background noise, otherwise order execution in step 403.
Step 403 is upgraded according to power information of calculating and adaptive-filtering study step-length, upgrades gain coefficient g (n), and more new formula is taked above-mentioned formula (3), and the study step-length of adaptive-filtering is upgraded and taked above-mentioned formula (4).
Step 404 is utilized new gain coefficient, produces new output signal, and computing formula is y (n)=g (n) x (n).
Step 405 is calculated the instantaneous power P that exports signal y (n)
y(n), the power calculation method is taked the method for above-mentioned formula (2).And the instantaneous power P of utilization calculating
y(n) with the echo signal power P of user's preassignment
RefAsk irregular energy, and it is fed back to the gain coefficient lastest imformation of step 403 as next signal.
Step 406 is according to the power P of input signal
x(n), the finishing that gains further improves voice quality, and the computational methods of gain shaping are taked the method for above-mentioned formula (6).
Step 407 is carried out saturated control and output signal y (n), and the purpose of saturated control is to overflow for control signal; If input signal is the 16bitPCM code stream; Then saturated control makes the scope of 16bit output signal be [32768 ,+32767], and the output greater than 32767 is set to 32767; Output less than-32768 is set to-32768, and other output is constant.
When importing new voice signal x (n), repeat above step.
Fig. 3 has provided and has used automatic gain control (AGC) method of the present invention that the voice in one period 3 second are carried out process result figure.Fig. 4 has provided the change curve of AGC to the gain coefficient of this section voice; Gain coefficient (original gain coefficient) that does not pass through shaping and the contrast of passing through the gain coefficient of shaping have been write down; It is thus clear that after the gain trimming, the voice signal of output balance more is harmonious; And when background noise, gain coefficient equals 1.In this instance, the AGC selection of parameter is following: the α in formula (1) and the formula (2) gets 0.05, μ in the formula (4)
0Get 0.03125 and 0.001 respectively with γ, K in the formula (6)
1, K
2, P
aAnd P
bGet 0.5,2,0.001 and 0.1 respectively, P in the formula (5)
MinGet 0.0008, represent the power of background noise, P in the formula (3)
RefGet 0.15, represent echo signal power.
Fig. 5 has provided and has used automatic gain control (AGC) method of the present invention that the voice in 6 seconds of another section are carried out process result figure.In this instance, K in the formula (6)
1, K
2Get 0.8 and 4 respectively, the echo signal power P in the formula (3)
RefGet 0.2, other values of parameters are identical with the value of instance among Fig. 3.Can find out that from Fig. 3 and Fig. 5 gain effect is more satisfactory, and the background noise part is not gained.