MIDI In - real time problem

Hi to all, I search for a solution in the web but I can’t find one so I write the problem here. With the new version (3.1) finally Sonic Pi can handle the MIDI, but the use_real_time command return me the error:

!! Out of time, skipping: synth :piano, {notes: 79.0, amp: 0.64 etc…

with no note out audible.

I run the code (fixed for my midi device) found in this page:

live_loop :midi_piano do
note, velocity = sync “/midi/f37/0/1/note_on”
synth :piano, note: note, amp: velocity / 127.0

Can you help me?

In the Audio tab in Sonic Pi preferences there is a switch “Enforce timing guarantees”. You are getting skipping errors because of timing. It may be you have this switch ticked. If so, try removing the tick and trying again.

Another thing you could try would be to remove the use_real_time command. This may get it working, but you will find a very large latency if so. If it does work in this circumstance, you could slowly reduce the latency time by using (instead of the use_real_time command).
use_sched_ahead_time <number>
where should start at say 0.2 and slowly be reduced eg 0.18, 0.15…etc
use_real_time is equivalent to set_sched_anead_time 0

By the way: what computer are you running on?

1 Like

Thanks for the answer, and sorry for the late I took to reply. I use a desktop computer, with a AMD Athlon Dual Core Processor 4050e at 2.1Gz, I’ve instelle 4Gb of RAM (I think DDR2, if I remember right), and the OS is Windows 7 at 36 bit. I use and external audio card, the UR22 by Steinberg.

I have already tried all that solutions, but, I can’t say there is no latecy, as always it’s for me hard to play in real time via midi…

Hi @Mattia,

I think the problem you’re facing now is that the default Windows audio drivers have quite a bit of latency. On Windows, I’ve typically had to switch drivers to ASIO4ALL which has had a dramatic effect. Unfortunately this isn’t currently possible without patching Sonic Pi’s source code directly.

If this is something you’re prepared to have a go at, I’d be happy to give you guidance.

Your guidance will be appreciated, as i am also having this problem. I am using a midi keyboard known as the roli seaboard. its touch/pressure sensitive, for some reason, sonic pi is only able to ring out a few out of the hundred different notes played. I would also appreciate advice on how to store the notes of the midi into into an object so i can sample it. As always Sam, thank you so much, for all it is that you do.

@king_job - my understanding is that the Roli Seaboard spits out more than standard MIDI not on/off events. Do you have the specification of what it’s actually sending when you press a key down?

Also, all received notes are currently stored in the time state, so there’s no need for you to manually store anything. However, functions for making it easy to work with this history are still in development :slight_smile: