From: Mario on 5 Sep 2009 19:31 hi, Im having a problem I need a GUI this 3 basic controls 1 push button to load a wav file (audio), 1 axes to plot it and a second push button to play te wav file this is the code in my GUI file ( all the other code is matlab) -------------------------------------- function AbrirMedia_Callback(hObject, eventdata, handles) [nombre direccion]=uigetfile('*.wav','abrir'); [OriginalSound,Fs] = wavread(nombre); t=size(OriginalSound,1)/Fs; tiempo = 0:1/Fs:t; plot(tiempo(2:end),OriginalSound) function PlayMedia_Callback(hObject, eventdata, handles) sound(handles.OriginalSound,handles.Fs) -------------------------------------- everything seems to be fine but when I press the second pushbutton, I have an error: ??? Undefined function or variable 'OriginalSound'. Error in ==> LoadFile>PlayMedia_Callback at 102 sound(OriginalSound,Fs) WHY????????????? if you can help me Thanks!!!
From: ImageAnalyst on 5 Sep 2009 19:50 On Sep 5, 7:31 pm, "Mario " <mario_ma...(a)hotmail.com> wrote: > hi, Im having a problem I need a GUI this 3 basic controls 1 push button to load a wav file (audio), 1 axes to plot it and a second push button to play te wav file this is the code in my GUI file ( all the other code is matlab) > > -------------------------------------- > function AbrirMedia_Callback(hObject, eventdata, handles) > > [nombre direccion]=uigetfile('*.wav','abrir'); > [OriginalSound,Fs] = wavread(nombre); > t=size(OriginalSound,1)/Fs; > tiempo = 0:1/Fs:t; > plot(tiempo(2:end),OriginalSound) > > function PlayMedia_Callback(hObject, eventdata, handles) > > sound(handles.OriginalSound,handles.Fs) > > -------------------------------------- > everything seems to be fine but when I press the second pushbutton, I have an error: > > ??? Undefined function or variable 'OriginalSound'. > > Error in ==> LoadFile>PlayMedia_Callback at 102 > sound(OriginalSound,Fs) > > WHY????????????? > if you can help me Thanks!!! ----------------------------------------------------------------- In function 1, store the variable OriginalSound into your application's workspace with setappdata(). Then in function 2, retrieve it with getappdata(). Then you'd want to play the wave array OriginalSound, NOT handles.OriginalSound. And to play a sound, don't you use something like wavplay() rather than sound()? I think so, but I don't have MATLAB open at the moment.
|
Pages: 1 Prev: avi video Next: about coloring the selected part of the image |