audio equalizer in matlab.ppt
TRANSCRIPT
![Page 1: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/1.jpg)
Project VII:
Leslie Murphy Beth Keswani
![Page 2: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/2.jpg)
IntroductionPurpose GUI Explanation/DesignFilter ExplanationFilter DesignDemonstrationResultsConclusion
![Page 3: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/3.jpg)
For Project VII, we wanted to utilize our programming skills by creating three audio equalizers in Matlab
![Page 4: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/4.jpg)
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
![Page 5: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/5.jpg)
![Page 6: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/6.jpg)
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
![Page 7: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/7.jpg)
![Page 8: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/8.jpg)
![Page 9: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/9.jpg)
Desired values are starting and stopping point frequencies (Bandwidth) & Gain
Convert signal into the frequency domain
Filter out unwanted frequenciesConvert back to time domain
![Page 10: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/10.jpg)
![Page 11: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/11.jpg)
Desired values are N (number of notches) and ∆ω (Bandwidth)
Convert signal into the frequency domain
Filter out unwanted frequenciesConvert back to time domain
![Page 12: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/12.jpg)
![Page 13: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/13.jpg)
Desired values are ω₀ (Notching frequency) & ∆ω (Bandwidth)
Convert signal into the frequency domain
Filter out unwanted frequenciesConvert back to time domain
![Page 14: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/14.jpg)
GUI with a movable bar for each channel
Band-pass filters
Apply the wanted gain
Convolve & Combine
Output
![Page 15: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/15.jpg)
Function statement to call the equalizer function from the GUI
function [f, f9] = equalize_audio(f, f9); %Equalizer %Les Murphy %Beth Keswani
![Page 16: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/16.jpg)
Wavread creates a matrix from an audio file
[x,fs]=wavread('utopia.wav'); N = 62;
![Page 17: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/17.jpg)
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);
![Page 18: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/18.jpg)
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;
![Page 19: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/19.jpg)
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;
![Page 20: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/20.jpg)
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');
![Page 21: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/21.jpg)
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);
![Page 22: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/22.jpg)
We applied the gain to each convolved channel. This is an example of one channel.
yA= g1 * y1; %wavwrite(yA,fs,'Equalizer1');
![Page 23: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/23.jpg)
We then combined each of the convolved channels into one matrix.
yI = yA + yB + yC + yD + yE + yF + yG + yH;
![Page 24: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/24.jpg)
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');
![Page 25: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/25.jpg)
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]);
![Page 26: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/26.jpg)
![Page 27: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/27.jpg)
GUI with a movable bar for inputs
Modify input values
Comb function & filter design
Convolve & Combine
Output
![Page 28: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/28.jpg)
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)
![Page 29: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/29.jpg)
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
![Page 30: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/30.jpg)
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];
![Page 31: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/31.jpg)
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
![Page 32: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/32.jpg)
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]);
![Page 33: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/33.jpg)
![Page 34: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/34.jpg)
GUI with a movable bar for inputs
Modify input values
Notch function & filter design
Convolve & Combine
Output
![Page 35: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/35.jpg)
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)
![Page 36: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/36.jpg)
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
![Page 37: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/37.jpg)
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];
![Page 38: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/38.jpg)
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
![Page 39: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/39.jpg)
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]);
![Page 40: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/40.jpg)
![Page 41: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/41.jpg)
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
![Page 42: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/42.jpg)
Sucessfully, we created three audio equalizers using the FIR, comb and notch filters in Matlab with the help of a GUI and user inputs.
![Page 43: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/43.jpg)
![Page 44: Audio Equalizer in Matlab.ppt](https://reader035.vdocuments.mx/reader035/viewer/2022081412/54492781b1af9f4f618b4ea8/html5/thumbnails/44.jpg)