hrmOsc2

sort of harmonics-selecting oscillator or something -quant sets the amount of harmonics used in a single phase-cycle -offset gives an offset to all harmonic values, selecting a different set of harmonics in a single cycle -step sets the stepsize for selecting harmonic values -range sets the range for the highest harmonic that may be used
Author: Remco van der Most
License: BSD
Github: sss/osc/hrmOsc2.axo

Inlets

int32 offset

int32 step

frac32 pitch

frac32buffer phase increment

frac32buffer phase

Outlets

frac32buffer.positive phasor wave

Parameters

frac32.s.map.pitch pitch

frac32.s.map fm

int32 quant

int32 offset

int32 step

int32 range

bool32.tgl internal

Declaration
uint32_t Phase;
uint64_t P1;
uint64_t P2;
int32_t S1;
int32_t S2;
Init
Phase = 0;
Control Rate
uint32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq);
int32_t step = param_step + inlet_step;
int32_t offset = param_offset + inlet_offset;
Audio Rate
Phase += (freq >> 0) +
         ___SMMUL(___SMMUL(inlet_freq << 4, param_fm << 4) << 3, freq << 2);
uint32_t phase =
    (param_internal > 0 ? Phase / param_quant : 0) + (inlet_phase << 5);
P1 = phase;
P1 = (P1 / ((1 << 30) / (param_quant))) >> 2;
P2 = ((phase - (P1 << 2) * (1 << 30) / (param_quant)) * param_quant) >> 5;
int p1 = P1;
int p2 = 1 + P1;
p2 = p2 - (p2 / (param_quant)) * (param_quant);
p1 = (p1 + offset) * step;
p2 = (p2 + offset) * step;
p1 = p1 - (p1 / param_range) * param_range;
p2 = p2 - (p2 / param_range) * param_range;
uint32_t p3 = Phase / param_quant;
SINE2TINTERP(Phase *(1 + p1), S1)
SINE2TINTERP(Phase *(1 + p2), S2)
outlet_phasor = ___SMMUL(S1, ((1 << 27) - P2)) + ___SMMUL(S2, P2);

Privacy

© 2024 Zrna Research