home *** CD-ROM | disk | FTP | other *** search
- page 132,63,1,1
- opt rc
- title 'LPC Vocoder'
-
- ;***************************************************************
- ;* LPC.ASM -- 2400 bit/s LPC Vocoder main control loop *
- ;* *
- ;* Provides main control loop of the LPC codec. Wait (in order *
- ;* to reduce power consumption) for a one frame to be sampled. *
- ;* Then analyze it, send to the host computer (via serial line)*
- ;* check if block from the host computer has been received, and*
- ;* if there are any, then synthesize it. *
- ;* *
- ;* This module reserves registers as follows: *
- ;* r7 - input/output sample pointer *
- ;* *
- ;* Copyright (C) 1992 by Alef Null. All rights reserved. *
- ;* Author(s): Jarkko Vuori, OH2LNS *
- ;* Modification(s): *
- ;***************************************************************
-
- nolist
- include 'ioequlc'
- list
-
- section LPC
-
- xdef ssi_ini,lpc_i,m_loop
- xref m_cra,m_crb,m_tde,m_sr,m_tx
- xref lpc_ana,lpc_syn
-
- org p:
-
- nolist
- include 'macros'
- list
-
-
- ;****************************
- ;* SSI initialization *
- ;****************************
- ssi_ini
- ; initialize SSI,
- IF !DEBUG
- movep #$4000,x:m_cra ; 16 bit word
- movep #$7200,x:m_crb ; syncronous,word frame,ext clk
- ELSE
- movep #$6008,x:m_cra ; 24 bit word (because simulator won't read fractinal values correctly in 16 bit mode)
- movep #$7620,x:m_crb ; syncronous,word frame,ext clk
- ENDIF
-
- rts
-
-
- ;****************************
- ;* ADC & LPC *
- ;* initialization *
- ;****************************
- lpc_i
- ; program the A/D & D/A converter chip (TLC32044, master clock is 5.184MHz)
- ; enable A/D high-pass filter, disable loopback, disable AUX IN,
- ; select syncronous mode, select input span 1.5Vpp, insert sinx/x correction
- ; lowpass cutoff frequency at 3600Hz -> TA = 9 (SCF = 288kHz)
- ; sampling frequency is 8000Hz -> TB = 36
- ; unit sampling correction time 0.4uS -> TA' = 2
- pgmtlc %10101001,9,2,36
-
- ; initialize input and output sample buffer pointers
- move #samples,r7
- move #3*M-1,m7
- move r7,x:samptr
-
- ; initialize flags and parameters
- move #(1<<loopb),a1
- clr a a1,x:<flags
- move a,x:<p_d
-
- rts
-
-
- ;****************************
- ;* Main Loop *
- ;****************************
- loop wait
- m_loop
-
- ; check if one frame converted
- move x:samptr,a
- move r7,x0
- sub x0,a #>M,x0
- cmpm x0,a
- jlo <loop
-
- ; then analyze it, encode parameters and send them to output
- jsr <lpc_ana
- jsr <lpc_encode
- jsr <put_blk
-
- ; receive parameters for synthesizer
- jsr <get_blk
- jcc <_okblk
- clr a ; reset output if no new block received
- move a,x:lpcin
- move a,x:lpcin+1
-
- ; decode those parameters and synthesize voice
- _okblk jclr #loopb,x:<flags,_normb
- move x:lpcout,a1
- move a1,x:lpcin
- move x:lpcout+1,a1
- move a1,x:lpcin+1
-
- _normb jsr <lpc_decode
- jsr <lpc_syn
-
- ; finally update current frame pointer
- move x:samptr,r0
- move #M,n0
- move #3*M-1,m0
- nop
- move (r0)+n0
- move r0,x:samptr
-
- jmp <loop
-
-
- ;****************************
- ;* DATA - AREA *
- ;****************************
-
- xdef flags,p_d
- xdef p_code,g_code,k_code
- xdef p_s,g_s,k_s
- xdef samptr
-
- org x:
-
- ; Global parameters
- flags ds 1 ; global Vocoder flags
- p_d ds 1 ; pitch adjustment
-
- ; Parameters for LPC analysis
- p_code ds 1 ; pitch estimate
- g_code ds 1 ; gain estimate
- k_code ds P ; estimated reflection coefficients
-
- ; Parameters for LPC sythesis
- p_s ds 1 ; current pitch period
- g_s ds 1 ; gain for current output frame
- k_s ds P ; current reflection coefficients
-
- ; Global internal variables
- samptr ds 1 ; start of current input/output frame pointer
-
- endsec
-
-
- section Samples
-
- xdef samples,temp,lotaps,hamming,glottal
-
- nolist
- include 'macros'
- list
-
-
- org x:
-
- samples ds 3*M ; input sample buffer
- ds 512-3*M
-
- temp ds N
-
- ; Hamming window
- hamming
- dum set 0
- dup N
- dc 0.54-0.46*@cos(6.283185*@cvf(dum)/@cvf(N))
- dum set dum+1
- endm
-
-
- org y:
-
- ds 3*M ; output sample buffer
- ds 512-3*M
-
- ; 900 Hz lowpass filter generated using Parks-McClellan algorithm
- ; sampling rate 8000 Hz
- ; passband edge 840 Hz
- ; stop band edge 960 Hz
- ; filter lenght 79 taps
- lotaps dc 1.619394e-02,5.805688e-03,3.155693e-03,-1.500173e-03,-6.545769e-03
- dc -9.963868e-03,-1.022255e-02,-7.061145e-03,-1.754771e-03,3.332559e-03
- dc 5.765334e-03,4.199639e-03,-8.617942e-04,-7.138900e-03,-1.151400e-02
- dc -1.147496e-02,-6.426490e-03,1.780802e-03,9.467491e-03,1.274443e-02
- dc 9.432186e-03,3.507424e-04,-1.070496e-02,-1.840716e-02,-1.827196e-02
- dc -9.051937e-03,6.112294e-03,2.066623e-02,2.704929e-02,2.031219e-02
- dc 9.089151e-04,-2.437167e-02,-4.415325e-02,-4.639930e-02,-2.320264e-02
- dc 2.545267e-02,9.059131e-02,1.564397e-01,2.052803e-01,2.232958e-01 ; center tap
- dc 2.052803e-01,1.564397e-01,9.059131e-02,2.545267e-02,-2.320264e-02
- dc -4.639930e-02,-4.415325e-02,-2.437167e-02,9.089151e-04,2.031219e-02
- dc 2.704929e-02,2.066623e-02,6.112294e-03,-9.051937e-03,-1.827196e-02
- dc -1.840716e-02,-1.070496e-02,3.507424e-04,9.432186e-03,1.274443e-02
- dc 9.467491e-03,1.780802e-03,-6.426490e-03,-1.147496e-02,-1.151400e-02
- dc -7.138900e-03,-8.617942e-04,4.199639e-03,5.765334e-03,3.332559e-03
- dc -1.754771e-03,-7.061145e-03,-1.022255e-02,-9.963868e-03,-6.545769e-03
- dc -1.500173e-03,3.155693e-03,5.805688e-03,1.619394e-02
-
- ; DoD stadard glottal pulse excitation
- ; Normalized for unity gain
- glottal dc .249,-.262,.363,-.362,.100,.367,.079,.078,.010,-.277
- dc -.082,.376,.288,-.065,-.020,.138,-.062,-.315,-.247,-.078
- dc -.082,-.123,-.039,.065,.064,.019,.016,.032,.018,-.015
- dc -.029,-.021,-.018,-.027,-.031,-.022,-.012,-.010,-.010,-.004
-
- endsec
-
- end
-