top of page
PROJECTS

Emotion Detection Using Matlab

Design of Digital Parametric Equalizer Based on Second-Order Function [Code Download]

Problem Statement:

Design of Digital Parametric Equalizer Based on Second-Order Function

Researcher Paper Studied:

Design of Digital Parametric Equalizer Based on

Second-Order Function

Zhang Xiuli, Zhang Ruihua, Chen Weidong

Electronic and Information Engineering Department, Zhejiang Wanli University

Ningbo, China

xianzhangxiuli@sina.com

yisilong007@163.com

zrh3000@zwu.edu.cn

 

  1.  

Audio Equalizer:

Equalization is the process of adjusting the balance between frequency components within an electronic signal. The most well-known use of equalization is in sound recording and reproduction but there are many other applications in electronics and telecommunications. The circuit or equipment used to achieve equalization is called an equalizer. These devices strengthen (boost) or weaken (cut) the energy of specific frequency bands or "frequency ranges". [i]

 

Types of Equalizers:

i.)Parametric Equalizer:

The parametric equalizer is the most powerful and flexible of the equalizer types. Midrange bands in a parametric equalizer have three adjustments: gain, center frequency, and quality factor Q (or bandwidth). A parametric equalizer allows the operator to add a peak or a notch at an arbitrary location in the audio spectrum. At other frequencies, far away from the peak or notch, the parametric equalizer does not modify the spectral content, as its magnitude response, there is unity (0 dB). Adding a peak can be useful to help an instrument be heard in a complex mix, or to deliberately add coloration to an instrument’s sound by boosting or reducing a particular frequency range. Notches can be used to attenuate unwanted sounds, including removing power line hum (50 Hz or 60 Hz and sometimes their harmonics) and reducing feedback. To remove artifacts without affecting the rest of the sound, a narrow bandwidth would be used. A single section of a parametric equalizer is created from a second order peaking/notch filter, or in certain cases, a first or second order shelving filter for the lowest and highest frequency bands. When multiple sections are used, they are always connected in cascade so that the effects of each sub-filter are cumulative on a decibel scale. In this section, we derive the transfer functions for the first and second order shelving filter and for the second order peaking/notch filter.[ii]

ii.)ii.)  Graphic Equalizer

A graphic equalizer is a tool for independently adjusting the gain of multiple frequency regions in an audio signal. Common graphic equalizer designs can provide up to about 10 controls for manipulating the frequency response of each audio channel. Structurally, a graphic EQ is a set of filters, each with a fixed center frequency and bandwidth. The only user control is the command gain, or the amount of boost or cut, in each frequency band, which is often controlled with vertical sliders. The gain of each frequency band can usually be adjusted within the range 40dB, corresponding to approximately -20 < G < 20 for each filter. The term graphic refers to the fact that the position of the sliders’ knobs can be understood as a graph of the equalizer’s magnitude response versus frequency, which makes the graphic equalizer intuitive to use despite the number of controls. For this reason, it is a very popular device for sound enhancement, although it is more restricted than a parametric equalizer. Digital music players, such as those available in mobile phones, usually have several preset settings for the graphic equalizer for different music styles, such as pop, rock, and jazz, see e.g.

 

Here I am designing Graphic Equalizers.

GUI Design:

Here is a list of components which I am using in my GUI.

 

  1. Push Buttons

  2. Sliders

  3. Edit Text

  4. Static Text

  5. Pop-up Menu

1.) Push Button

Every push button in Matlab has a call-back-function which is run when we push the button.

2.) Sliders

            Every slider has a Max. and Min. value and the third one is the current value of slider which tells us what is the current position of the slider and it has a call back function which is run when we change the value of sliders.

3.) Edit Text

Edit text has a call back function which is run when we edit the string of the edit box.

4.) Static Text

The static text has no call back function it has only string value to show something in GUI.

 

  

MY GUI Design

 

Filter Designing for Equalizers:

Here in this equalizer, I am using 3 types of filter.

  1. Low Shelving Filter

  2. Peak Filter

  3. High Shelving Filter

The techniques I am using here to applying these filters is given below.

  1. Calculate the coefficients of transfer functions of filters using the following equations.   

 

 

 

 

[iii]

 

 

2.)  Than create sos of using coefficients of all filters

 

3.)  Then convert the SOS of the filter to direct form I object using the flowing command.

hobj=dfilt.df1sos(sys);

4.) After getting the filters object apply filters using filer commend.

 

Below code is given for filter calculation and applying.

function [hobj]=rcf(gn)

global xc1 xc2 aa f Fs hand Hd Q g;

g=gn;

[b1,a1]=l_shel(g(1),Q,f(1),Fs);

[b2,a2]=peak(g(2),Q,f(2),Fs);

[b3,a3]=peak(g(3),Q,f(3),Fs);

[b4,a4]=peak(g(4),Q,f(4),Fs);

[b5,a5]=peak(g(5),Q,f(5),Fs);

[b6,a6]=peak(g(6),Q,f(6),Fs);

[b7,a7]=peak(g(7),Q,f(7),Fs);

[b8,a8]=peak(g(8),Q,f(8),Fs);

[b9,a9]=peak(g(9),Q,f(9),Fs);

[b10,a10]=h_shel(g(10),Q,f(9),Fs);

alla=[a1;a2;a3;a4;a5;a6;a7;a8;a9;a10];

allb=[b1;b2;b3;b4;b5;b6;b7;b8;b9;b10];

sys=[allb alla];

hobj=dfilt.df1sos(sys);

Hd=hobj;

if (isequal(aa,g)==0)

rnplot();

end

 

function []=rnplot()

global xc1 xc2 aa f Fs g Hd;

    aa=g;

[h,w] = freqz(Hd);

fq=(w/pi)*Fs/2;

set(xc1,'XData',fq,'YData',20*log10(abs(h)));

set(xc2,'XData',f,'YData',g);

 

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

 

A=sqrt(10^(g/20));

w=2*pi*f/Fs;

ws=sin(w);

wc=cos(w);

al=ws/(2*Q);

 

b0=1+al*A;

b1=-2*wc;

b2=1-al*A;

a0=1+al/A;

a1=-2*wc;

a2=1-al/A;

 

a=[a0,a1,a2];

b=[b0,b1,b2];

 

b=b/a0;

a=a/a0;

 

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

 

A=sqrt(10^(g/20));

w=2*pi*f/Fs;

ws=sin(w);

wc=cos(w);

bt=sqrt(A)/Q;

 

b0=A*((A+1)+(A-1)*wc+bt*ws);

b1=-A*2*((A-1)+(A+1)*wc);

b2=A*((A+1)+(A-1)*wc-bt*ws);

 

a0=(A+1)-(A-1)*wc+bt*ws;

a1=2*((A-1)-(A+1)*wc);

a2=(A+1)-(A-1)*wc-bt*ws;

 

b=[b0 b1 b2]/a0;

a=[a0 a1 a2]/a0;

 

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

 

A=sqrt(10^(g/20));

w=2*pi*f/Fs;

ws=sin(w);

wc=cos(w);

bt=sqrt(A)/Q;

 

b0=A*((A+1)-(A-1)*wc+bt*ws);

b1=A*2*((A-1)-(A+1)*wc);

b2=A*((A+1)-(A-1)*wc-bt*ws);

 

a0=(A+1)+(A-1)*wc+bt*ws;

a1=-2*((A-1)+(A+1)*wc);

a2=(A+1)+(A-1)*wc-bt*ws;

 

b=[b0 b1 b2]/a0;

a=[a0 a1 a2]/a0;

 

 

 

The reason of the using Shelving Filter for starting and ending frequencies:

As peak filter is applying on some specifics frequencies range so if I use these filters on starting frequency and ending frequency than peak filter will destroy all the frequencies above and below its cutoff frequency. Due to these reasons, I am using Shelving Low pass filter on starting and High pass at the end of the frequencies range.

 

 

[i] https://en.wikipedia.org/wiki/Equalization_(audio)

 

[ii] http://www.mdpi.com/2076-3417/6/5/129

 

[iii] www.apogeebio.com/ddx/PDFs/AN-06.pdf

bottom of page