Borrar filtros
Borrar filtros

playing a nonstop audio file

5 visualizaciones (últimos 30 días)
Mohamed Turkmani
Mohamed Turkmani el 6 de Sept. de 2022
Editada: Mohamed Turkmani el 7 de Sept. de 2022
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

Respuestas (1)

jibrahim
jibrahim el 6 de Sept. de 2022
You can use dsp.AudioFileReader with PlayCount set to Inf:
afr = dsp.AudioFileReader('speech_dft.mp3','PlayCount',Inf);
adw = audioDeviceWriter('SampleRate', afr.SampleRate);
while ~isDone(afr)
audio = afr();
adw(audio);
end
  5 comentarios
jibrahim
jibrahim el 6 de Sept. de 2022
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
Mohamed Turkmani el 7 de Sept. de 2022
Editada: Mohamed Turkmani el 7 de Sept. de 2022
ok it is working the problem is when i press the button to increas the volume, it doesnt work in real time, it waits until the audio is done and repeats with the increased volume

Iniciar sesión para comentar.

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by