command clear sound doesn't work
Show older comments
Hello, I'm doing a GUI where I want to use a Play and a Stop button. I'm using the sound command, but the command clear sound doesn't work, I'm using Matlab online, so I cannot use the audioplayer command because it doesn't work. I don't know why the clear sound doesn't work, it used to work well in the matlab offline, but my teacher is going to usea the online ver, so I need to fix it.
sound(Final,SampleR);
clear sound;
9 Comments
Geoff Hayes
on 21 Apr 2020
Lina - I've seen some posts about using clear playsnd instead..though I'm not sure how valid it is (it won't work in my R2014a). Out of curiosity, why doesn't the audio player work on MATLAB Online? What error message do you observe?
Lina Marcela Cordoba Velasquez
on 22 Apr 2020
Lina Marcela Cordoba Velasquez
on 22 Apr 2020
Adam Danz
on 22 Apr 2020
Matlab online cannot interact with most hardware.
I believe clear sound was undocumented.
If your teacher expects students to use Matlab Online with sounds, you can point him/her to the link I shared above.
Lina Marcela Cordoba Velasquez
on 22 Apr 2020
I have several releases installed, but not enough to pinpoint when this was introduced. clear sound works in R2013b and later (test in R2019a and R2015a), but fails in R2011a. In that latter release clear playsnd seems to work.
%start playback
S=load('handel.mat');sound(S.y,S.Fs);
%stop playback on any release I could find
%'clear sound playsnd' to remove potential variables with those names
clear sound playsnd,clear sound,clear playsnd
%confirmed: R2019a, R2015a, R2013b, R2011a, R13 (v6.5)
Curious thing to leave undocumented.
I just tested it in r2020a and you can add that to the confirmed list (it works).
However it does not stop the sound from playing on Matlab Online
% matlab online
------------------------------------------------------------------------------------------------------
MATLAB Version: 9.8.0.1340451 (R2020a) Update 1
MATLAB License Number:
Operating System: Linux 4.14.174-0414174-generic #202003200742 SMP Fri Mar 20 11:45:37 UTC 2020 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
------------------------------------------------------------------------------------------------------
Rik
on 22 Apr 2020
Speculation time: based on this comment by Walter it could be OS-specific. (I can only test it on Windows, since I'm not planning on installing Matlab in an Ubuntu VM just to test this)
Adam Danz
on 22 Apr 2020
That very well may be the case. Windows user here so I can't test that either.
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!