Contents

% tunable lowpass and highpass filter
% lab9_demo.m * mw * 04/13/2007

Wave sound

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

Default filtering

alpha = 0;                % default
[u,v] = latc1m(-alpha,x); % one-multiplier form, k = -alpha
ylp = .5*(x + v');        % lowpass
yhp = .5*(x - v');        % highpass

Main menu

MAIN_LOOP = 11; 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'}; num_lines = 1; def = {'0'};
            answer = inputdlg(prompt,dlg_title,num_lines,def);
            alpha = str2num(answer{1});
            % filtering
            [u,v] = latc1m(-alpha,x); % one-multiplier form, k = -alpha
            ylp = .5*(x + v');        % lowpass
            yhp = .5*(x - v');        % highpass
        case 2
            [FIG1, FIG2] = lab9_demo_graphics(x,v,ylp,yhp,alpha,fs);
        case 3
            lab9_demo_playsound(x,v,ylp,yhp,fs,nbits)
        otherwise
            END = 'true';
    end
    if strcmp(END,'true') break, end
end