I’m not sure if I understand exactly, but if you sleep for a 24th of a beat in your loop, then the loop will run 24 times per beat. Does this do what you want:
live_loop :beat do
sample :the_sample
sleep 1.0 / 24
end
Just listening to the output in a headphone (couldn’t try using the signal for sync yet), it is not constant. Could there be timing issues/streaming issues? Is there something to do for steady output and streaming?
I tried it myself and the timing seemed pretty steady - I couldn’t hear any variation. Are you using wired headphones? If they are bluetooth it’s possible they could be introducing some timing fluctuations.
I now tried in the real world case I was intending. The receiving device in an ERM Multiclock, which generates MIDI clock based on that sample playback.
Using Sonic Pi this way, I can see the tempo varying around the target tempo. When I do the same in say Ableton Live, it is steady.
That may be also caused by the fact that I use an ASIO driver for my RME UCX soundcard in Ableton Live, while I haven’t found that option in Sonic Pi (did I miss it?), so it’s using and WDM driver, for the same soundcard.