dynamic global clock source #129
Comments
|
I took a stab at a lua-side clock here (in dust, maybe it should be here instead.) Lua seems to work pretty well for 24ppq, but rebroadcasting external clock to other connected devices might be better done on the native side. |
|
Here's a draft straw-man proposal for a native clock system. This is going to be simultaneously inappropriately maximalist, poorly informed, and a little obvious, but just to push the conversation: UI:
Lua/script layer:
matron/C layer:
SuperCollider layer:
|
|
As an experiment, though, I'm throwing the Link library into the C layer to see if I can work Link into the existing BeatClock system. |
|
pinging this thread regarding link support. A report from a colleague:
|
|
I've started some of the prep work for Link support, but it touches a lot of things that are changing in 2.0, so I've put that work on hold until after 2.0 is finished.
|
|
fwiw, i think it would be better to put Link support in the C components if possible. we're moving further in the direction of making norns ecosystem independent of supercollider; SC becoming one of many options for DSP engine interfacing with the scripting / timing layer. see also PR 712 #712 which makes steps to support lua code execution as coroutines, with worker threads under the hood. |
|
aye, the clock module support for syncing to external events is in progress. link should fit perfectly as long as it's implemented in matron. |
|
I saw this pull request and from some recent experiments with particle synthesis I can see big benefits to an approach that gets clocks off the main lua thread. I’m trying to run some metros in the 100+ calls per second range and it’s interfering with the menu system running smoothly and my ability to update the script via Maiden. (And I don’t think it’s what’s executing in that callback, because CPU is reporting ~17%.) |
|
@NathanKoch while i agree that this is a good idea (servicing clock callbacks from worker thread), i also wonder if this isn't the event queue itself getting bogged down. the CPU reporting on norns is average of all 4 cores, so isn't really granular enough to see if things are stalling in ii am surprised that |
|
I’ll leave my (terribly un-optimized, with a ton of garbage collection from these particles being spawned and killed) code here: https://github.com/nathankoch/NornsMachines/blob/master/grains/simplegrains.lua (It’s basically a lua port of standard Processing/oF style particle systems as found in Daniel Shiffman’s Nature of Code.) What I’ll probably do is dig into this more, do some optimizations and isolate the problem better in fresh code - then create a separate issue. (I don’t see any rogue print statements but I can’t rule out one slipping in. I know for a fact that tons of printing stalls out/overwhelms Good to know also that the CPU is reporting across all cores. |
known (and unfortunate behavior). i could have sworn we had a bug tracking this but can't find it... @ngwese? |
|
I wonder if it would be worth investigating a solution like what Unity 3D’s console does, where multiple identical prints to the console (or multiple identical errors getting thrown) just get an incrementing number tacked next to one line. (But I’m getting way OT from this original issue here) |
|
@artfwo finally took a look at your coroutine clock PR #712. I'm about ready to start working on Ableton Link again. If I keep working on the plan described in #129 (comment), will that be compatible with what you're doing, or does the plan need to change? (Along with the obvious changes for post-2.0 UI.) |
|
@Dewb not exactly, the clock module already provides beat syncing coroutine execution scheduler with arbitrary multiplication and division. Currently it only has one clock source - tempo, MIDI and link are in progress. To push the clock forward you'll need to update the master clock rather frequently using the "app" (thread-safe) link methods. And then call And here's a crude matron clock source for link (not currently pushed because it's a horrible hack, please also feel free to contribute): https://gist.github.com/artfwo/2de822c5b6389d310299d6f29440a458 And here's a test script for the clock API: |
|
Awesome! Looks like you're well on the way, then, I'll try to build your WIP branch + gists. |
|
For building gists, add |
|
Updating last year's straw man proposal to adapt to 2.0 changes and @artfwo's coroutine clock system. UI:
(more to come) |
|
I would be excited about all of that. What can I do to help? (probably in the testing and breaking things dept) |
|
stopping and resetting is currently not possible with the clock module, but is possible to implement in theory - it will require rescheduling sleeper threads when start/stop/reset command is received or there is a significant tempo change, for example. |
|
@Dewb I agree, system wide clock is the future. i am hoping to work on the param menu expansion soon but we can hack in the clock system ahead of that is needed. |
|
(scope creep) perhaps a "transport control" UI widget for start/stop/reset? I could see this being super useful with MIDI and Link when norns is the master clock. |
|
looking at this again as i'm planning to integrate it into my in-process param menu overhaul. i'll start work on a system-wide clock that (yikes) basically is feature-overblown (due to all of the sync possibilities i guess) the param submenu system should make this clean and navigable though. |
|
Clock section in params sounds great. I got a little ways towards prototyping a global clock before putting it on hold when the menu revamp started. Let me know if there’s a section of work that could be broken out that I could help with. I think the biggest remaining issue in adopting the coroutine system for a global clock is having some sort of cancellation system to retrigger waiting coroutines when the master tempo changes. Right now going from a slow tempo to a fast tempo can give you events much later than expected. |
|
I think this is not a really big issue - abrupt tempo changes from 20 to 200 are rare and you still have enough flexibility from the script to keep the situation more or less under control. For example, instead of calling |
|
menu revamp shouldn't block progress on a clock class--- i'm just hoping to get config options for the clock in the menu. all of these should be configurable with class functions as well. @Dewb would be happy to build upon what you've started (and also, i'm looking to finish this menu revamp quite soon) |
|
if anyone has begun work on this, could you make your branch visible? there's interest from several people to work on this, but (my lack of) coordinating is probably confusing everyone. i am more than happy to have someone take the lead on this. |
|
this is effectively in place. minor polish and fixes remain. |
there are a number of musically useful ways that lua callbacks could be synchronized to various clock sources:
internal, using the
metrosystem; these are high-priority threads using nanosleep, should be maximally accurateMIDI clock (24 ppqn)
sample clock; we could get a timestamped bundle from supercollider every N samples; this will have some jitter in the 100s of usecs range, but no drift
ableton link (???)
create a Clock module or something, allowing scripts to conveniently select from these
The text was updated successfully, but these errors were encountered: