How to Play a audio File without delay
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John Hock
am 9 Feb. 2019
Kommentiert: John Hock
am 9 Feb. 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.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Feb. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!