Task is to design a 10-band software
audio equalizer.
1/5/2017Audio Equalizer.............................................Hasham_Khan
 Open Matlab
 Using “ guide ” function create a new GUI
1/5/2017Audio Equalizer.............................................Hasham_Khan
 For 10 bands Audio Equalizer we need 10 sliders…
so select 10 sliders
1/5/2017Audio Equalizer.............................................Hasham_Khan
 After the completion of previous step your design will be like this ;
1/5/2017Audio Equalizer.............................................Hasham_Khan
 Define the values for each slider handles
• global stop C Fs;
• stop=1;
• Fs=44100;
• C=zeros(1,10);
Slider 1 values are as follow;
• set(handles.slider1,'min',-20);
• set(handles.slider1,'max',20);
• set(handles.slider1,'value',0);
• set(handles. slider1,'SliderStep',[0.025,0.05]);
• set(handles. slider1,'string',num2str(0));
Repeat the above steps for all 10 Sliders
1/5/2017Audio Equalizer.............................................Hasham_Khan
 Double click on each slider and click “ callback”
and “ CreateFtn ”…By clicking both you will see both functions
in your m file
1/5/2017Audio Equalizer.............................................Hasham_Khan
 To get the different values of slider add “get” function
• % Executes on slider movement.
• function slider1_Callback(hObject, eventdata, handles)
• global C;
• C(1)=get(hObject,'value');
• set(handles.slider1_val,'string',num2str(C(1)));
• % --- Executes during object creation, after setting all properties.
• function slider1_CreateFcn(hObject, eventdata, handles)
• if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
• set(hObject,'BackgroundColor',[.9 .9 .9]);
• end
Repeat the above steps for all 10 sliders
1/5/2017Audio Equalizer.............................................Hasham_Khan
 To add “Load”, “ Reset ”, “ Play ” ,“ Stop ’’ buttons use the Push button
in the GUI
 Double click on Push button and change the string and tag as load , reset ,
play and stop.
1/5/2017Audio Equalizer.............................................Hasham_Khan
 Now after adding the button your design will be like this ;
1/5/2017Audio Equalizer.............................................Hasham_Khan
 Double click on each button and select callback function
For Reset button :
• set(handles.slider1_val,'string',num2str(0));
• set(handles.slider1_var,'value',0);
Repeat the above step for all 10 sliders
For Load button :
• % -Executes on button press in load.
• function load_Callback(hObject, eventdata, handles)
• global file_name;
• file_name=uigetfile('*wav','hasham .wav');
1/5/2017Audio Equalizer.............................................Hasham_Khan
For Stop and Play Button :
• % --- Executes on button press in play.
• function play_Callback(hObject,
eventdata, handles)
• global stop file_name C;
• stop=1;
• equalizer_play();
• function equalizer_play()
• global stop file_name C;
• [x,Fs]=wavread(file_name);
• [a,b]=coef();
• l_bucata=2*Fs;
• Nb=round(length(x)/l_bucata);
• y=0;
• for i=1:floor(Nb)
• bucata=x((i-1)*l_bucata+1:i*l_bucata);
• for k=1:5
• y=y+filter(10^(C(k)/20)*b{k},a{k},bucat
a);
• if(stop==0)
• break;
• end
• end
• wavplay(y,Fs,'async');
• y=0;
• if(stop==0)
• break;
• end
• end
• % --- Executes on button press in stop.
• function stop_Callback(hObject, eventdata,
handles)
• global stop;
• stop=0;
1/5/2017Audio Equalizer.............................................Hasham_Khan
 Add Edit Text to each slider and double click the edit text icon and select
“callback” and “CreateFtn” for each slider
1/5/2017Audio Equalizer.............................................Hasham_Khan
 After adding the edit text to each slider your design will be like this ;
1/5/2017Audio Equalizer.............................................Hasham_Khan
 To have the value of each slider add the below code to each slider;
 function slider1_val_Callback(hObject, eventdata, handles)
 global C;
 C(1)=str2num(get(hObject,'string'));
 minn=get(handles.C1_var,'min');maxx=get(handles.C1_var,'max');
 if(C(1)<minn || C(1)>maxx)
 C(1)=get(handles.C1_var,'value');set(hObject,'string',num2str(0));
 else set(handles.slider1_var,'value',C(1));
 end
 function slider1_val_CreateFcn(hObject, eventdata, handles)
 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
 set(hObject,'BackgroundColor','black');
 end
Repeat the above step for all 10 sliders
1/5/2017Audio Equalizer.............................................Hasham_Khan
 Add equalizer plot and filter function in the code. As the equalizer is of
10 band so we have to design 10 filters.
1/5/2017Audio Equalizer.............................................Hasham_Khan
 After adding the equalizer plot your design will be like this ;
1/5/2017Audio Equalizer.............................................Hasham_Khan
 So your design of 10 Band Audio Equalizer is ready now run the code
1/5/2017Audio Equalizer.............................................Hasham_Khan
Thank You
Prepared by
Hasham Khan
hkhan.msee16seecs@seecs.edu.pk
NUST School of Electrical Engineering and Computer Science(SEECS)
1/5/2017Audio Equalizer.............................................Hasham_Khan

Audio equalizer

  • 2.
    Task is todesign a 10-band software audio equalizer. 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 3.
     Open Matlab Using “ guide ” function create a new GUI 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 4.
     For 10bands Audio Equalizer we need 10 sliders… so select 10 sliders 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 5.
     After thecompletion of previous step your design will be like this ; 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 6.
     Define thevalues for each slider handles • global stop C Fs; • stop=1; • Fs=44100; • C=zeros(1,10); Slider 1 values are as follow; • set(handles.slider1,'min',-20); • set(handles.slider1,'max',20); • set(handles.slider1,'value',0); • set(handles. slider1,'SliderStep',[0.025,0.05]); • set(handles. slider1,'string',num2str(0)); Repeat the above steps for all 10 Sliders 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 7.
     Double clickon each slider and click “ callback” and “ CreateFtn ”…By clicking both you will see both functions in your m file 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 8.
     To getthe different values of slider add “get” function • % Executes on slider movement. • function slider1_Callback(hObject, eventdata, handles) • global C; • C(1)=get(hObject,'value'); • set(handles.slider1_val,'string',num2str(C(1))); • % --- Executes during object creation, after setting all properties. • function slider1_CreateFcn(hObject, eventdata, handles) • if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) • set(hObject,'BackgroundColor',[.9 .9 .9]); • end Repeat the above steps for all 10 sliders 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 9.
     To add“Load”, “ Reset ”, “ Play ” ,“ Stop ’’ buttons use the Push button in the GUI  Double click on Push button and change the string and tag as load , reset , play and stop. 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 10.
     Now afteradding the button your design will be like this ; 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 11.
     Double clickon each button and select callback function For Reset button : • set(handles.slider1_val,'string',num2str(0)); • set(handles.slider1_var,'value',0); Repeat the above step for all 10 sliders For Load button : • % -Executes on button press in load. • function load_Callback(hObject, eventdata, handles) • global file_name; • file_name=uigetfile('*wav','hasham .wav'); 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 12.
    For Stop andPlay Button : • % --- Executes on button press in play. • function play_Callback(hObject, eventdata, handles) • global stop file_name C; • stop=1; • equalizer_play(); • function equalizer_play() • global stop file_name C; • [x,Fs]=wavread(file_name); • [a,b]=coef(); • l_bucata=2*Fs; • Nb=round(length(x)/l_bucata); • y=0; • for i=1:floor(Nb) • bucata=x((i-1)*l_bucata+1:i*l_bucata); • for k=1:5 • y=y+filter(10^(C(k)/20)*b{k},a{k},bucat a); • if(stop==0) • break; • end • end • wavplay(y,Fs,'async'); • y=0; • if(stop==0) • break; • end • end • % --- Executes on button press in stop. • function stop_Callback(hObject, eventdata, handles) • global stop; • stop=0; 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 13.
     Add EditText to each slider and double click the edit text icon and select “callback” and “CreateFtn” for each slider 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 14.
     After addingthe edit text to each slider your design will be like this ; 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 15.
     To havethe value of each slider add the below code to each slider;  function slider1_val_Callback(hObject, eventdata, handles)  global C;  C(1)=str2num(get(hObject,'string'));  minn=get(handles.C1_var,'min');maxx=get(handles.C1_var,'max');  if(C(1)<minn || C(1)>maxx)  C(1)=get(handles.C1_var,'value');set(hObject,'string',num2str(0));  else set(handles.slider1_var,'value',C(1));  end  function slider1_val_CreateFcn(hObject, eventdata, handles)  if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))  set(hObject,'BackgroundColor','black');  end Repeat the above step for all 10 sliders 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 16.
     Add equalizerplot and filter function in the code. As the equalizer is of 10 band so we have to design 10 filters. 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 17.
     After addingthe equalizer plot your design will be like this ; 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 18.
     So yourdesign of 10 Band Audio Equalizer is ready now run the code 1/5/2017Audio Equalizer.............................................Hasham_Khan
  • 19.
    Thank You Prepared by HashamKhan hkhan.msee16seecs@seecs.edu.pk NUST School of Electrical Engineering and Computer Science(SEECS) 1/5/2017Audio Equalizer.............................................Hasham_Khan