Sunteți pe pagina 1din 44

Project VII:

Leslie Murphy Beth Keswani

Introduction Purpose GUI Explanation/Design Filter Explanation Filter Design Demonstration Results Conclusion

For Project VII, we wanted to utilize our programming skills by creating three audio equalizers in Matlab

Create three different equalization techniques that utilize a GUI (Graphical User Interface):
FIR Filter with eight gain channels and cutoff

frequency options Comb Filter using two channel inputs Notch Filter using two channel inputs

Buttons Load Process Play and Save are exclusively for the FIR Filter Buttons Comb and Notch process those filters respectively 8-bands left of the Comb and Notch buttons are for adjusting the gains of the FIR filter 2-bands to the right are for the comb and notch filters Text boxes are the user defined cutoff frequencies

Desired values are starting and stopping point frequencies (Bandwidth) & Gain Convert signal into the frequency domain Filter out unwanted frequencies Convert back to time domain

Desired values are N (number of notches) and (Bandwidth) Convert signal into the frequency domain Filter out unwanted frequencies Convert back to time domain

Desired values are (Notching frequency) & (Bandwidth) Convert signal into the frequency domain Filter out unwanted frequencies Convert back to time domain

GUI with a movable bar for each channel

Bandpass filters

Apply the wanted gain

Convolve & Combine

Output

Function statement to call the equalizer function from the GUI


function [f, f9] = equalize_audio(f, f9);
%Equalizer %Les Murphy %Beth Keswani

Wavread creates a matrix from an audio file

[x,fs]=wavread('utopia.wav');

N = 62;

We brought in variables f and f9 and data from the GUI, then used the f matrix to adjust the gains.
%These are the gains on each of the 8 bands %Taking values from f changed using GUI Sliders g1 = 10^f(1); g2 = 10^f(2); g3 = 10^f(3); g4 = 10^f(4);

g5 = 10^f(5);
g6 = 10^f(6); g7 = 10^f(7); g8 = 10^f(8);

We took the cutoff frequency of each band and scaled it down to proportional values from the f9 matrix.
project=12800; co1 = f9(1)/project; co2 = f9(2)/project; co3 = f9(3)/project; co4 = f9(4)/project; co5 = f9(5)/project; co6 = f9(6)/project; co7 = f9(7)/project;

We took the new values and prepared a variable to use with fir1. These values are cutoff constants.
Wn1 = co1; Wn2 = [co1, co2]; Wn3 = [co2, co3]; Wn4 = [co3, co4]; Wn5 = [co4, co5]; Wn6 = [co5, co6]; Wn7 = [co6, co7]; Wn8 = co7;

The range of cutoff constants create a basic filter, with channel 8 representing a filter above the constant.
filter1 = fir1(N,Wn1);
filter2 = fir1(N,Wn2); filter3 = fir1(N,Wn3); filter4 = fir1(N,Wn4);

filter5 = fir1(N,Wn5);
filter6 = fir1(N,Wn6); filter7 = fir1(N,Wn7); filter8 = fir1(N,Wn8,'high');

We convolve the basic filters with the matrix from the audio file, which creates 8 sections that will combine to create a new audio file.
y1 = conv(filter1,x);
y2 = conv(filter2,x); y3 = conv(filter3,x); y4 = conv(filter4,x);

y5 = conv(filter5,x);
y6 = conv(filter6,x); y7 = conv(filter7,x); y8 = conv(filter8,x);

We applied the gain to each convolved channel. This is an example of one channel.

yA= g1 * y1; %wavwrite(yA,fs,'Equalizer1');

We then combined each of the convolved channels into one matrix.

yI = yA + yB + yC + yD + yE + yF + yG + yH;

We created an audio file based on our new matrix, and will then use a sampling frequency, fs, that we extracted from the original file via wavread.

wavwrite(yI,fs,'equalized_audio_file');

By creating a Fourier transform, we can visually display the gains of the frequencies.
donkey = 18000; ftransform = fft(yI); f444 = 1000*(0:donkey); figure(10); plot(f444,ftransform(1:(donkey+1))); title('Frequency content of equalized_audio_file.wav'); xlabel('frequency (Hz)'); ylim([0 10000]);

GUI with a movable bar for inputs

Modify input values

Comb function & filter design

Convolve & Combine

Output

This function acquires the variables from the GUI and the user settings.

function [a, b, c, beta] = combeq(G0, G, GB, D, Dw, s, f22)

G and GO are variable names we will apply to N and BW later. values from the matrix f22, which is a matrix containing values from the sliders in the GUI.

G0 = f22(1) G = (f22(2) + 1) / 2

j = round(G0) + 10

We used the following algorithms to define the inputs to the function iircomb.

wo = fs/((j + 1)*fs/20 + 1) wo = round(wo) + 1 bw = G*(fs/1.01)/(fs) + 0.001;

[num, den] = iircomb(wo,bw,'notch');


filter1 = [num, den];

Next we convolve our filter with our original audio matrix for a finalized audio matrix. Write this matrix to a wave file and we are finished

y1 = conv(x, filter1); %Convolve


fvtool(num, den, y1, 1, x, 1); %Display Output on Graph

wavwrite(y1,fs,'equalized_audio_file');
%Write audio file

We used the following algorithm to display the Fourier Transform of the original and final outputs.

donkey = 18000; ftransform = fft(y1); oftransform = fft(x); f444 = 1000*(0:donkey); figure(10); plot(f444,ftransform(1:(donkey+1))); hold on; plot(f444,oftransform(1:(donkey+1)),'r'); title('Frequency content of equalized_audio_file.wav'); xlabel('frequency (Hz)'); ylim([0 10000]);

GUI with a movable bar for inputs

Modify input values

Notch function & filter design

Convolve & Combine

Output

This function acquires the variables from the GUI and the user settings.

function [a, b, c, beta] = combeq(G0, G, GB, D, Dw, s, f22)

G and GO are variable names we will apply to fO and BW later. values from the matrix f22, which is a matrix containing values from the sliders in the GUI.

G0 = (f22(1) + 10) / 20 G = (f22(2) + 10) / 20

We used the following algorithms to define the inputs to the function iirnotch.

wo = G0*(fs/1.01)/(fs) + 0.001 bw = G*(fs/1.01)/(fs) + 0.001; [num, den] = iirnotch(wo,bw);

filter1 = [num, den];

Next we convolve our filter with our original audio matrix for a finalized audio matrix. Write this matrix to a wave file and we are finished

y1 = conv(x, filter1); %Convolve


fvtool(num, den, y1, 1, x, 1); %Display Output on Graph

wavwrite(y1,fs,'equalized_audio_file');
%Write audio file

We used the following algorithm to display the Fourier Transform of the original and final outputs.

donkey = 18000; ftransform = fft(y1); oftransform = fft(x); f444 = 1000*(0:donkey); figure(10); plot(f444,ftransform(1:(donkey+1))); hold on; plot(f444,oftransform(1:(donkey+1)),'r'); title('Frequency content of equalized_audio_file.wav'); xlabel('frequency (Hz)'); ylim([0 10000]);

Equalizers work but with a few errors.


Wav files must be short MP3 / WMA etc. not supported (Matlab package) The Matlab function, Fir1, did not work with small

frequency ranges, as the increase/decrease was gradual Both Comb and Notch filters had a phasing problems once filter matrix was set to single variable name

Sucessfully, we created three audio equalizers using the FIR, comb and notch filters in Matlab with the help of a GUI and user inputs.

S-ar putea să vă placă și