% digmus.m
% Demonstration of digital filters applied to music.
%
% ELEC 320, Rich Kozick

% 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('slove.au');

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

fprintf('This is the original music . . . ');
sound(x)
pause(20);
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 . . . ')
y = zeros(size(x));
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');
