ldelay.f
上传用户:szhypcb168
上传日期:2007-01-06
资源大小:2187k
文件大小:3k
- C==========================================================================
- C
- C ROUTINE
- C ldelay
- C
- C FUNCTION
- C Time delay a bandlimited signal
- C using point-by-point recursion
- C with a long interpolation filter (see delay.f)
- C
- C SYNOPSIS
- C subroutine ldelay(x, bufr, start, n, d, m, y)
- C
- C formal
- C data I/O
- C name type type function
- C -------------------------------------------------------------------
- C x(n) real i signal input (output in last 60)
- C bufr int i length of input sequence x(n)
- C start int i beginning of output sequence
- C n int i length of output sequence
- C d real i fractional pitch
- C m int i integer pitch
- C y(n) real o delayed input signal
- C==========================================================================
- C
- C DESCRIPTION
- C
- C Subroutine to time delay a bandlimited signal by resampling the
- C reconstructed data (aka sinc interpolation). The well known
- C reconstruction formula is:
- C
- C | M2 sin[pi(t-nT)/T] M2
- C y(n) = X(t)| = SUM x(n) --------------- = SUM x(n) sinc[(t-nT)/T]
- C | n=M1 pi(t-nT)/T n=M1
- C |t=n+d
- C
- C The interpolating (sinc) function is Hamming windowed to bandlimit
- C the signal to reduce aliasing.
- C
- C Multiple simultaneous time delays may be efficiently calculated
- C by polyphase filtering. Polyphase filters decimate the unused
- C filter coefficients. See Chapter 6 in C&R for details.
- C==========================================================================
- C
- C REFERENCES
- C
- C Crochiere & Rabiner, Multirate Digital Signal Processing,
- C P-H 1983, Chapters 2 and 6.
- C
- C Kroon & Atal, "Pitch Predictors with High Temporal Resolution,"
- C ICASSP '90, S12.6
- C
- C**************************************************************************
- C
- subroutine ldelay(x, bufr, start, n, d, m, y)
- implicit undefined(a-z)
- integer n, bufr, start
- real x(bufr), y(0:n-1), d
- integer nfrac, i, j, k, m, qd, M1, M2
- c * 5 fractional delays calculated over a 40 point interpolation (-20 to 19)
- parameter (nfrac = 5, M1 = -20, M2 = 19)
- integer twelfths(nfrac)
- real sinc, wsinc(M1:M2, nfrac), hwin(12*M1:12*(M2+1)), frac(nfrac)
- logical first
- c
- save first, hwin, wsinc
- c
- data first /.true./
- data twelfths/3, 4, 6, 8, 9/
- data frac/ 0.25, 0.33333333, 0.5, 0.66666667, 0.75/
- c
- c Generate Hamming windowed sinc interpolating function
- c for each allowable fraction. The interpolating functions
- c are stored in time reverse order (i.e., delay appears as
- c advance) to allign with the adaptive code book v0 array.
- c The interp filters are:
- c wsinc(.,1) frac = 1/4 (3/12)
- c wsinc(.,2) frac = 1/3 (4/12)
- c . .
- c wsinc(.,5) frac = 3/4 (9/12)
- c
- if (first) then
- call ham(hwin, 12*(M2-M1+1)+1)
- do 20 i = 1, nfrac
- do 10 j = M1, M2
- wsinc(j,i) = sinc(frac(i)+j)*hwin(12*j+twelfths(i))
- 10 continue
- 20 continue
- first = .false.
- end if
- c
- k=qd(d)
- c
- c Resample:
- do 80 i = 0, n-1
- x(start+i) = 0.0
- do 70 j = M1, M2
- x(start+i) = x(start+i) + x(start-m+i+j)*wsinc(j,k)
- 70 continue
- 80 continue
- c
- c The v0 array in psearch.FF/pgain.f must be zero above "start"
- c because of overlap and add convolution techniques used in pgain.
- c
- do 100 i = 0, n-1
- y(i) = x(start + i)
- x(start + i) = 0
- 100 continue
- return
- end