image thumbnail

EXPO 2011 Signal Processing Workflow Demo Files

by

 

MATLAB EXPO 2011 Signal Processing Workflow Demo Files

filter_farrow.m
%% Tv[gRo[^݌v
% FarrowtB^ɂRXg啝팸
%%
% 
clear all,close all

%% @Lt@N^[Tv[gRo[^
% ̃Tv[g̕ϊstB^
Fs1 = 8e3*441;	% Clock rate
W = linspace(0,44.1e3,2048);  % Define the frequency range analysis
L = 441; M = 80;	% ݂ɑfƂȂp[^ݒ
Astop = 50;			% Ւf
Frf = fdesign.rsrc(L,M,'nyquist')
set(Frf,'TransitionWidth',1/(L*2),'Astop',Astop);
Hrf = design(Frf); %design with Kaiser window

h6 = fvtool(Hrf,'Fs',Fs1,'FrequencyRange','Specify freq. vector', ...
    'FrequencyVector',W,'NormalizeMagnitudeto1','on')

%% AtB^O
clear n x y
Fs = 8000;
n = 0:255;					% 
infreq = 2e2;
x  = sin(2*pi*infreq/Fs*n);	% Sin Wave
y = filter(Hrf,x);

figure
numstem = 41;
stem(n(1:numstem)/Fs,x(1:numstem)),hold on
xlim([0 1/infreq])

%% 
% Tv[gRo[^o͂vbg
stem((n(1:numstem*L/M))/(L*Fs/M),...
	y([1:numstem*L/M]+34),'r','filled')
xlabel('Time (sec)');ylabel('Signal value')
legend('8 kHz sample rate','44.1 kHz sample rate')
title('8k to 44.1kHz Sample Rate Converter'),hold off
xlim([0 1/infreq])
shg

%% BRXǧςƓ]
cost(Hrf)
measure(Hrf)

%% CFarrow  FIR |tF[Y\̃JXP[h
% ɁA܂łɌĂ 2 ނ̃tB^[𗘗p\[V
% ݌vĂ݂܂傤B |tF[YtB^[́At@N^[ɂ}܂
% ԈƁA}ъԈWႢ[gϊɓɓKĂ܂B 
% Farrow tB^[͔Cӂ (܂) [gϊt@N^[ʓIɎ
% ł܂B ܂AFIR n[tohtB^[̃JXP[hgpāA 
% 8 kHz M 4 œ}܂B
Fs2 = 32e3*441;		% Clock rate
TW = .125; % Transition Width
L2 = 4;		% 8k->32k Interpolation Factor
F2 = fdesign.interpolator(L2,'Nyquist',4,'TW,Ast',TW,Astop);
Hfir = design(F2,'multistage','HalfbandDesignMethod','equiripple');
cost(Hfir)
%% DtB^݌v
% ɁA8x4=32 kHz M}A
% ړI̍ŏII 44.1 kHz ̃TvOg擾܂B 
% 3 OWx[X tB^[gp܂B
Np = 3;			% Polynomial Order
M2 = M*L2;		% 441/(80*4)
Ffar = fdesign.polysrc(L,M2,'Fractional Delay','Np',Np);
Hfar = design(Ffar,'lagrange');
cost(Hfar)
%% E 2‚̃tB^[JXP[h
Hc = cascade(Hfir,Hfar);
cost(Hc)

set(h6,'Filters',[Hrf,Hc],'Fs',[Fs1 Fs2],'NormalizeMagnitudeto1','on');
legend(h6,'Polyphase Interpolator','Farrow Interpolator')

% h7 = fvtool(Hc,'Fs',Fs1,'FrequencyRange','Specify freq. vector', ...
%     'FrequencyVector',W,'NormalizeMagnitudeto1','on');

% eof

Contact us