2011-10-30 3 views
1

dans mon un de mes rappels, je charge un fichier wav puis le tracer dans un axes. dans un autre rappel, j'essaie de lire le fichier wav mais il ne fonctionne pas. s'il vous plaît aider, comment puis-je jouer ??matlab gui faire tableau public

function btnload_Callback(hObject, eventdata, handles) 
[filename, pathname] = uigetfile('*.wav','Select Data File'); 
[y,fs] = wavread([pathname filename]); 
axes(handles.axes1) 
plot(y); 
title('ORIGINAL AUDIO SIGNAL'); 
ylabel('t'); 
guidata(hObject, handles); %updates the handles 




function btnplay1_Callback(hObject, eventdata, handles) 
soundsc(y,fs); 

Répondre

3

Si vous avez besoin de maintenir application data dans GUIs GUIDE généré, est une façon d'utiliser la structure handles qui se transmet autour de toutes les fonctions de rappel:

function btnload_Callback(hObject, eventdata, handles) 
    %# read WAV file 
    [filename, pathname] = uigetfile('*.wav','Select Data File'); 
    [y,fs] = wavread([pathname filename]); 

    %# plot wave 
    axes(handles.axes1) 
    plot(y); 
    title('ORIGINAL AUDIO SIGNAL'); 
    ylabel('t'); 

    %# save it to handles structure 
    handles.y = y; 
    handles.fs = fs; 
    guidata(hObject, handles);  %# updates the handles 
end 

function btnplay1_Callback(hObject, eventdata, handles) 
    %# retrieve the wave data, and play the sound 
    soundsc(handles.y, handles.fs); 
end