by Ljiljana Milic
Supplemental material for Chapter VI:
6. Sampling Rate Conversion by a Fractional Factor
6.1 Sampling Rate Conversion by a Rational Factor
Example 6.1
In this example, the MATLAB function resample is used for sampling-rate conversion by a rational factor.
Sampling-rate conversion by L/M = 3/2
Fx = 20; Tx=1/Fx; % Original sampling frequency in Hz
tx = 0:Tx:1; % Time vector tx
x = 0.9*sin(2*pi*tx); % Input sequence
y = resample(x,3,2); % Re-sampling
ty = (0:(length(y)-1))*2*Tx/3; % New time vector ty
subplot(2,1,1), stem(tx,x,'*k')
legend('original','resampled')
xlabel('Time'), ylabel('Amplitude')
disp('END OF EXAMPLE 6.1)')
6.2 Efficient Implementation of Polynomial Interpolation Filters Using Farrow Structure
Remainder
Using the polynomial-based approach and the Farrow structure, the sampling rate conversion by an arbitrary factor can be implemented efficiently. The above mentioned structure is indicated in the Figure.
Farrow structure for polynomial-based interpolation filters:
(a) The overall structure. (b) FIR filter details.
In the following example, we demonstrate the application of the Farrow structure for converting the sampling rate of the input signal by the factor 16/15.
Example 6.2
This example demonstrates sampling rate alteration by the fractional factor R = 16/15.
Generating the input signal x[n]
x = n+2*sin(pi*f1*n)+5*cos(pi*f2*n)+1;
subplot(2,1,1),stem(n,x(3:length(x)-2),'k');
xlabel('Time index [n]'), ylabel('x[n]')
R = 16/15; % Re-sampling factor
mu = repmat(mu,1,3); % Vector of fractional intervals
Farrow filter, coefficients:
C0 = [1/6,-1/2,1/2,-1/6]; % Vector of Lagrange coefficients for C_0(k)
C1 = [0,1/2,-1,1/2]; % Vector of Lagrange coefficients for C_1(k)
C2 = ([-1/6,1,-1/2,-1/3]); % Vector of Lagrange coefficients for C_2(k)
C3 = [0,0,1]; % Vector of Lagrange coefficients for C_3(k)
Farrow filter, initial states:
xs0 = [0,0,0]; xs1 = [0,0,0]; xs2 = [0,0,0]; xs3 = [0,0];
Farrow filtering:
[v0,xs0] = filter(C0,1,xnl,xs0);
[v1,xs1] = filter(C1,1,xnl,xs1);
[v2,xs2] = filter(C2,1,xnl,xs2);
[v3,xs3] = filter(C3,1,xnl,xs3);
y(l) = ((v0*mu(l)+v1)*mu(l)+v2)*mu(l)+x(n+2);
y(l+1) = ((v0*mu(l+1)+v1)*mu(l+1)+v2)*mu(l+1)+x(n+2);
y(l) = ((v0*mu(l)+v1)*mu(l)+v2)*mu(l)+x(n+2);
Displaying the results
stem(0:length(y) -1,y,'sk'), xlabel ('Time index [l]'),ylabel('y[l]')
title('Re-sampled signal')
disp('END OF EXAMPLE 6.2')
6.3 Fractional Delay Filters
Example 6.3
We generate impulse responses of a family of fractional delay filters using the MATLAB object dfilt.farrowlinearfd.
Designing family of fractional delay filters
h(k+1)= dfilt.farrowlinearfd(mu);
Compute and plot phase delay characteristics
[phi,f] = phasedelay(h,512,2); % Computing the phase delay
xlabel('\omega/\pi'), ylabel('Phase delay (samples)'), grid
Compute and plot magnitude responses
[H,f] = freqz(h,512,2); % Computing the frequency response
xlabel('\omega/\pi'), ylabel('Magnitude'), axis([0,1,0,1.1]),grid
Aplying the fractional delay filter
x=0.5*sin(pi*0.2*t)+(sin(pi*0.1*t)); % Original sequence
y1=filter(h(3),x); % 0.2-sample delay
y2=filter(h(6),x); % 0.5-sample delay
stem(t,x,'k'); hold on; stem(t-0.2,y1,'kv--','filled')
hold on; stem(t-0.5,y2,'ks-.','filled')
xlabel('n'),ylabel('Amplitude')
legend('\mu=0','\mu=0.2','\mu=0.5'), grid
disp('END OF EXAMPLE 6.3')
Example 6.4
This example illustrates processing of a sinusoidal sequence when the fractional delay factor is changed from to . Program generates the 1st order Lagrange fractional-delay filter, creates 10 samples of the sinusoidal sequence, and performs filtering with the sudden change of the delay factor from to at the time-index n = 5. The Matlab object dfilt.farrowlinearfd has been used. h = dfilt.farrowlinearfd(mu);
h.PersistentMemory = true;
stem(t,x); hold on; stem(ty,y,'rs')
xlabel('n'),ylabel('Amplitude')
legend('Original Signal','Delayed Signal')
disp('END OF EXAMPLE 6.4')
disp(' END OF CHAPRER VI')