Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clock: crow + MIDI external clock sources double-trigger clock.sync(1) #1273

Open
dndrks opened this issue Dec 18, 2020 · 7 comments
Open

clock: crow + MIDI external clock sources double-trigger clock.sync(1) #1273

dndrks opened this issue Dec 18, 2020 · 7 comments
Labels
bug

Comments

@dndrks
Copy link
Contributor

@dndrks dndrks commented Dec 18, 2020

test script

setup:

  • connect to maiden
  • attach a MIDI or crow clock source to norns
  • nav to EDIT > CLOCK and choose midi or crow
    • MIDI tests: OP-Z, UM-ONE, MOTU UltraLite mk4
    • crow tests: Teletype with steady 500ms pulse + crow in div set to 1
  • ensure the tempo displayed matches the expected tempo
  • run the script

script details:

  • script starts by truncating the current clock beat number and assigning it to a variable count
  • a coroutine is established
  • the coroutine uses clock.sync(1) to sync to each beat
  • each beat increments the count variable by 1
  • each beat prints the current beat number
  • in theory, these two values should remain the same (understanding that the printed clock beat might be +0.00x ahead)

expected results: in the repl, the integer of the left value (clock beat) matches the right value (count)

control: running script with internal clock or Link clock provides expected results (for at least 500 beats)

actual results: clock steps are somehow double-tapping, which double-increments the count value

1181.0002472464	1181
1182.000157767	1182
1183.0018666615	1183
1183.9966417216	1184
1184.0018485279	1185
1185.0002404991	1186
1186.0002296293	1187
1187.0005070127	1188
1188.0003569899	1189
1189.000229808	1190
1190.0024096313	1191
1190.9967660519	1192
1191.0018336364	1193
1192.0001773595	1194
1193.0008779371	1195
1194.0000049084	1196
1195.0005623592	1197
1196.0002397995	1198

impact:

  • if a script uses a coroutine to advance a counter to determine a 16-beat bar, then the counter would hit 16 beats at the 14th beat
  • if a script is just simply re-triggering a synth voice on a steady pulse, the voice is re-triggered and sounds accented
@dndrks dndrks added the bug label Dec 19, 2020
@schollz
Copy link
Contributor

@schollz schollz commented Jan 21, 2021

@artfwo has this bug been fixed with the most recent update? i was writing a midi-sync script and i'm finding that the norns clock is still going a little bit fast when it is being set using external midi devices (i tried both a sh-01a and a op-1 and both had issues syncing with norns when norns clock was set to midi, but not when norns was internal).

@artfwo
Copy link
Member

@artfwo artfwo commented Jan 21, 2021

If it's still reproducible - then no, it's not fixed unfortunately. Can you share the script that you're running with the OP-1?

@schollz
Copy link
Contributor

@schollz schollz commented Jan 21, 2021

here's the script i used:

-- aaaa.lua

lattice = require("lattice")
my_lattice = nil 

function init()
    print("init")
    my_lattice = lattice:new{
        ppqn=96
    }

    m = midi.connect(1)
    pattern_c = my_lattice:new_pattern{
        action = function(t) 
            print("quarter notes", t) 
            m:note_off(72)
            m:note_on(72,127)
        end,
        division = 1/4
    }
    my_lattice:start()
end

essentially i have the device (op-1 or sh-01a) use its own internal sequencer to emit a note at 60bpm. then i set the norns clock to midi and have it tell the device to play another note at 60bpm. the device should then have two notes playing, simultaneously.

i then record the output. when the norns clock is set to internal (and manually pressing play to get it in sync initially) there is no problem (waveform of both notes playing simultaneously):

image

but when i have the norns set to midi, being driven off the op-1, it quickly gets off. the midi note coming from the norns (being synced by the op-1) seems to be on a faster beat:

image

a close-up view, farther out:

image

then i tried with the sh-01a, and again with norns set to internal there is no problem staying in sync. but when i set norns to midi the norns midi note emission drifts back and forth:

image

@ngwese
Copy link
Member

@ngwese ngwese commented Jan 21, 2021

thinking out loud, i’m wondering if this behavior is the result of normal thread scheduling jitter in the device thread which is reading from alsa. i haven’t looked but if alsa could provide time stamps on incoming midi messages that might help

@papernoise
Copy link

@papernoise papernoise commented Feb 6, 2021

Any news on this one? I'm working with @schollz on a new script and I'm seeing huge jitter, not like a few ms, but basically 1/4 notes shifts back and forth. I can do some more testing if that is useful.
My set up is nonrns shield getting MIDI through a Faderfox UC4, the midi clock comes from an Octatrack.
Unfortunately my coding skills are really bad, so I can't really go much deeper than this.

@artfwo
Copy link
Member

@artfwo artfwo commented Feb 6, 2021

@papernoise does this also happen with the internal metronome?

@papernoise
Copy link

@papernoise papernoise commented Feb 6, 2021

I've just retested things and this was my set-up:
clock master Microfreak > goes into norns via the UC4 > goes out to a Volca keys.
If norns is the master, i.e. clock is internal, then the loop and the volca stay nicely in sync (I've let it run for a bit and it seems stable). If I use external MIDI clock everything is out of sync.
So no, it doesn't seem to happen with the internal one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants