use_real_time removes Sonic Pi's scheduling look-ahead for MIDI and OSC-driven live loops
Sonic Pi schedules audio 0.5s ahead by default to ensure timing accuracy. For live_loops driven by sync on external MIDI or OSC events, this causes an audible delay between physical trigger and sound. Placing use_real_time at the top of such a live_loop disables the look-ahead for that thread, producing near-zero latency. Should not be used for code-driven synthesis where Sonic Pi’s scheduling is needed.
Examples
live_loop :midi_piano do use_real_time note, vel = sync “/midi/*/note_on” synth :piano, note: note, amp: vel / 127.0 end
Assessment
Explain what happens audibly if you omit use_real_time in a MIDI-driven live_loop. Explain why use_real_time should not be used in purely code-driven loops.