

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


ECEN 4763—Introduction to DSP Project 3 : A MATLAB Audio Player
Oklahoma State University Page 1 of 2 ECEN 4763/Fall 200 8
function [y] = filter_audio_live(x, h, fs)
% block size blk_size = 2048; % adjust as desired
% length of FFT % IMPORTANT NOTE: If you adjust blk_size, you’ll need to also adjust N % to ensure that N is a power of 2, otherwise the FFT will be slow! N = 2*blk_size;
Project 3: A MATLAB Audio Player ECEN 4763—Introduction to DSP
ECEN 4763/Fall 200 8 Page 2 of 2 Oklahoma State University
% length of the filter h_len = length(h);
% length of the input signal x_len = length(x);
% TODO: pad input signal to make it a multiple of blk_size
% Compute the FFT of the filter H = fft(h, N);
% make room for the filtered signal y = zeros(1, x_len+h_len-1);
% TODO: allocate room for any temporary variable here
msound('openwrite', 0, fs, blk_size, 1); try % TODO: loop over the song... % (1) extract each block % (2) perform a length-N FFT of the block % (3) multiply the FFT of the block with the FFT of the filter % (4) perform the inverse FFT of the result % (5) store using overlap-add % (6) play using msound % (7) map the resulting FFT to the bars and display catch msound('close'); rethrow(lasterror); end msound('close');
y = y(h_len:length(x));