MATLAB app designer not playing sounds
조회 수: 17 (최근 30일)
이전 댓글 표시
I am trying to excute the following lines with MATLAB app designer
[x, fs] = audioread('wave.wav');
app.freq = 2 * fs;
player = audioplayer(x, app.freq);
play(player);
but no sound is produced. However, when I copy the above lines along with those lines,
restoredefaultpath
rehash toolboxcache
savepath
it sounds in the command window but not in the app designer.
How can I fix this issue? - TIA
댓글 수: 0
채택된 답변
Subhadeep Koley
2021년 4월 27일
I have attached one demo minimum working example.
Have a look. It might help you fix the issue.
Also, if possible provide the full path of the sound file when reading it with audioread()
댓글 수: 5
Subhadeep Koley
2021년 4월 27일
Then invoke play(app.player)
[filename, pathname]=uigetfile({'*.wav'},'File Selector');
fullpathname = fullfile(pathname, filename);
try
[app.x,app.fs] = audioread(fullpathname);
catch
return
end
app.wavFolderAvailableLamp.Color = 'g';
app.freq = 2 * app.fs;
app.player = audioplayer(app.x, app.freq); % Here app.player is a public property variable
play(app.player);
추가 답변 (1개)
Adham Elkhouly
2021년 4월 27일
댓글 수: 2
Subhadeep Koley
2021년 4월 27일
@Adham Elkhouly I think, if you use sound(app.x, app.freq), then the audio clip will keep on playing even if you close the app window.
Whereas, using the below code, will stop the sound as soon as you close the app window.
app.player = audioplayer(app.x, app.freq);
play(app.player);
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!