% Demonstration of first-, second-, and third-order low-pass filters.
% Music is filtered for each case, and the differences can be heard.
% This program must be run on the Suns to access the music file.
% Rich Kozick, Fall 1998

x = auread('/home/pleiades/ACM/snd/spacemusic.au');
t = (1:length(x))/8192;
w = logspace(1, 5, 500);

[b1,a1] = butter(1, 2*pi*400, 's');
y1 = lsim(b1, a1, x, t);

[b2,a2] = butter(2, 2*pi*400, 's');
y2 = lsim(b2, a2, x, t);

[b3,a3] = butter(3, 2*pi*400, 's');
y3 = lsim(b3, a3, x, t);

% Write results to .au files

% auwrite(x, 'filx.au');
% auwrite(y1, 'fily1.au');
% auwrite(y2, 'fily2.au');
% auwrite(y3, 'fily3.au');

% To play the results in MATLAB:

% sound(x)
% sound(y1)
% sound(y2)
% sound(y2)
