Cannot plot audio waves in specific axes??

3 vues (au cours des 30 derniers jours)
Nirajan Shrestha
Nirajan Shrestha le 26 Déc 2017
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 26 Déc 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

Plus de réponses (0)

Catégories

En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by