Very short sleep time gives Timing warning


I am trying to make a synthesizer play chords like you would play a guitar. That is, I simulate down-strokes and up-strokes by using a very short sleep interval between the individual notes that make up the chord.
Here’s the code:

play_pattern_timed (chord :E3, :minor), 0.005

Everything sounds fine. The only thing is, I get a lot of these warnings:

Timing warning: running slightly behind…

What does this actually mean? I assume it means that the pre-executing of the code is lagging behind the desired time? Like the value from use_sched_ahead_time cannot be satisfied?

PS: The value 0.005 is independent of bpm since I want the guitar strokes to have the same speed for any bpm. Therefore I pass it to this function:

define :secondsToBpm do |seconds|
  return current_bpm / 60.0 * seconds

So in the example above I assumed a bpm of 60 for brevity.

1 Like