Issue with MATLAB app designer playing sounds

310 views Asked by At

I am trying to play a sound when I press a button using MATLAB app designer 2021a; I use the following lines

    [x, fs] = audioread('abc.wav');
    freq = 2 * fs;  
    player = audioplayer(x, freq); 
    play(player);

But I don't get the audio. However, when I copy the same lines in the command box, I get the audio after I wrote the following lines there:

   restoredefaultpath
    rehash toolboxcache
    savepath

Can someone please tell me how I can play using app designer cause the lines above create lag there? Thank you

1

There are 1 answers

1
Adham El Khouly On

For anyone facing a similar issue, I used

sound(x,freq);

instead of

player = audioplayer(x, freq); 
play(player);