Cannot plot audio waves in specific axes??

3 次查看(过去 30 天)
Hello, I am trying to plot audio waves in my axes(audioplot) which triggers after a push button - which also plays the audio. However, function that plays the audio lies in a different file from the main file.
----------------------------------------------------------------
function playbutton_ClickedCallback(hObject, eventdata, handles)
global audio_value;
playsounds(audio_value);
----------------------------------------------------------------
This function triggers playsounds.m which has this function. The argument passed is the file path that needs to read.
-------------------------
function playsounds(a)
[y, fs]=audioread(a);
sound(y, fs);
axes(handles.audioplot);
plot(y);
end
-----------------------
Now, I can play the audio file but it does not plot the waves. This is the error that is shown..
Undefined variable "handles" or class "handles.audioplot".
Error in playsounds (line 7) axes(handles.audioplot);
I have googled around and known that the handle is out of scope but I can't really find out what is happening here as the function is being called from the mainfile. It would be a great help if anyone can explain me this. Thanks in advance.

采纳的回答

Walter Roberson
Walter Roberson 2017-12-26
In the place you call playsounds add handles as a second argument. In the place you define playsounds add handles as the second argument

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by