-
What's the best way to sync multiple Clocks? I have one that starts when I instantiate a class. It's sole purpose is to send out a MIDI Clock message on every quarter note. I'm using it to turn on an LED on the sequencer so the user has a visual representation of the BPM. It looks like this:
I have another clock I'm using for recording MIDI Note On and Note Off messages created by pressing a button on the sequencer. One of the things I want that Clock to do is start a metronome that plays a click on every quarter note. I'm also attempting to quantize played notes to a 1/16th note, although I'm still working out the best way to do that. That clock looks like this:
I need both clocks to be synced. Is that what the arguments to Clock's |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 6 replies
-
That did the trick. |
Beta Was this translation helpful? Give feedback.
-
Awesome. Thanks. I might change things later, but because the Sequencer
module has a few different states, like recording, playback, as well as
performance (which is simply passing along Note On and Note Off messages to
the DualOscillator), I didn't want to cram everything into one clock
callback.
…On Sun, Jan 26, 2025, 6:40 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
I have to admit that I never tried to sync multiple clocks. I typically
just use one and schedule everything on it (since I typically don't care
about tempo just absolute time).
But the initial_* values to start() are intended for the synchronizing
you're trying to do.
—
Reply to this email directly, view it on GitHub
<#421 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNEUKJDBWH3PNAIQIJLL2MUMYHAVCNFSM6AAAAABV4KBDC2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJWGAYTINA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Oh, this would be very useful. I spent a lot of time today trying to figure
out how to start the metronome and let it play for 4 beats/1 measure before
starting the callback I use when recording a played sequence of notes. This
is usually how it works in music. You get 1 measure to set the tempo in
your head before beginning to play. I didn't figure out a good solution,
tho.
So I could schedule a callback that does nothing for 1 measure, and then
starts another callback?
…On Sun, Jan 26, 2025, 7:05 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
FWIW, you can have multiple clock callbacks. And they can also specify if
the next call should be scheduled by seconds or beat. It's not really
documented (sorry, everyone).
https://github.com/supriya-project/supriya/blob/mixers/supriya/clocks/bases.py#L268-L271
Basically, if your callback returns a float, it schedules it as the beat
delta, but if it returns (offset, TimeUnit.SECONDS) you can schedule it
as a seconds delta.
—
Reply to this email directly, view it on GitHub
<#421 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNES5EDIKDDHVPNSJ46D2MUPXHAVCNFSM6AAAAABV4KBDC2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJWGAZTGNQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
So the type of the value returned by the initial callback can decide if a
new callback is used? Not sure I'm totally following.
…On Sun, Jan 26, 2025, 7:56 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
... which means hypothetically you could write a callback that checks if
this is the first time it's been called and does one thing (and returns one
kind of delta) and then does something else (and returns a different kind
of delta) for each subsequent invocation.
—
Reply to this email directly, view it on GitHub
<#421 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNEUNDTXHG47GKEKL4FL2MUVULAVCNFSM6AAAAABV4KBDC2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJWGA3TAOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
It sounds a bit like method overriding in OOP inheritance.
…On Sun, Jan 26, 2025, 8:01 PM yun bao ***@***.***> wrote:
So the type of the value returned by the initial callback can decide if a
new callback is used? Not sure I'm totally following.
On Sun, Jan 26, 2025, 7:56 PM Joséphine Wolf Oberholtzer <
***@***.***> wrote:
> ... which means hypothetically you could write a callback that checks if
> this is the first time it's been called and does one thing (and returns one
> kind of delta) and then does something else (and returns a different kind
> of delta) for each subsequent invocation.
>
> —
> Reply to this email directly, view it on GitHub
> <#421 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ACVNNEUNDTXHG47GKEKL4FL2MUVULAVCNFSM6AAAAABV4KBDC2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJWGA3TAOA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***
> com>
>
|
Beta Was this translation helpful? Give feedback.
-
Oh, I think I see. You're talking about using the same callback, but
changing the wait time between invocations. So for the example I was
talking about, I'd check if `invocations` equaled zero, if so return some
value that caused a 1 measure delay before the callback was called again,
then in subsequent invocations do whatever I needed to do. Right?
…On Sun, Jan 26, 2025, 8:05 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
No, you're misunderstanding. I'm literally talking about putting an
if/else block inside your callback that switches on the
context.event.invocations field to decide what to do.
def my_clock_callback(context, *args, **kwargs):
if context.event.invocations == 0:
do_something()
return 1, TimeUnit.BEATS
else:
do_something_else()
return 0.345, TimeUnit.SECONDS
—
Reply to this email directly, view it on GitHub
<#421 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNEUP3DASAQ7T6WB5E2T2MUWWLAVCNFSM6AAAAABV4KBDC2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJWGA3TMNQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Cool. Thanks!
…On Sun, Jan 26, 2025, 8:17 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
Correct.
—
Reply to this email directly, view it on GitHub
<#421 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNESDGNHRJRAUKEYOBGL2MUYDJAVCNFSM6AAAAABV4KBDC2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJWGA4DGMA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
That did the trick.