?? gain.dsp
字號:
.module/boot=3/boot=4 gain_calculation;
{ GAIN.DSP - Calculates the gain factor for a speech frame.
INPUT:
i0 -> speech frame
l0 = 0
OUTPUT:
sr1 = gain
FUNCTIONS CALLED:
poly_approx - used to aproximate sqrt function
DESCRIPTION:
The gain of a frame is calculated as:
gain = sqrt(sum_over_frame(x(n)^2))
A simpel no-speech detection is implemented, if the gain is lower
than NOISE_FLOOR the gain is set to zero.
The result is scaled appropriatly by GAIN_SCALE.
}
{Include constant definitions}
#include "lpc.h"
.const NOISE_FLOOR = 0x0000; {found as gain when no input is present}
.const GAIN_SCALE = 0; {appropriate scale value}
.entry calc_gain;
.external sqrt;
calc_gain:
{calulate energy of frame, R(0), as sum of input squared}
mr=0;
cntr = FRAME_LENGTH;
do cor_data_loop until ce;
si = dm(i0,m1);
sr = ashift si by G_INP_SHIFT (hi); {scale to avoid overflow}
my0 = sr1;
cor_data_loop: mr=mr+sr1*my0(ss);
{set gain = 0 if energy is under noise level}
ay0 = NOISE_FLOOR;
ar = mr1 - ay0;
if gt jump speech;
sr1 = 0;
jump from_noise;
speech:
{calc the gain as the squareroot of R(0)}
sr = lshift mr0 by -12 (lo); {shift to 16.16 format}
sr = sr or ashift mr1 by -12 (hi);
mr1 = sr1; {msw of gain^2}
mr0 = sr0; {lsw of gain^2}
call sqrt; {result is in unsigned 8.8 format}
sr = lshift sr1 by 7 (hi); {shift back to 1.15 format}
sr = lshift sr1 by GAIN_SCALE (hi);
from_noise:
rts;
.endmod;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -