what im trying to figure out is a way to add another non-linearity (tanh, clip etc.), here its scaled by the combOffset
and linearly mixed via the combShape
param. When combShape = 1
, you get a nice intermediate pausing / cadence effect because all phases are set to 0 momentarily, if combOffset
is bigger then the scaled ratios. But im still searching for an implementation which has the same effect but applied after the wrapping to work with normalized phases. I will keep you in the loop PS. you should multiply your
combOffset
by combDensity.sign
, so combOffset
has no effect when combDensity
is 0 (no combs)).
var addCombFilter = { |chain, combOffset, combDensity, combWarp, combShape, combPeak|
var ratios = chain[\freqs] / chain[\freq];
var normalizedRatios = (ratios / ratios[chain[\numPartials] - 1]).clip(0, 1);
var warpedRatios = log2ToLinearMorph.(normalizedRatios, combWarp);
var scaledRatios = warpedRatios * ratios[chain[\numPartials] - 1];
var offsetRatios = scaledRatios * (0.5 * combDensity) + (combOffset * combDensity.sign);
var shapedRatios = offsetRatios * (1 - combShape) + (offsetRatios.tanh * combShape);
var phases = shapedRatios.wrap(0, 1);
chain[\amps] = chain[\amps] * raisedCos.(phases, combPeak);
chain;
};
The way i have set this up always gives me future dancehall vibes haha
i have additionally tried to come up with different warping functions (before we had quintic easing), here is a pseudo log2 easing function with linear blend, which sounds pretty sharp.
var pseudoLog2In = { |x, coef = 10|
1 - (log2((1 - x) * (2 ** coef - 1) + 1) / coef);
};
var pseudoLog2Out = { |x|
1 - pseudoLog2In.(1 - x);
};
var log2OutToLinear = { |x, shape|
var mix = shape * 2;
var easeOut = pseudoLog2Out.(x);
easeOut * (1 - mix) + (x * mix);
};
var linearToLog2In = { |x, shape|
var mix = (shape - 0.5) * 2;
var easeIn = pseudoLog2In.(x);
x * (1 - mix) + (easeIn * mix);
};
var log2ToLinearMorph = { |x, shape|
Select.kr(shape > 0.5, [
log2OutToLinear.(x, shape),
linearToLog2In.(x, shape)
]);
};