hey, i have made an attempt to translate the ramp2slope abstraction from the gen~ book to SC:
(
var rampToSlope = { |phase|
//var delta = HPZ1.ar(phase) * 2;
var delta = Slope.ar(phase) * SampleDur.ir;
delta.wrap(-0.5, 0.5) * SampleRate.ir;
};
var rampDiv = { |phase, scale|
var slope = rampToSlope.(phase);
Phasor.ar(DC.ar(0), slope / scale * SampleDur.ir);
};
{
var plotScale = 400;
var bpm = 120 * plotScale;
var clockRate = bpm / 60;
var beatsPerMeasure = 4;
var measurePhaseRate = clockRate / beatsPerMeasure;
var measureScale = 2;
//var barPhase = (Phasor.ar(DC.ar(0), measurePhaseRate * SampleDur.ir) - SampleDur.ir).wrap(0, 1);
var barPhase = LFSaw.ar(measurePhaseRate, 1).linlin(-1, 1, 0, 1);
var divPhase = rampDiv.(barPhase, measureScale);
[barPhase, divPhase];
}.plot(0.021);
)
Not sure if i should use Slope
or HPZ1
here, they seem to have the same result when beeing scaled.
The slope of my attempt is a bit unstable even when the main Phasor is not modulated, would you think this is the same with the gen~ approach or something binded to Slope / HPZ1 ?
when the target slope for example is 8.0, i get:
UGen(BinaryOpUGen): 7.99084
UGen(BinaryOpUGen): 7.99609
UGen(BinaryOpUGen): 8.01187
UGen(BinaryOpUGen): 8.01187
UGen(BinaryOpUGen): 8.01187
UGen(BinaryOpUGen): 8.00135
UGen(BinaryOpUGen): 7.99084
UGen(BinaryOpUGen): 8.01187
UGen(BinaryOpUGen): 7.96981
UGen(BinaryOpUGen): 7.96981
UGen(BinaryOpUGen): 7.99084
UGen(BinaryOpUGen): 8.03289
UGen(BinaryOpUGen): 7.99084
UGen(BinaryOpUGen): 8.03289
UGen(BinaryOpUGen): 7.99084
UGen(BinaryOpUGen): 7.99609
UGen(BinaryOpUGen): 7.99609
UGen(BinaryOpUGen): 8.01187
Maybe you could scale the rate, get the slope and divide by the scaling factor to be more precise.
The rampDiv abstraction would probably be more precise with a feedback accumulator i guess.