I’m sending an OSC message from Sonic Pi to Reaper DAW to trigger recording. My code in Sonic Pi looks like this:
use_osc "localhost", 8000
live_loop :bass_drum do
The problem is that I see a delay between start of the recording and start of that live_loop :bass_drum. The delay is about 140 milliseconds, and it throws the timing completely off. Here’s an illustration of what I see in Reaper:
Can this somehow be fixed on my side, or is it some sort of a limitation of Sonic Pi? Maybe start-up time of a live loop is so long?
as the first statement in the live_loop
See this previous thread
Good idea, but I would have imagined that this isn’t the issue as the default schedule ahead time is 500ms and that the OSC messages are designed to be scheduled with the same delay as the audio.
I would have assumed that putting the live loop into realtime mode would mean that the first 360ms of the audio is missing from the sound. @Roman could you verify this?
@Roman - welcome to the Sonic Pi forums. It’s lovely to have you here and so sorry that you’re having issues. I’d love to get to the bottom of this if we can.
Could you just verify which OS you’re using? Also, are you able to get a similar setup with a different audio app to see if the latency is introduced by the internal audio bus or by the DAW. How are you extracting the audio from Sonic Pi?
Hi and thanks for your replies!
I’ve tried with the
use_real_time and indeed it changes timing, but along the lines of what @samaaron has mentioned: first part of the audio is missing. I haven’t measured exact amount, but 360 millis sound about right.
Regarding the setup I’m using (sorry I haven’t mentioned this important information in my original post). I’m running Sonic Pi 3.1.0 on Windows 10 version 1809 (build 17763.529). I’m using Synchronous Audio Routing (http://sar.audio/) audio driver to create virtual audio devices and use them with my spl Crimson USB audio interface, running in ASIO mode. I’m recording the sound from the virtual device dedicated to Sonic Pi in Reaper DAW, and triggering the start of recording with the OSC message from Sonic Pi, as described in the original post.
I’m not sure how can I test any other setup, because I don’t have any other software which can both play some sound and send OSC commands, besides Sonic Pi. But I’d be ready to give this a try, if you could provide some guidance. But from what I understand, the SAR shouldn’t introduce any additional latency but what’s coming from the audio interface, and my Crimson is set up with 12 ms output latency and 2ms input latency:
Please let me know if I can provide any help investigating this. I’m not extremely experienced in digital audio though, so please bear with me.
It’s hard to know where this latency may come from.
One thing you could try to mitigate this issue is to use:
Does that help things?
Hi, and sorry for long delay in answer. I’ve tried different options, and the best one seems to be combining the
set_audio_latency! -140. The timing is still not perfect, but it got much closer, and I probably just need to play with the latency value. Thanks for your suggestions!
You shouldn’t need to switch to “real time” mode, this just changes the timestamps by the schedule ahead time (defaults to 500ms) and then increases jitter due to us now relying on Ruby for timing (which is typically avoided). Try adding or removing 500ms from the latency delta (so either -640 or 360). Does that help?
I think I give up. It looks like using
set_audio_latency! on its own doesn’t change anything in this situation (I tried values of different magnitude, but they all give same result). In addition, I’m not getting consistent results, and I sometimes need to restart Sonic Pi for changes to take an effect, as weird as it sounds. The more I’m looking into this, the more it seems to me it’s an artifact of my setup, especially by using SAR. It’s very frustrating, but probably has nothing to do with Sonic Pi. Looks like I need to find another way to record my drums.
Thanks for your suggestions so far, but let’s just close this topic.