Cannot plot audio waves in specific axes??

3 views (last 30 days)
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.

Accepted Answer

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

More Answers (0)

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!