?? autocor.dsp
字號:
.module/boot=3/boot=4 autocorrelation_of_speech;
{ AUTOCOR.DSP - perform autocorrelation on input speech frame.
INPUT:
i0 -> frame of speech (dm)
l0 = 0
i6 -> buffer for autocorrelation (pm)
l6 = 0
OUTPUT: autocorrelation buffer filled
FUNCTIONS CALLED:
None
DESCRIPTION:
First the speech is autoscaled (IN PLACE!!), to avoid overflow.
The autocorrelation is calculated, and normalized so r[0] = 1 (0x7fff).
}
{include constant and macro definitions}
#include "lpc.h";
.entry a_correlate;
.external overflow;
{.var/pm/ram/circ copy_of_speech[FRAME_LENGTH];}
.var/dm p2_speech;
.var/dm p2_autocor_speech;
a_correlate:
{store pointers for later use}
dm(p2_speech) = i0;
dm(p2_autocor_speech) = i6;
{auto scale input before correlating}
{first: detect largest exp in speech}
{i0 -> speech)}
cntr = FRAME_LENGTH;
sb = -16;
do max_speech until ce;
si = dm(i0,m1);
max_speech: sb = expadj si;
{adjust speech input: normalize to largest and then right shift
to |AC_SHIFT|.(16-|AC_SHIFT|) format (done in one shift).
At the same time copy to pm for correlation}
i0 = dm(p2_speech); l0 = 0;
i5 = dm(p2_autocor_speech); l5 = 0;
cntr = FRAME_LENGTH;
ax0 = sb;
ay0 = AC_SHIFT; {scale down to avoid overflow (worst case)}
ar = ay0 - ax0; {effective scale value}
se = ar;
do adj_speech until ce;
si = dm(i0,m0);
sr = ashift si (hi);
pm(i5,m5) = sr1;
adj_speech: dm(i0,m1) = sr1;
{do autocorrelation, R[i] = sum_of s[j]*s[i+j]}
{NOTE: the counter updating scheme, might cause a "acces to
non-existing memory" in the simulator/emulator}
i5 = dm(p2_autocor_speech); l5 = 0; {s[i+j]}
{i6 -> autocor_speech} {->R[i]}
i2 = FRAME_LENGTH; l2 = 0;
m2 = -1;
cntr = FRAME_LENGTH;
do corr_loop until ce; {i loop}
i0 = dm(p2_speech); l0 = 0; {->s[j]}
i4 = i5; l4 = 0; {->s[i+j]}
cntr=i2;
mr=0, my0=pm(i4,m5), mx0=dm(i0,m1);
do cor_data_loop until ce; {j loop}
cor_data_loop: mr=mr+mx0*my0(ss),my0=pm(i4,m5),mx0=dm(i0,m1);
if mv call overflow;
mx0 = dm(i2,m2), my0 = pm(i5,m5); {update counters: - }
{(innerloop cnt'er)--, i++)}
corr_loop: pm(i6,m5) = mr1; {store R[i]}
{Normalize autocorrelation sequence}
{shift sequnece for maximum precision before division}
i5 = dm(p2_autocor_speech); l5 = 0;
cntr = FRAME_LENGTH - 1;
si = pm(i5,m4); {R(0)}
se = exp si (hi);
sr = norm si (hi);
pm(i5,m5) = sr1; {new R(0)}
do sh_cor until ce; {shift remaining sequence accordingly}
si = pm(i5,m4);
sr = norm si (hi);
sh_cor: pm(i5,m5) = sr1;
{calculate R(i)/R(0)}
i5 = dm(p2_autocor_speech); l5 = 0;
cntr = FRAME_LENGTH - 1;
ax0 = pm(i5,m4); {ax0 = divisor = R(0)}
ay0 = 0x7fff;
pm(i5,m5) = ay0; {new R(0) = 1}
do nrm_cor until ce;
ay1 = pm(i5,m4); {ay1 = MSW of dividend }
ay0 = 0x0000; {ay0 = LSW of dividend}
divide(ax0,ay1);
nrm_cor: pm(i5,m5) = ay0;
rts;
.endmod;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -