Contents

% tunable bandpass and bandstop filter
% lab9_demo2.m * mw * 04/13/2007

Wave sound

fprintf('tunable bandpass and hbandstop filters \n')
[x,fs,nbits] = wavread('handel');
fprintf('sampling frequency = %g kHz \n',fs/1000)
tunable bandpass and hbandstop filters 
sampling frequency = 8.192 kHz 

Default filtering

beta = 0; alpha = 0; % default
[u,v] = latc1m([-beta,alpha],x); % one-multiplier form, k2 = alpha, k1=-beta
ybs = .5*(x + v');   % bandstop
ybp = .5*(x - v');   % bandpass

Main menu

MAIN_LOOP = 21; END = 'false';
while MAIN_LOOP > 0
    MAIN_LOOP = MAIN_LOOP - 1;
    MAIN = menu('Select','filtering','graphics','sound','END');
    switch MAIN
        case 1
            dlg_title = 'Input for tunable filters';
            prompt = {'Enter -1 < alpha < 1','Enter -1 < beta < 1'}; num_lines = 1; def = {'0','0'};
            answer = inputdlg(prompt,dlg_title,num_lines,def);
            alpha = str2num(answer{1});
            beta = str2num(answer{2});
            % filtering
            [u,v] = latc1m([-beta,alpha],x); % one-multiplier form, k2 = alpha, k1=-beta
            ybs = .5*(x + v');   % bandstop
            ybp = .5*(x - v');   % bandpass
        case 2
            [FIG1, FIG2] = lab9_demo2_graphics(x,v,ybs,ybp,alpha,beta,fs);
        case 3
            lab9_demo2_playsound(x,v,ybs,ybp,fs,nbits)
        otherwise
            END = 'true';
    end
    if strcmp(END,'true') break, end
end