?? lpc2k4.dsp
字號:
.module/boot=4/abs=0 lpc2k4_through;
{ LPC2k4.DSP - talk through, encoding and decoding using LPC.
Input: Speech samples from microphone (using autobuffering) via sport0
Ouput: Speech samples to speeaker (using autobuffering) via sport0
Modules used:
- pre_emphasize_speech (PREEMP.DSP)
- gain_calculation (GAIN.DSP)
- autocorrelation_of_speech (AUTOCOR.DSP)
- durbin_double/single (DURBIN2.DSP/DURBIN.DSP)
- pitch_detection (PITCH.DSP)
- lpc_sync_synth (SSYNTH.DSP)
- de_emphasize_speech (DEEMP.DSP)
- constant header (LPC.H)
Description:
This program implements a shell to demonstrate the LPC algorithm
on an EZ-LAB board. Speech is autobuffered in from the codec,
compressed, decompressed and autobuffered back out to the codec,
providing a "talk-through" program.
NOTE: The framesyncs of sport0 (TFS0 & RFS0) SHOULD NOT be tied together
EXTERNALY!!
(On the EZ-LAB's seriel connector it is pins 4 & 5)
}
{include constant definitions}
#include "lpc.h";
{Buffers used by autobuffering, input swaps between analys_buf & receive_buf,
whereas output swaps between synth_buf & transit_buf}
.var/dm/ram/circ analys_buf[FRAME_LENGTH];
.var/dm/ram/circ receive_buf[FRAME_LENGTH];
{The LPC-parameters are stored in trans_line to "simulate" transmission}
.var/dm/ram trans_line[WORDS_PR_LPCFRAME];
{Pointers to the buffers that are NOT currently being used by autobuffering}
.var/dm/ram p2_analysis,p2_synth;
{Intermediate variables}
.var/pm/ram autocor_speech[FRAME_LENGTH];
.var/dm/ram/circ k[N];
.var/dm/ram pitch, gain;
.var/dm/ram lpc_flag;
.external pre_emph;
.external calc_gain;
.external a_correlate;
.external levinson;
.external detect_pitch;
.external encode;
.external decode;
.external clear_filter;
.external synthesis;
.external de_emph;
{load interrupt vectors}
jump start_test; nop; nop; nop; {reset interrupt}
rti; nop; nop; nop;
rti; rti; nop; nop; {sport0 transmit}
call rcv_ir; rti; nop; nop; {sport0 receive}
rti; nop; nop; nop;
rti; nop; nop; nop;
rti; nop; nop; nop;
change_demo:
gd: if not flag_in jump gd;
ay0 = 0x0238; {set bootforce bit}
dm(0x3fff) = ay0;
nop;
rts;
start_test:
{configure sports etc.}
ax0 = 0x0000;
dm(0x3ffe) = ax0; {dm waits = 0}
ax0 = 0x6327;
dm(0x3ff6) = ax0; {set sport0 control reg}
ax0 = 2;
dm(0x3ff5) = ax0; {set sclkfreq to 2.048 Mhz}
ax0 = 255;
dm(0x3ff4) = ax0; {set rclkfreq to 64 khz}
{Default register values, these values can always be asumed, and must
be reset if altered}
l0 = 0; l1 = 0; l2 = 0; l3 = 0;
l4 = 0; l5 = 0; l6 = 0; l7 = 0;
{DEDICATED REGISTERS. These registers must NOT be altered by any
routine at any time! (used by autobuffering)}
m0 = 0; m4 = 0;
m1 = 1; m5 = 1;
i3 = ^receive_buf; l3 = %receive_buf;
{Setup and clear intermediate buffers}
i6 = ^analys_buf; l6 = 0;
dm(p2_analysis) = i6;
ena sec_reg;
ax0 = FRAME_LENGTH;
af = pass ax0;
dis sec_reg;
ax0 = 0;
dm(lpc_flag) = ax0;
{clear the synthesis filter}
call clear_filter;
{enable sport0}
ax0 = 0x1038;
dm(0x3fff) = ax0;
{enable sport0}
icntl = b#00111;
imask = b#001000; {Enable receive}
wait: idle;
if not flag_in call change_demo;
ax0 = dm(lpc_flag);
ar = pass ax0;
if eq jump wait;
ax0 = 0;
dm(lpc_flag) = ax0;
{Parameters: i0 = p2_analysis (-> speech)
Returns : filtered speech}
i0 = dm(p2_analysis); l0 = 0;
call pre_emph;
{Parameters: i0 = p2_analysis (-> speech)
Returns : sr1 = gain}
i0 = dm(p2_analysis); l0 = 0;
call calc_gain;
dm(gain) = sr1;
{Parameters: i0 = p2_analysis (-> speech)
Returns : autocor_speech[]}
i0 = dm(p2_analysis); l0 = 0;
i6 = ^autocor_speech; l6 = 0;
call a_correlate;
{Parameters: i4 -> autocor_speech[])
Returns : i0 -> k[]}
i4 = ^autocor_speech; l4 = 0;
i0 = ^k; l0 = 0;
call levinson;
{Parameters: i0 -> k[],
i6 -> autocor_speech[]
Returns : si = pitch}
i0 = ^k; l0 = 0;
i6 = ^autocor_speech; l6 = 0;
call detect_pitch;
dm(pitch) = si;
{Parameters: i1 -> k[],
ar = pitch,
si = gain
Returns : parameters encoded
ar = pitch,
si = gain}
i1 = ^k; l1 = 0;
ar = dm(pitch);
si = dm(gain);
call encode;
dm(pitch) = ar;
dm(gain) = si;
{TRANSMISSION LINE}
{Parameters: i1 -> k[],
si = pitch,
ax0 = gain
Returns : k's decoded
si = pitch,
ax0 = gain}
i1 = ^k; l1 = 0;
si = dm(pitch);
ax0 = dm(gain);
call decode;
dm(pitch) = si;
dm(gain) = ax0;
{Parameters: ax1 = pitch,
mx1 = gain,
i0 -> k[]
Returns : i2 -> speech}
i0 = ^k; l0 = 0;
i1 = ^k + N - 1; l1 = 0; {store k's in revers order - }
cntr = 5; {N/2} {required by lattice routine}
m2 = -1;
do reverse_ks until ce;
ay0 = dm(i0,m0);
ay1 = dm(i1,m0);
dm(i0,m1) = ay1;
reverse_ks: dm(i1,m2) = ay0;
ax1 = dm(pitch);
mx1 = dm(gain);
i1 = ^k; l1 = N;
i2 = dm(p2_analysis); l2 = 0;
call synthesis;
{Parameters: i0 = p2_analysis (-> speech)
Returns : filtered speech}
i0 = dm(p2_analysis); l0 = 0;
call de_emph;
jump wait;
{End of main routine}
{Autobuffering interrupt routines}
trns_ir:
rts;
rcv_ir:
ena sec_reg;
ax0 = dm(i3,m0);
tx0 = ax0;
ax0 = rx0;
dm(i3,m1) = ax0;
af = af - 1;
if gt jump no_lpc;
{switch pointers}
ay0 = i3;
ay1 = dm(p2_analysis);
i3 = ay1; l3 = %receive_buf;
dm(p2_analysis) = ay0;
ax0 = FRAME_LENGTH;
af = pass ax0;
ax0 = 1;
dm(lpc_flag) = ax0;
no_lpc:
dis sec_reg;
rts;
{END of main code}
.endmod;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -