phsclk is an algorithm that takes in a phasor signal, and returns a clock signal with an arbitrary number of ticks that are equally spaced.

This little utility can be used to construct polyrhythmic clock signals that are resistant to accumulative clock drift over time.

Here is the woven page:

pbat.ch/sndkit/phsclk/

source code can be found here:

git.sr.ht/~pbatch/sndkit/tree/

A patchwerk wrapper and runt word for it has been implemented in , with a simple example written in Runt code:

git.sr.ht/~pbatch/monolith/tre

A trivial example in runt code that demonstrates how phsclk can be used, with sample audio.

Here, three different clocks are used to trigger three differently pitched blips. The clocks are all controlled by a single phasor signal. The phasor signal itself is used to control the frequency of a sine wave oscillator.

Two of the blips form a 4:5 polyrhythm. The last blip divides things into 6, but the phasor is fed through an exponential mapper before being processed by phsclk. The result is a set of 6 blips that slow down every time the phasor resets.

patchwerk nodes

1 3 / 0 phasor bhold 0 cabset
8192 ftnew gen_sine 1 regset

0 cabget
330 440 scale
0.3
0 1 regget osc

0 cabget 4 phsclk
0.001 0.01 0.01 tenvx
1000 0.3 0 1 regget osc mul

0 cabget 5 phsclk
0.001 0.01 0.01 tenvx
2000 0.3 0 1 regget osc mul

0 cabget -6 expmap 6 phsclk
0.001 0.01 0.01 tenvx
800 0.3 0 1 regget osc mul

0.8 mul

0 cabget bunhold

"test.wav" wavout bdrop

sr 10 * _compute rep

Phasors, I've recently come to realize, provide a means of timing that is very similar to how a human conductor would deliver it. Sure, a conductor is going to gesticulate the beats, but what they are really doing is creating a continuously moving circle of time for performers to follow. The individual performers, simultaneously being aware to every other performer, can then take in this signal and calculate musical events that synchronize well enough with the other performers ("good enough for humans").

· · brutaldon · · ·

In fact, early choral music and plainsong *was* conducted in a circle. So in a way, I'm sort of regressing a few centuries here.

The computer music twist, as I alluded to in the demo, happens when you begin to process phasor signals before converting them into clock signals. This opens up a whole interesting area of weird groove mapping with audio-rate precision.

The reverse operation of converting clocks to phasor signals is also interesting to me. This problem is a bit more complicated, and comes with many caveats.

The ideal implementation would allow phasors to be converted to ticks, to be converted back to phasors again, with the relative phase being preserved.

Without knowing the initial tempo of the incoming clock, some sort of delay would have to be introduced. To keep things in phase, even more delay would have to be added. Not a total dealbreaker, just a complication to consider.

Welcome to post.lurk.org, an instance for discussions around cultural freedom, experimental, new media art, net and computational culture, and things like that.