It’s funny you should mention this because the pulse is based on your example in a different thread: Pulse width modulation using only sines - #2 by fmiramar.
Here’s a slightly simplified version of what I have. It’s two oscillators out of phase with each other, with the “secondary” osc having controls for phase shifting and frequency offset relative to the primary.
The waveshaping is pretty simple in mine, and Normalize
is working quite nicely, with seemingly the same computational overhead as the other value scaling I was messing with before.
(
a = {
var spin = \spin.kr, phase = \phase.kr.mod(2pi), width = \width.kr(0.5).clip(0.0001, 0.9999),
shape = \shape.kr, amp = \amp.kr(0.2);
// freq & FM inputs
var freq = \freq.kr(200) + (\fm.ar([0, 0]) * \fmDepth.kr(1));
var sig = [
(
(SinOsc.ar(freq).asin * 0.5pi.reciprocal + width.linlin(0, 1, -1, 1))
> 0 // comparator for square converter
).madd(2, -1), // normalize
(
(SinOsc.ar(freq + spin, phase).asin * 0.5pi.reciprocal + width.linlin(0, 1, 1, -1)) // width scaling reversed due to neg
> 0
).madd(2, -1).neg // normalize & invert channel
].flat;
// for smoothing wave edge: 0.0 - 1
sig = Lag2.ar(sig, shape.lincurve(0, 1, 0, 0.015, 2));
sig = Normalizer.ar(sig, 1.0, 0.001);
// sig = sig * shape.lincurve(0, 1, 1, 7, 5.5); // old make-up gain
sig = sig * amp;
// main signal for stereo FM is osc1 L (FM L chan) + osc2 R (FM R chan)
// outsMapping: osc1 L + osc2 R, osc1 R + osc2 L, osc1 L + osc2 L, osc1 R + osc2 R
[sig[0], sig[3]]
}.play
)
Only issue with the oscillator as is at the moment I think is that it aliases in sort of a strange way when it’s fully squared and the frequency is set to, for example 204.2Hz. I don’t necessarily mind that though, and this’ll mostly be used as an LFO.
Though the shape itself is less important, and I like the siney-tri-ey-sawy thing happening in my example, but I’ll see if I can implement your “morphing” example from above here though, cause yeah, somewhere in there I’ve already got sine waves!
I’ll look into this too. In this case it might work nicely as well, because it’s also 4 or 5 different gain levels that I need, so the array can be real simple.
And I have played with Ease a little bit, but not enough yet to fully remember it while I dig deep into stuff. So also maybe it’d be a way to create the makeup gain curve as well, rather than Normalize.