suppose there are two buttons in a GUI and from first button i browsed an audio file and now i want to use that audio file in the callback function of second button for further processing on that audio file with second button
2 次查看(过去 30 天)
显示 更早的评论
This is code for button 1:
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.wav'}, 'Select File');
fullpathname = strcat (pathname, filename);
[x,fs] = audioread(fullpathname);
%check apakah user menekan batal pada dialog
if isequal(filename,0) || isequal(pathname,0)
uiwait(msgbox ('User pressed cancel','failed','modal') )
hold on;
else
uiwait(msgbox('Audio have been selected','sucess','modal'));
hold off;
x = x (:,1)
N = length(x);
t = (0:N-1)/fs;
N/fs
%plot
plot(t,x)
grid on
xlabel('Time (s)')
ylabel('Ampl')
end
handles.output = hObject;
guidata(hObject, handles);
This is code for button 2:
function pushbutton4_Callback(hObject, eventdata, handles
handles.fullpathname = fullpathname;
if isfield(handles, 'fullpathname')
fullpathname = handles.fullpathname;
sr = 44100; %sampling rate
w = 512; %window size
T = w/sr; %period
t = linspace(0, 1, 44100);
twindow = t(1:512);
hamming = 0.54 - 0.46 * cos((2 * pi * twindow)/T);
axes5(handles.axes);
plot(hamming);
end
its not showing plot(hamming) after processing in axes why? how can we resolve that error? please guide
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulation, Tuning, and Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!