playing a nonstop audio file
이전 댓글 표시
how can i play an audio file without stopping kinda like a loop in app designer
[y,Fs] = audioread(app.files);
sound(y,Fs)
this will just play it once
답변 (1개)
jibrahim
2022년 9월 6일
afr = dsp.AudioFileReader('speech_dft.mp3','PlayCount',Inf);
adw = audioDeviceWriter('SampleRate', afr.SampleRate);
while ~isDone(afr)
audio = afr();
adw(audio);
end
댓글 수: 5
Mohamed Turkmani
2022년 9월 6일
Mohamed Turkmani
2022년 9월 6일
Mohamed Turkmani
2022년 9월 6일
jibrahim
2022년 9월 6일
You can control the range of the signal you want to play with the ReadRange property:
afr = dsp.AudioFileReader('speech_dft.mp3','PlayCount',Inf,'ReadRange', [start finish]);
Increasing the volume can be done by simply multiplying 'audio' by a constant of your choice.
Regarding the error, in your app, first clear your workspace, then make sure the object afr is only created once (say in setup of your app) and then somply call it in the loop. Do not recreate every time in your loop.
Mohamed Turkmani
2022년 9월 7일
편집: Mohamed Turkmani
2022년 9월 7일
카테고리
도움말 센터 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!