How to Play a audio File without delay

14 ビュー (過去 30 日間)
John Hock
John Hock 2019 年 2 月 9 日
コメント済み: John Hock 2019 年 2 月 9 日
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.

採用された回答

Walter Roberson
Walter Roberson 2019 年 2 月 9 日
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 件のコメント
John Hock
John Hock 2019 年 2 月 9 日
@ Walter Roberson
Thanks for your time
I started working on your idea

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

製品


リリース

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by