How to Play a audio File without delay

13 visualizaciones (últimos 30 días)
John Hock
John Hock el 9 de Feb. de 2019
Comentada: John Hock el 9 de Feb. de 2019
Hi Everyone
I am working on a project in which I am creating an audio file and playing through MATLAB
The audio file is of 10 sec length.While playing first audio file I am doing the processing for next 10 sec data which take around 3 sec to create next audio file.
I just want to do that the second audio file should played without any delay(means when first audio file ends it automatically play the next file) and secondly the processing for the second audio file should start when first audio file played for 7sec.
This work is same as ECG machine where there is no delay between the audio means it read values and create audio and play.

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Feb. de 2019
For the greatest control you should look at https://www.mathworks.com/help/dsp/ref/dsp.audiofilereader-system-object.html and https://www.mathworks.com/help/audio/ref/audiodevicewriter-system-object.html and you should consider streaming data from the source instead of using 10 second files.
Otherwise, read the file with audioread() . Create an audioplayer() object https://www.mathworks.com/help/matlab/ref/audioplayer.html . Configure a TimerFcn callback with a TimerPeriod of 7 seconds and configure a StopFcn callback. play() the first object. When the timerFcn callback fires at 7 seconds, audioread() the second file and create a second audioplayer object for it and set up TimerFcn and TimerPeriod and StopFcn for it, and then return from the timer callback. When the first object hits the StopFcn callback, that callback should play() the second audioplayer() object.
This setup does not promise no delay: there will be the delay of firing the StopFcn callback to invoke the play() of the next file each time. If that delay turns out to be too much then you will need to switch to the audiodevicewriter system objects that I linked to before.
  1 comentario
John Hock
John Hock el 9 de Feb. de 2019
@ Walter Roberson
Thanks for your time
I started working on your idea

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by