I am typing a code where in one callback function I am browsing for a audio file (.wav) by hitting one pushbutton and setting the filename in one of the edit box (edit6). Now, I want this audio file to be read when I hit the second pushbutton. What command should I use? so that I can read the audio file which i selected and plot its fft and time domain? Here's the code..
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)[filename,filepath]= uigetfile({'*.*';'*.wav';'*.m4a'});fullname = [filepath filename];set(handles.edit6,'string', filename) ;% --- Executes on button press in button.
function button_Callback(hObject, eventdata, handles)% hObject handle to button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data= audioread('C:\Users\Mohanish\Desktop\GA\Project\mohanish.wav');L= length (data);Y= fft(data)P2= abs (Y/L)P1= P2(1:L/23+1);P1(2:end-1)= 2*P1(2:end-1)figure= subplot('position', [0.56, 0.15, 0.4, 0.3]);K= plot (P1);title ('Frequency Domain')xlabel('f(Hz)')ylabel('|P1(f)|')hold on[y,Fs]= audioread('C:\Users\Mohanish\Desktop\GA\Project\mohanish.wav');t= linspace(0,length(y)/Fs, length(y));figure1= subplot('position', [0.10, 0.15, 0.4, 0.3]);plot(t,y);title ('Time Domain')xlabel('Time (sec)')ylabel('Amplitude')
Best Answer