robbielyman / seamstress

seamstress is an art engine
GNU General Public License v3.0
129 stars 12 forks source link

fix: rework clocks #79

Closed robbielyman closed 1 year ago

robbielyman commented 1 year ago

the purpose of this PR is to really nail down clock.sync with MIDI and Link. i've hit upon a semi-workable solution, but could use feedback

@dndrks when you get a chance, would you mind testing this out? if you're on the homebrew build of seamstress, doing so should be as easy as cloning the repo, pulling down this branch, and doing zig build run -- test-midi in the repo root. the -- at the end lets you pass arguments to seamstress once it's built, so in this case i'm asking it to run a script called test-midi (probably in ~/seamstress).

known issues:

i'll keep poking at it too.

dndrks commented 1 year ago

raaaaad, omg you just casually rewrote a fundamental component of the system. wiiiiiild, thank you for all of your work!!!

test script

m = midi.connect(1)

function init()
  params:set('clock_source',2) -- '2' is midi, change to '1' for internal, '3' for link
end

function start_clock()
  step = 0
  print("started", clock.get_beats())
  test_clock = clock.run(function()
    while true do
      step = util.wrap(step + 1,1,16)
      print("step", clock.get_beats(), step)
      m:note_on(60, 127, 1)
      clock.sync(1)
      m:note_off(60, nil, 1)
    end
  end)
  print("running clock: "..test_clock)
end

function clock.transport.start()
  start_clock()
end

function clock.transport.stop()
  print("stopped, cancelling clock: "..test_clock)
  clock.cancel(test_clock)
  test_clock = nil -- cleans up the variable
end

Link results

in Live, i'm using a Global Launch Quantization of 1 Bar.

there seems to be a double-tap at transport start, where the clock action is called just before the beat i'd expect it to sync to and then on the beat i'd expect it to sync to.

so if i'm running a step sequencer, i'd get steps 1 and 2 blasted out on the first beat:

> are we playing: true
started 11.995096
step    11.995336   1 -- unexpected premature sync
running clock: 3
step    12.000256   2 -- expected sync
step    13.000252   3
step    14.000394   4

the MIDI out stream looks like this, where the first step gets two triggers:

image

re: link being behind the beat, i'm only seeing 1/256th distance in terms of the tick-to-MIDI-note journey, which feels totally workable imo!

MIDI results

everything looks good at transport start! there's only one, expected clock-sync fire at start, which is perf! the starting note is just barely 1/256th late, but that seems workable. as the sequence continues, it looks like each clock.sync(1) is firing pretty on-schedule in seamstress:

started 0.016608001062912
step    0.03802406643354    1
running clock: 3
step    1.0005250579021 2
step    2.0003966156531 3
step    3.0002447873308 4
step    4.0004181672096 5
step    5.0003806542426 6
step    6.0003360181437 7
step    7.0003239396711 8
step    8.0003593726645 9
step    9.0002515749693 10
step    10.000345627056 11
step    11.000401361572 12
step    12.000330216396 13
step    13.000372982103 14
step    14.000367824291 15
step    15.000355609877 16

but in Live, I'm seeing each of those notes pop in around 1/128th early:

image

follow-up q's

"sad and sorry state"

on the first first ever ever time seamstress receives a midi start message, if it hasn't been receiving clock beforehand, the midi clock is in a sad and sorry state, so takes a couple beats to figure itself out. notably this isn't a problem if one stops and restarts quickly?

i'm not seeing this, i don't think? unless, is that the 0.03802406643354-stamped first beat in my MIDI results above?

internal reset

if i load the test script on internal clock, i'd expect that hitting the reset action in the params would kickstart the sequence, but i'm only getting two steps before the clock seemingly stops executing its action:

started 0.3130976277506
step    0.31325825225076    1
running clock: 3
step    1.0003098784378 2
...

if i keep the script running, a minute later two additional notes occur, beat-stamped as if no time had passed!!

step    1.010734698167  3
step    2.0003111981566 4

this 'wait 30-60 seconds and another step or two will eventually happen' is consistent.

seg fault at quit?

small potatoes, but if i execute quit after this sketch runs, i get a seq fault:

Segmentation fault at address 0x1020cc000
Panicked during a panic. Aborting.
zsh: abort      seamstress scratch.lua
crashed thread ``` Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x180a20764 __pthread_kill + 8 1 libsystem_pthread.dylib 0x180a57c28 pthread_kill + 288 2 libsystem_c.dylib 0x180965ae8 abort + 180 3 seamstress 0x100382cc0 os.abort + 12 (os.zig:601) 4 seamstress 0x100350574 debug.panicImpl + 148 (debug.zig:441) 5 seamstress 0x100327de8 builtin.default_panic + 104 (builtin.zig:813) 6 seamstress 0x1003b0e80 debug.dumpSegfaultInfoPosix + 536 (debug.zig:2422) 7 seamstress 0x100383450 debug.handleSegfaultPosix + 252 (debug.zig:2389) 8 libsystem_platform.dylib 0x180a86a24 _sigtramp + 56 9 seamstress 0x10034f700 clock.deinit + 120 (clock.zig:59) 10 seamstress 0x10034f700 clock.deinit + 120 (clock.zig:59) 11 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 12 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 13 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 14 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 15 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 16 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 17 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 18 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 19 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 20 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 21 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 22 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 23 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 24 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 25 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 26 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 27 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 28 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 29 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 30 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 31 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 32 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 33 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 34 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 35 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 36 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 37 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 38 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 39 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 40 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 41 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 42 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 43 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 44 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 45 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 46 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 47 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 48 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 49 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 50 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 51 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 52 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 53 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 54 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 55 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 56 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 57 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 58 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 59 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 60 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 61 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 62 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 63 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 64 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 65 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 66 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 67 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 68 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 69 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 70 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 71 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 72 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 73 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 74 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 75 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 76 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 77 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 78 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 79 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 80 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 81 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 82 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 83 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 84 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 85 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 86 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 87 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 88 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 89 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 90 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 91 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 92 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 93 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 94 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 95 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 96 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 97 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 98 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 99 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 100 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 101 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 102 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 103 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 104 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 105 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 106 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 107 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 108 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 109 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 110 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 111 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 112 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 113 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 114 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 115 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 116 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 117 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 118 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 119 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 120 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 121 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 122 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 123 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 124 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 125 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 126 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 127 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 128 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 129 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 130 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 131 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 132 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 133 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 134 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 135 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 136 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 137 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 138 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 139 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 140 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 141 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 142 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 143 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 144 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 145 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 146 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 147 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 148 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 149 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 150 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 151 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 152 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 153 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 154 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 155 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 156 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 157 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 158 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 159 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 160 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 161 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 162 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 163 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 164 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 165 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 166 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 167 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 168 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 169 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 170 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 171 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 172 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 173 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 174 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 175 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 176 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 177 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 178 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 179 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 180 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 181 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 182 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 183 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 184 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 185 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 186 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 187 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 188 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 189 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 190 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 191 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 192 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 193 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 194 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 195 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 196 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 197 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 198 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 199 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 200 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 201 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 202 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 203 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 204 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 205 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 206 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 207 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 208 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 209 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 210 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 211 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 212 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 213 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 214 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 215 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 216 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 217 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 218 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 219 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 220 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 221 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 222 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 223 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 224 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 225 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 226 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 227 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 228 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 229 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 230 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 231 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 232 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 233 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 234 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 235 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 236 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 237 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 238 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 239 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 240 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 241 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 242 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 243 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 244 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 245 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 246 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 247 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 248 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 249 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 250 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 251 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 252 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 253 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 254 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 255 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 256 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 257 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 258 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 259 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 260 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 261 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 262 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 263 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 264 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 265 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 266 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 267 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 268 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 269 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 270 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 271 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 272 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 273 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 274 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 275 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 276 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 277 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 278 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 279 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 280 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 281 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 282 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 283 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 284 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 285 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 286 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 287 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 288 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 289 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 290 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 291 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 292 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 293 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 294 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 295 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 296 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 297 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 298 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 299 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 300 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 301 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 302 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 303 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 304 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 305 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 306 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 307 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 308 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 309 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 310 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 311 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 312 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 313 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 314 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 315 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 316 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 317 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 318 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 319 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 320 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 321 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 322 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 323 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 324 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 325 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 326 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 327 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 328 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 329 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 330 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 331 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 332 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 333 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 334 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 335 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 336 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 337 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 338 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 339 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 340 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 341 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 342 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 343 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 344 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 345 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 346 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 347 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 348 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 349 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 350 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 351 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 352 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 353 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 354 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 355 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 356 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 357 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 358 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 359 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 360 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 361 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 362 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 363 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 364 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 365 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 366 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 367 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 368 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 369 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 370 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 371 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 372 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 373 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 374 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 375 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 376 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 377 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 378 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 379 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 380 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 381 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 382 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 383 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 384 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 385 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 386 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 387 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 388 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 389 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 390 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 391 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 392 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 393 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 394 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 395 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 396 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 397 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 398 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 399 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 400 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 401 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 402 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 403 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 404 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 405 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 406 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 407 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 408 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 409 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 410 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 411 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 412 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 413 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 414 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 415 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 416 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 417 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 418 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 419 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 420 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 421 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 422 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 423 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 424 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 425 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 426 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 427 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 428 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 429 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 430 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 431 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 432 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 433 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 434 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 435 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 436 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 437 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 438 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 439 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 440 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 441 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 442 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 443 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 444 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 445 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 446 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 447 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 448 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 449 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 450 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 451 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 452 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 453 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 454 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 455 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 456 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 457 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 458 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 459 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 460 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 461 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 462 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 463 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 464 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 465 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 466 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 467 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 468 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 469 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 470 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 471 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 472 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 473 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 474 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 475 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 476 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 477 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 478 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 479 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 480 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 481 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 482 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 483 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 484 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 485 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 486 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 487 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 488 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 489 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 490 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 491 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 492 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 493 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 494 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 495 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 496 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 497 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 498 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 499 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 500 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 501 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 502 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 503 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 504 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 505 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 506 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 507 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 508 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 509 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) 510 seamstress 0x10034ef48 main.main + 7480 (main.zig:77) ```

shweeee!! thank youuuuuu, please lmk if i can test anything else!

robbielyman commented 1 year ago

hiiiii, thank you very much for this thorough feedback! i think i managed to fix up the major outstanding issues; notably the internal clock should be working, having seamstress hooked up to midi should no longer cause starts and stops to propagate to lua when they oughtn't, etc.

huh, i guess if the midi clock is stopped then seamstress just maths it out as though it is running at the tempo it was previously running at—that's just an accidental side effect of the current design. love it. it doesn't even cause anything more than a potential blip in the displayed tempo when the clock restarts. neato.

I don't really know what to do about midi coming in early with certain settings of latency in Live: since MIDI runs at 24 PPQN, i can only really tune by 1/96ths? the fact that it changes when i change the buffer size in Live leads me to suspect that it might have more to do with how Live handles MIDI than anything else.

I believe I corrected the segfault issue, but i'm not 100% sure. let me know if it pops back up.

Anyway, I'd love to get your eyes and ears on this revision // please let me know if there are more things I should take care of before merging!

dndrks commented 1 year ago

rad rad rad, happy to help however i can!! you're cruising thru everything so impressively, thank you!! sorry for raising new issues, but hopefully these'll be helpful ? :grimacing: ❤️

internal + MIDI clock: double steps

i'm seeing some double-steps with the internal + MIDI clocks (not Link, though!), which i've not seen before. if i run the script and execute start_clock() in the REPL, the whole-beat steps will spin up fine, but eventually there's a double-step, eg:

step    59.000270428996 12 -- fine
step    60.000275741339 13 -- fine
step    61.000268744495 14 -- fine
step    61.99158680683  15 -- early sync, unexpected hit
step    62.000176556839 16 -- expected hit, but is technically a double-step
step    63.000286621495 1 -- should be step 16
step    64.000283997994 2 -- should be step 1

MIDI clock: bottlenecks

all starts well, but if i let the script run while receiving external clock, i run into a weird bottleneck where the seamstress clock process stops for a while, and then picks back and prints a bunch of (what were otherwise missed) steps when it resumes:

step    326.00026992385 7 -- fine
step    327.00033956826 8 -- this is the last step i hear for a while
-- all of a sudden, these print:
step    328.1524936761  9
step    329.11717279802 10
step    330.10820007178 11
step    331.12215861847 12
step    332.10995063415 13
step    333.10845499743 14
step    334.13481299618 15
step    335.11052394333 16
step    336.11650430202 1
step    337.11592005183 2
step    338.10485102715 3
step    339.10463220686 4
step    340.10176894328 5
step    341.10711144081 6
step    342.11687629652 7
step    343.11059396582 8
step    344.11452288424 9
step    345.10559611026 10
step    346.19267783526 11
 -- and we're back to a regular tick!
step    347.00034684346 12
step    348.0003867306  13
step    349.00048527183 14
step    350.00050683949 15

what it looks like on Live's side:

image

this was reproducible pretty consistently with 128 sample latency.

Link: full crash with 128 sample latency

after running a few bars of the example script with Link clocking, I'm getting full-on crashes with 128 sample latency:

> thread 4277119 panic: integer cast truncated bits
<filepath>/seamstress/src/clock.zig:178:39: 0x102ff59bf in loop (seamstress)
            self.beat.beat_duration = @intCast(@as(i128, micros - now) * std.time.ns_per_us);
                                      ^
/opt/homebrew/Cellar/zig/0.11.0/lib/zig/std/Thread.zig:412:13: 0x102fcbc9b in callFn__anon_35753 (seamstress)
            @call(.auto, f, args);
            ^
/opt/homebrew/Cellar/zig/0.11.0/lib/zig/std/Thread.zig:680:34: 0x102f939f3 in entryFn (seamstress)
                    return callFn(f, @as(Args, undefined));
                                 ^
???:?:?: 0x180a57fa7 in ??? (libsystem_pthread.dylib)
???:?:?: 0xef70000180a52d9f in ??? (???)
zsh: abort      seamstress scratch.lua

doesn't seem to happen with 512 sample latency!

Link: fuzzy bpm

i'm seeing that if i run a session at 120bpm (with 512 sample latency), the Link session tempo will automatically change (not just momentary fluctuations beat-to-beat, but just permanent changes for many bars) without my input -- eg. dropping down to 117bpm or speeding up to 123bpm. this reflects both in seamstress's clock menu and in Live. in my most recent run, it took 250 bars to get back to 120bpm, but then around 400 bars the clock jumped up to 134bpm.

robbielyman commented 1 year ago

double steps

i wasn't able to reproduce the double trigger... are you still seeing it consistently?

the crash

i think some instability and certainly the crash was caused by time somehow not being monotonic; i added a pair of guards to avoid this.

the bottlenecks or dropouts

are kind of stumping me; they're even happening when the clock is set to link. maybe it's my impatience, but it often seems like the clock just "dies" and only restarts if i stop and start Live's transport. aha, i added the following to my init()

clock.run(function()
  local last = clock.get_beats()
  while true do
    clock.sleep(1)
    local beat = clock.get_beats()
    if beat < last then
      print("hey, did we just reset to " .. beat .. "???")
    end
    last = beat
  end
end)

and the next time the dropout happened i see that lo and behold, we have somehow gotten hey, did we reset to -1034.522281??? which is pretttttttttttty extreme and also very confusing. i added some code to the Link thread to hopefully gracefully handle this situation. can you add this snippet to your test script and see if you can reproduce the issue you were having with MIDI?

other instability

i noticed that if i have the seamstress windows semi-minimized with macOS stage manager, and then i go and interact with them while the clock is running, i get beat inconsistencies. i think this is because the "yo, let's check for screen events" function is somewhat heavy. probably the correct way to deal with this is to shunt off a lot of the actual application code (including the main event loop) to a separate thread and let the main thread just be in charge of carefully tending to the poor needy lil screen... lol. anyway, that's certainly outside the scope of this PR.

robbielyman commented 1 year ago

fuzzy bpm

oh rightrightright I forgot about this: fundamentally i think the issue is that there's a feedback loop going on where seamstress has a clock that's periodically saying "hey, set the tempo to the current tempo" so if link's tempo fluctuates for some reason, seamstress will then broadcast that fluctuation back through link to live, and the process can repeat... would love your thoughts on how to short-circuit this.

oh jkjk let me just use silent if source == "link" that's easy enough

dndrks commented 1 year ago

ayyyy, rad rad rad, hope you had a good AM :)

thank youuuuuuu!!!!

bottlenecks

fwiw, i'm not seeing these with Link or internal -- only MIDI clocking. ran 1k steps with all three and MIDI gunked up around step 325.

i popped that snippet into my init(), but it only fired off at the start of the script:

started 0.000163916
step    0.000360166 1
running clock: 4
step    1.0002078388763 2
hey, did we just reset to 1.2722905156914???
step    2.0002797185872 3
step    3.000283573243  4

when i experienced the bottleneck, nothing reported:

step    323.00026225344 4
step    324.00023200723 5
-- hiccup //
step    325.09089484215 6
step    326.14295016612 7
step    327.12255481728 8
step    328.12094019934 9
step    329.10857364342 10
step    330.10801993356 11
step    331.11125027686 12
step    332.11120376524 13
step    333.11461794021 14
step    334.09952934663 15
step    335.15794573644 16
step    336.1057131783  1
step    337.12080177188 2
step    338.12440088594 3
step    339.10705094131 4
step    340.11992469547 5
step    341.10146733113 6
step    342.10428239203 7
step    343.09920708749 8
step    344.10289811739 9
step    345.09754595793 10
-- // hiccup
step    346.00022238732 11
step    347.00030195148 12
step    348.00023270855 13
step    349.00023397989 14
step    350.00026268006 15
step    351.00031435078 16
step    352.00028832297 1
step    353.00046158341 2
step    354.00037167337 3
step    355.00029624143 4
robbielyman commented 1 year ago

on a hunch, i recompiled seamstress in release mode (-Doptimize=ReleaseFast) and was suddenly unable to reproduce this issue; i let the MIDI clock run up to 2000+ steps with no hiccups. i'm suspecting although completely unsure of the influence of lua's garbage collection here? i'm gonna go ahead and merge! thank you so so much for your diligent help with this PR.