Вы находитесь на странице: 1из 15

July 24

Assignment 03-04

2014

Audio Equalizer

Short
Report

SIDRA FAHIM
Fa-2012-MSEE-056

Sidra Fahim
Fa2012 MSEE 056

Table of Contents

Problem Statement.......................................................................................................... 3
Deliverables .................................................................................................................... 4
Requirements .................................................................................................................. 4
1.

AUDIO EQUALIZATION .......................................................................................... 5


1. Graphic Equalizers ............................................................................................. 5
2. Parametric Equalizer .......................................................................................... 6

2.

SOFTWARE DESIGN METHODOLOGY ................................................................. 7


1. Graphic Interface of Audio Equalizer .................................................................. 7
1. Push buttons ................................................................................................... 7
2. Panel............................................................................................................... 7
3. Sliders ............................................................................................................. 8
4. Static Text ....................................................................................................... 8
5. Edit Texts ........................................................................................................ 8
6. Tools ............................................................................................................... 8
2. Run GUI interface .............................................................................................. 9
3. M-file editing ....................................................................................................... 9
1. Browsing function............................................................................................ 9
2. Processing Function ..................................................................................... 10
3. Scrolling sliders and Updating Gains ............................................................ 11
4. Update Filters ............................................................................................... 12
5. Play Sound ................................................................................................... 14
6. Reset Gains .................................................................................................. 14

3.

Bibliography ........................................................................................................... 15

Sidra Fahim
Fa2012 MSEE 056

Table of Figures

Figure 1 Graphic Equalizer .............................................................................................. 5


Figure 2 Parametric Equalizer ......................................................................................... 6
Figure 3 GUI Design........................................................................................................ 7
Figure 4 Toolbars in Software ......................................................................................... 8
Figure 5 Basic GUI ......................................................................................................... 9
Figure 6 Browsing ........................................................................................................... 9
Figure 7 Processing ...................................................................................................... 11
Figure 9 Editing sliders .................................................................................................. 11
Figure 8 Changing sliders value .................................................................................... 11
Figure 10 H/L shelving filter [2] ...................................................................................... 13
Figure 11 Peak Filtering ................................................................................................ 14

Sidra Fahim
Fa2012 MSEE-056

Problem Statement
Make a software audio equalizer with the following frequency bands
[0 60 Hz], [60 Hz 170 Hz], [170 Hz 310 Hz], [310 Hz 600 Hz], [600 Hz 1 kHz],
[1 kHz 3kHz], [3 kHz 6 kHz], [6 kHz 12 kHz], [12 kHz 14 kHz], [14 kHz 16 kHz]

Deliverables
1. A software with GUI of an audio equalizer.
2. A short report containing problem statement and the methodology used. Explain all
the steps in methodology.

Requirements
1. Variable range of gain for all bands (-20dB to 20dB)
2. Read audio file from computer
3. Equalization in real-time
4. Play audio file. Button to play file.
5. Sliders to change frequency level.
6. Figure showing the frequency response of a multiband equalizer based on the
values of sliders
7. GUI in MATLAB.

Sidra Fahim
Fa2012 MSEE 056

1. AUDIO EQUALIZATION
Theory:-

It is a process to deliberately alter the tonal quality of audio passing through it. It does
this by using a number of filter circuits, which are capable of applying gain to audio
signals within specific frequency ranges both positive gain, referred to a 'boost', and
negative gain, referred to as 'cut'. [1]

There are two different types of equalizers:

1. Graphic Equalizers
In the graphic equalizer, the input signal is sent to a bank of filters. Each filter passes
the portion of the signal present in its own frequency range or band. The amplitude
passed by each filter is adjusted using a slide control to boost or cut frequency
components passed by that filter. The vertical position of each slider thus indicates the
gain applied at that frequency band, so that the knobs resemble a graph of the
equalizer's response plotted versus frequency. [2]

Figure 1 Graphic Equalizer

Sidra Fahim
Fa2012 MSEE 056

2. Parametric Equalizer
Parametric equalizers are multi-band variable equalizers which allow users to control
the three primary parameters: amplitude, center frequency and bandwidth. [2]The
amplitude of each band can be controlled, and the center frequency can be shifted, and
bandwidth ("Q") can be widened or narrowed.

Figure 2 Parametric Equalizer

Sidra Fahim
Fa2012 MSEE 056

2. SOFTWARE DESIGN METHODOLOGY


1. Graphic Interface of Audio Equalizer
Firstly, a graphical overview of the required equalizer is designed with appropriate
buttons, sliders and axes placements.

Figure 3 GUI Design

1. Push buttons
Browse the .*wav files from computer to read and equalized.
After selecting the file, process button plots the frequency response of the
speech/audio file.
Play sound button for playing audio selected.
Gains can be set to zero by pressing Reset Gains button.
2. Panel
Process, Play Sound and Reset Gains options are grouped into an Option panel for the
user accessibility.

Sidra Fahim
Fa2012 MSEE 056
3. Sliders
10 different sliders with required cutoff frequencies are placed which can be changed by
user in real time.
4. Static Text
Few static texts are introduces such as Select, Frequencies, -20dB and 20dB. These
texts cant be edited in run-time.
5. Edit Texts
When users vary the gain of the sliders, the gain values appear in the edit text gadget
below each slider. Also, when user select the audio file from computer its path also
appear in an edit text box.
6. Tools
Following tools are added in tool bar:
Save figure, Legend, Print, Color Bar, Data cursor

Figure 4 Toolbars in Software

Sidra Fahim
Fa2012 MSEE 056

2. Run GUI interface


Now when all the desired buttons are set, click play or Run Fig to see layout.

Figure 5 Basic GUI

3. M-file editing
Now click on open editor to see m-file related to the project. Audio_equalizer_sidra.m
contains a variety of functions related to sliders, push button, edit text buttons etc
Functions which are edited are shown below:
1. Browsing function

Figure 6 Browsing

Sidra Fahim
Fa2012 MSEE 056

% --- Executes on button press in Browse.


function pushbutton12_Callback(hObject, eventdata, handles)
global s fs Fs
[FileName,PathName,FilterIndex] =uigetfile({'*.wav'},'Load Wav File');
isok=true;
if length(FileName)==1
if FileName==0
isok=false;
end
end
if isok
fln=[PathName FileName];
set(handles.edit3,'string',fln);
[s, fs]=wavread(fln);

end

2. Processing Function
This function reads and plots the sound wave as shown below:

% --- Executes on button press in Process.


function Process_Callback(hObject, eventdata, handles)
% hObject

handle to Process (see GCBO)

% eventdata

reserved - to be defined in a future version of MATLAB

% handles

structure with handles and user data (see GUIDATA)

global s Fs fs
Y=fftshift(fft(s));
% plot spectrum of bottom 5000Hz
hzFs=Fs*length(Y)/fs;
f=(0:hzFs)*fs/length(Y);
plot(handles.axes3,f,20*log10(abs(Y(1:length(f)))+eps));
legend('Spectrum');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
drawnow;

Sidra Fahim
Fa2012 MSEE 056

Figure 7 Processing

3. Scrolling sliders and Updating Gains


Similar functions are used to update other sliders and edit test string below each slider.

% --- Executes on slider movement.


function slider12_Callback(hObject,
eventdata, handles)
g1=get(hObject,'Value');
set(handles.edit4,'string',g1);
updategains;
update_filters;

function edit4_Callback(hObject,
eventdata, handles)
Figure 9 Editing sliders

get(handles.edit4,'string');

Figure 8 Changing sliders value

Sidra Fahim
Fa2012 MSEE 056
4. Update Filters
Two more functions are called inside sliders function:1. updategains.m

2. update_filters.m

function updategains

function update_filters

global hdls g

global g hdls Fs s fs

g(1)=get(hdls.slider12,'value');

g1=-10;

g(2)=get(hdls.slider13,'value');

g2=10;

g(3)=get(hdls.slider14,'value');

n=10; % number of sliders

g(4)=get(hdls.slider15,'value');

f=[60

g(5)=get(hdls.slider16,'value');

Q=1*ones(1,n); % Q-factors

g(6)=get(hdls.slider17,'value');

filts_type=[1 2*ones(1,n-2) 3]; % filt types: 1-low shelving, 2peak, 3-high shelving

g(7)=get(hdls.slider18,'value');
g(8)=get(hdls.slider19,'value');
g(9)=get(hdls.slider20,'value');

170 310

600 1e3 3e3

6e3

12e3

14e3

16e3]; % frequencies

Y=zeros(size(s));
for nc=1:n
switch filts_type(nc)

g(10)=get(hdls.slider21,'value');

case 1

end

[b a]=get_low_shelving_filter(g(nc),Q(nc),f(nc),Fs);
y=filter(b, a, s);
case 2
[b a]=get_peak_filter(g(nc),Q(nc),f(nc),Fs);
y=filter(b, a, s);
case 3
[b a]=get_high_shelving_filter(g(nc),Q(nc),f(nc),Fs);
y=filter(b, a, s);
end
Y=Y+y;
end

Sidra Fahim
Fa2012 MSEE 056
Update_filter is the core part of equalizer. Filters used in equalizer are
1. Low/High shelving filter
A filter designed to alter the level of all signals beyond a certain frequency by a userdefinable amount.

Figure 10 H/L shelving filter [2]

function [b a]=
get_high_shelving_filter(g,Q,f,Fs)

function [b a]=
get_low_shelving_filter(g,Q,f,Fs)

A=10^(g/40);

A=10^(g/40);

w=2*pi*f/Fs;

w=2*pi*f/Fs;

sn=sin(w);

sn=sin(w);

cs=cos(w);

cs=cos(w);

bt=sqrt(A)/Q;

bt=sqrt(A)/Q;

b=A*[(A+1)+(A-1)*cs+bt*sn,...

b=A*[(A+1)-(A-1)*cs+bt*sn,...

-2*((A-1)+(A+1)*cs),...

2*((A-1)-(A+1)*cs),...

(A+1)+(A-1)*cs-bt*sn];

(A+1)-(A-1)*cs-bt*sn];

a=[(A+1)-(A-1)*cs+bt*sn,...

a=[(A+1)+(A-1)*cs+bt*sn,...

2*((A-1)-(A+1)*cs),...

-2*((A-1)+(A+1)*cs),...

(A+1)-(A-1)*cs-bt*sn];

(A+1)+(A-1)*cs-bt*sn];

b=b/a(1);

b=b/a(1);

a=a/a(1);

a=a/a(1);

Sidra Fahim
Fa2012 MSEE 056
2. Peak Filter:It boosts a specific band of frequencies. Q is a measure of the width of the frequency
range altered by a peaking filter.
function [b a]=
get_peak_filter(g,Q,f,Fs)
A=10^(g/40);

w=2*pi*f/Fs;
sn=sin(w);
cs=cos(w);
al=sn/(2*Q);

b=[1+al*A

-2*cs

1-al*A];

a=[1+al/A

-2*cs

1-al/A];

b=b/a(1);
Figure 11 Peak Filtering

a=a/a(1);

5. Play Sound
This button reads the file from the path given in the browse window.
% --- Executes on button press in Play Sound.
function pushbutton13_Callback(hObject, eventdata, handles)
global s fs;
sound(s,fs);

6. Reset Gains
This button set all the gains of the frequency bands to zero.
% --- Executes on button press in Reset.
function Reset_Callback(hObject, eventdata, handles)
global g n;
n=10;
g=zeros(n,1);
set(handles.slider12,'value',0);
set(handles.edit4,'string',0);
get(handles.edit4,'string');

Sidra Fahim
Fa2012 MSEE 056

3. Bibliography

[1] "Equalizer

Explained,"

1985.

[Online].

Available:

http://www.soundonsound.com/sos/jul01/articles/equalisers1.asp. [Accessed 24 July


2014].

[2] G. Massenburg, "Parametric Equalization," ITI Audio Products.

[3] D. Bohn, "Operator Adjustable Equalizers: An Overview," Rane Corporation.

[4] A. Degani, "DIGITAL AUDIO PROCESSING," University of Brescia - Communication


Technology and Multimedia.

Вам также может понравиться