i have also calculated the maxOverlap for Dbjorklund2 from f0plugins by redFrik:
EDIT: there now also is a Dsieve extension, you know whats coming next
(
var multiChannelTrigger = { |numChannels, trig|
numChannels.collect{ |chan|
PulseDivider.ar(trig, numChannels, chan);
};
};
var multiChannelPhase = { |triggers, windowRate|
triggers.collect{ |localTrig, i|
var hasTriggered = PulseCount.ar(localTrig) > 0;
var localPhase = Sweep.ar(localTrig, windowRate[i] * hasTriggered);
localPhase * (localPhase < 1);
};
};
{
var numChannels = 5;
var tFreq, reset, trig, triggers, legato, overlap, maxOverlap, windowRates;
var windowPhases, durations, numHits, numSize, offSet, sequencer;
tFreq = \tFreq.kr(100);
reset = Trig1.ar(\reset.tr(0), SampleDur.ir);
// sequencer
numHits = \numHits.kr(3);
numSize = \numSize.kr(8);
offSet = \offSet.kr(0);
sequencer = Dbjorklund2(numHits, numSize, offSet, inf);
// bjorklund durations for triggers and legato sequence
durations = Ddup(2, sequencer);
// create triggers from sequence of durations
trig = TDuty.ar(durations / tFreq, reset);
// distribute triggers round robin across the channels
triggers = multiChannelTrigger.(numChannels, trig);
// trigger legato sequence by multichannel triggers
legato = Demand.ar(triggers, reset, durations);
// multiply overlap by sequence of durations to adjust phase per trigger
overlap = \overlap.kr(2) * legato;
// calculate maximum overlap per trigger
maxOverlap = numChannels.collect{ |chan|
Demand.ar(triggers, reset, Dbjorklund2(numHits, numSize, offSet + chan % numHits, inf));
}.sum;
// add Impulse.ar(0) to prevent division through zero
windowRates = tFreq / (min(overlap, maxOverlap) + Impulse.ar(0));
windowPhases = multiChannelPhase.(triggers, windowRates);
IEnvGen.ar(Env([0, 1, 0.8, 0], [0.25, 0.5, 0.25]), windowPhases);
}.plot(0.5);
)
I thought there could be a universal way of calculating these, but probably there isnt one for all the different attempts. But one thing which came conceptually to my mind is first calculate the maxOverlap, then the legato and triggers from it, maybe this will lead to generalisation.