hey, i have worked on some abstractions from the gen~ book. One is this ramp2trig abstraction. Would you think my approach lines up with the gen~ patch?
(
var rampToTrig = { |phase|
var difference = HPZ1.ar(phase);
var sum = LPZ1.ar(phase);
var trig = (difference / sum).abs > 0.5;
Trig1.ar(trig, SampleDur.ir);
};
{
var plotScale = 400;
var bpm = 120 * plotScale;
var clockRate = bpm / 60;
var beatsPerMeasure = 4;
var measurePhaseRate = clockRate / beatsPerMeasure;
var stepsPerMeasure = 8;
//var phase = (Phasor.ar(0, measurePhaseRate * SampleDur.ir) - SampleDur.ir).wrap(0, 1);
var phase = LFSaw.ar(measurePhaseRate, 1).linlin(-1, 1, 0, 1);
var trigA = rampToTrig.((phase * stepsPerMeasure).wrap(0, 1));
var trigB = Changed.ar((phase * stepsPerMeasure).ceil);
[phase, trigA, trigB];
}.plot(0.01);
)
I have also compared it to a Changed / ceil approach, they look the same on the plot. But when being played the wrapping of the phase when using rampToTrig
seems to drift away from the master Phasor and the Changed / ceil
approach more precise. Does this make any sense? But probably I have spent too much time with this and cant hear it anymore…
Problem with the Changed / ceil approach is, you cant get triggers from a ramp when you dont multiply the phase by some ramp division. I thought of one universal ramp to trig function.
Changed
with rhythm:
Changed
with regular pulse:
Changed
with bpm synced ratchets:
rampToTrig with rhythm:
ramptToTrig with regular pulse:
rampToTrig with bpm synced ratchets:
And one additional question: is there a way to start a Phasor
exactly at the same phase like LFSaw.ar(freq, 1).linlin(-1, 1, 0, 1)
, otherwise you dont get the initial trigger at the start, and dont want to add Impulse.ar(0);