amiika / ziffers

Numbered musical notation for composing algorithmic and generative melodies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Initial note timing

sklink opened this issue · comments

I've just set up Ziffers and am having an issue with the timing of the first few notes. Here's an exmaple:

require "~/ziffers/ziffers.rb"

live_loop :first do
  zplay "0 035"
end

Here's the log output from the first note:

{run: 27, time: 1.0, thread: :live_loop_first}
 └─ synth :beep, {note: 60.0, release: 1.0}
 
{run: 27, time: 1.5, thread: :live_loop_first}
 └─ synth :beep, {note: [60.0, 65.0, 69.0], release: 1.0}
 
{run: 27, time: 2.5, thread: :live_loop_first}
 └─ synth :beep, {note: 60.0, release: 1.0}
 
{run: 27, time: 3.5, thread: :live_loop_first}
 └─ synth :beep, {note: [60.0, 65.0, 69.0], release: 1.0}

You can see that the first note comes in at 1.0 and the chord then plays at 1.5. After that, the timings are 1.0 apart.

I have tried this alongside a simple play, which does keep the correct timing.

I use my Mac for software dev so I don't think it would have trouble with the calculations under the hood, but that is a possibility.

Let me know if I can provide any more info. Thanks!

First of all, thanks for testing and posting issue! :)

It seems something has changed in Sonic Pi ahead of time scheduling. To reproduce the issue:

use_sched_ahead_time 1.0

live_loop :first do
  play 60
  sleep 1.0
  play 60
  play 65
  play 69
  sleep 1.0
end

Default in Ziffers is 1.0 for optimization, but this seems to produce odd timing for first beats ... 0.5 seems to work. For now quick fix seems to be to use sched_ahead parameter and set sched ahead timing to 0.5:

z1 "0 035", sched_ahead: 0.5

Changed default sched_ahead to 0.5 which fixes this for now ... until I figure out what is actually going on.