% digmus.m
% Demonstration of digital filters applied to music.
% This program must be run on the Sun computers to access the music file.
%
% ELEC 320, Rich Kozick, Fall 1998

% Filter music with an impulse response (1st order)

fs = 8192;	% Sample rate, in samples per second
T = 1/fs;       % Period between samples, in seconds

% Read the music file
x = auread('/home/pleiades/COURSES/ee328/slove.au');

L = length(x);  % Number of samples in the vectors x

fprintf('This is the original music . . . ');
sound(x)
fprintf('\n');

% Add your code to do the digital filtering here.
% The filter output will be y[n].
% You might use y1[n], y2[n], etc. to denote the ouputs from several filters.

% Simple filter in which output = input:

fprintf('Performing digital filtering . . . takes a while . . . ')
clear y      
y(1) = x(1);    % Take care of initial conditions (may need more commands here)

for n=2:L       % Implement the difference equation
  y(n) = x(n);
end
fprintf('\n');

fprintf('This is the music after filtering . . . ');
sound(y)
fprintf('\n');
