Docsity

A MATLAB Audio Player - Project 3 | ECEN 4763, Study Guides, Projects, Research of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECEN 4763—Introduction to DSP
Project 3: A MATLAB Audio Player
Oklahoma State University
Page 1 of 2
ECEN 4763/Fall 2008
Project 3: A MATLAB Audio Player
Due Date:
Wednesday, December 10, 2008 in class.
The code for this project is to be submitted electronically via e-mail. There is no re-
port due for this project.
Office Hours:
Damon: Mondays and Wednesdays, 12:30-1:30 PM in 306 Engineering South.
Hoa: Tuesdays, 3:00-4:00 PM in 410 Engineering South.
Concepts to
learn from this
project:
How to make a cool audio player in MATLAB.
Objective
In Project 1, you created a (pseudo) real-time spectrum analyzer with audio playback capabilities using
msound. In Project 2, you used the overlap-add method and FFT-based filtering to filter audio. In this
project, you will use what you learned in Projects 1 and 2 to create an audio player in MATLAB that
does (pseudo) real-time filtering.
To make this work, you’ll need to share some of the computation used for the spectrum display and
the computation used for the filtering. Specifically, instead of using freqz() to compute the to-be-
displayed spectrum, you can use your FFT result, since the FFT needs to be computed to do the filter-
ing anyway. In this way, you can do the filtering and spectrum analysis in one shot, thus making
(pseudo) real-time filtering and spectrum display possible in MATLAB.
Your audio player should meet the following minimum specs:
1. Display: At least 14 bars spanning the range 50 Hz – 22 kHz. The bars should correspond to lo-
garithmically spaced frequency bands.
2. Display: At least 20 frames/sec update speed.
3. Filtering: At least four different filters should be available.
4. Filtering: There should be a “bypass” option in which no filtering is applied (or filtering with an
impulse).
Here’s some code to get you started:
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;
pf2

Partial preview of the text

Download A MATLAB Audio Player - Project 3 | ECEN 4763 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

ECEN 4763—Introduction to DSP Project 3 : A MATLAB Audio Player

Oklahoma State University Page 1 of 2 ECEN 4763/Fall 200 8

Project 3: A MATLAB Audio Player

Due Date: Wednesday, December 10, 200 8 in class.

The code for this project is to be submitted electronically via e-mail. There is no re-

port due for this project.

Office Hours: Damon: Mondays and Wednesdays, 12:30-1:30 PM in 306 Engineering South.

Hoa: Tuesdays, 3:00-4:00 PM in 410 Engineering South.

Concepts to

learn from this

project:

How to make a cool audio player in MATLAB.

Objective

In Project 1, you created a (pseudo) real-time spectrum analyzer with audio playback capabilities using

msound. In Project 2, you used the overlap-add method and FFT-based filtering to filter audio. In this

project, you will use what you learned in Projects 1 and 2 to create an audio player in MATLAB that

does (pseudo) real-time filtering.

To make this work, you’ll need to share some of the computation used for the spectrum display and

the computation used for the filtering. Specifically, instead of using freqz() to compute the to-be-

displayed spectrum, you can use your FFT result, since the FFT needs to be computed to do the filter-

ing anyway. In this way, you can do the filtering and spectrum analysis in one shot, thus making

(pseudo) real-time filtering and spectrum display possible in MATLAB.

Your audio player should meet the following minimum specs:

1. Display : At least 14 bars spanning the range 50 Hz – 22 kHz. The bars should correspond to lo-

garithmically spaced frequency bands.

2. Display : At least 20 frames/sec update speed.

3. Filtering : At least four different filters should be available.

4. Filtering : There should be a “bypass” option in which no filtering is applied (or filtering with an

impulse).

Here’s some code to get you started:

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));

The above code represents a baseline version. To maximize your score on this project, I encourage you

to add as many cool features as possible. Some examples include:

More bars

More filters

Other eye-candy-type elements such as a display of the elapsed time, remaining time, etc.

Adjustments to the bar heights to take into account human perception of sound ( loudness ; see

http://en.wikipedia.org/wiki/Loudness)

The ability to handle stereo

A GUI version (see the guide command in MATLAB)

There is no report associated with your project. Your grade will be determined solely by (1) your ability

to meet the minimum specs, and (2) how impressed the TA and I are with your resulting program.