High latency for audio use on a Raspberry Pi using Simulink

조회 수: 9 (최근 30일)
Amadeus
Amadeus 2014년 11월 24일
답변: Dong-uk Hyon 2018년 3월 1일
Hi everybody!
For a student project we decided to build test hardware for musical instrument effects. As base we decided to go for a Raspberry Pi with some peripheral equipment installed. We've programed the hardware just using Simulink with their tools and libraries. Everything works fine but we do have a huge latency with our audio signal.
Even when we try to put the signal through without effects, the latency is half a second long.
Do you have any ideas why?
Does the Raspberry Pi compute on its own or is all data just sent via ethernet?
How do I reduce buffer sizes?
Thanks for your help!
Regards, Amadeus

답변 (3개)

Tom Haelvoet
Tom Haelvoet 2016년 10월 8일
편집: Tom Haelvoet 2016년 10월 8일
Hi all,
The latency can be reduced from within Simulink after performing the following steps:
1. Drag & drop an ALSA Audio Playback block into your model.
2. Jump to the Library (CTRL+L) and unlock it.
3. Edit the mask (CTRL+M) of the ALSA Audio Playback block.
4. Navigate to Parameters & Dialog, Select Que duration & check the Visible flag.
5. Lock & save the library.
The Queue duration should now be visible and ready to be modified.
FYI: Tested with a Focusrite 2i2 (Device name = 'plughw:1.0') and a Queue duration of 50ms
  댓글 수: 1
Amadeus
Amadeus 2016년 12월 13일
Thank you very much!
That helped indeed.
It is better to get some help lately than have none. It works so much better now!
Regards, Amadeus

댓글을 달려면 로그인하십시오.


Murat Belge
Murat Belge 2014년 12월 10일
The ALSA Audio Playback block uses and audio buffer size of 0.5 seconds of data. You can not change this parameter unless you modify the source file (MW_alsa_audio.c). This parameter determines the latency.
It is very hard to achieve real-time, low-latency audio in Linux. If you reduce the audio buffer size, you might observe stutter / interruptions in the audio.

Dong-uk Hyon
Dong-uk Hyon 2018년 3월 1일
Hi,
On top of Tom's answer above, I am also carrying out audio experiments using Raspberry Pi and have found lowering the ALSA frame sample size down will significantly reduce the latency.
I found these settings by double clicking on the ALSA audio capture block. The default frame size for me was 4410 (N), by reducing this value you will find a better response of your system. I managed to go down to 10, and the delay is just about noticeable by audio.
Info found here: https://uk.mathworks.com/help/dsp/ug/sample-and-frame-based-concepts.html#bso3wxr-1
Kind regards, Don

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by