sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.78k stars 923 forks source link

Audio output delay on Raspbian #2111

Open AugustGSP opened 5 years ago

AugustGSP commented 5 years ago

Setup

Problem

I have a barebones setup where a MIDI interface sends inputs to a Raspberry Pi running Sonic Pi. The setup is working and outputting audio as expected, however there's a very noticeable delay (by my estimate about 200-300ms) between when the MIDI event is recoded in Sonic Pi and when audio is outputted (through the audio jack).

So far i've tried use_real_time as well as set_sched_ahead_time. Neither seem to have any effect in reducing the delay. I've also tried every combination of preference settings that i thought might affect the delay, without success.

What are my options in terms of minimizing the delay/latency?

Quick note: I've previously tried SamplerBox on the same hardware and OS, which had no perceivable delay. Unfortunately it had other limitations that led me to explore Sonic Pi.

EDIT:

I've also made sure to enable real-time audio like so: http://jackaudio.org/faq/linux_rt_config.html

I've also tested a web browser sampler using the same environment, which had no perceivable delay. I feel like i can say with some amount of confidence, that the latency issues originate inside Sonic Pi, and not because of a miss-configured environment or missing drivers.

What are your thoughts?

Code

Copy-paste from the MIDI tutorial snippet.

live_loop :midi_piano do
  use_real_time
  note, velocity = sync "/midi/nanokey2_keyboard/0/1/note_on"
  synth :piano, note: note, amp: velocity / 127.0
end
augustbjornberg commented 5 years ago

Waiting