tri_2_b

Dual phase triangle LFO, bipolar, 0 and 120 degrees, bipolar, pitch input, phase reset
Author: Are Leistad
License: BSD
Github: drj/lfo/dual_triangle.axo

IO Variants: 4


Variant: 1

Inlets

frac32.bipolar pitch

bool32.rising reset phase

Outlets

frac32.bipolar 0 deg triangle wave

frac32.bipolar 120 deg triangle wave

Parameters

frac32.s.map.lfopitch pitch

Declaration
uint32_t phase;
uint32_t old_reset;
__attribute__((always_inline)) __STATIC_INLINE int32_t ___ABS(int32_t op1) {
  int32_t result;
  __ASM volatile("movs  %0, %1\n"
                 "it    mi\n"
                 "rsbmi %0, %0, #0"
                 : "=r"(result)
                 : "r"(op1));
  return (result);
};
Init
phase = 0;
old_reset = 0;
Control Rate
if (inlet_reset && !old_reset) {
  phase = 0;
} else {
  int32_t freq;
  MTOFEXTENDED(param_pitch + inlet_pitch, freq);
  phase += freq >> 2;
}
old_reset = inlet_reset;

int32_t saw;

saw = (phase >> 4) - (1 << 27);
outlet_0 = (1 << 27) - ___ABS(saw << 1);

saw = ((phase - 0x55555555) >> 4) - (1 << 27);
outlet_120 = (1 << 27) - ___ABS(saw << 1);

Variant: 2

Inlets

frac32.bipolar pitch

bool32.rising reset phase

Outlets

frac32.positive 0 deg triangle wave

frac32.positive 120 deg triangle wave

Parameters

frac32.s.map.lfopitch pitch

Declaration
uint32_t phase;
uint32_t old_reset;
__attribute__((always_inline)) __STATIC_INLINE int32_t ___ABS(int32_t op1) {
  int32_t result;
  __ASM volatile("movs  %0, %1\n"
                 "it    mi\n"
                 "rsbmi %0, %0, #0"
                 : "=r"(result)
                 : "r"(op1));
  return (result);
};
Init
phase = 0;
old_reset = 0;
Control Rate
if (inlet_reset && !old_reset) {
  phase = 0;
} else {
  int32_t freq;
  MTOFEXTENDED(param_pitch + inlet_pitch, freq);
  phase += freq >> 2;
}
old_reset = inlet_reset;

int32_t saw;

saw = (phase >> 4) - (1 << 27);
outlet_0 = (1 << 27) - ___ABS(saw);

saw = ((phase - 0x55555555) >> 4) - (1 << 27);
outlet_120 = (1 << 27) - ___ABS(saw);

Variant: 3

Inlets

frac32.bipolar pitch

bool32.rising reset phase

Outlets

frac32.positive 0 deg triangle wave

frac32.positive 90 deg triangle wave

Parameters

frac32.s.map.lfopitch pitch

Declaration
uint32_t phase;
uint32_t old_reset;
__attribute__((always_inline)) __STATIC_INLINE int32_t ___ABS(int32_t op1) {
  int32_t result;
  __ASM volatile("movs  %0, %1\n"
                 "it    mi\n"
                 "rsbmi %0, %0, #0"
                 : "=r"(result)
                 : "r"(op1));
  return (result);
};
Init
phase = 0;
old_reset = 0;
Control Rate
if (inlet_reset && !old_reset) {
  phase = 0;
} else {
  int32_t freq;
  MTOFEXTENDED(param_pitch + inlet_pitch, freq);
  phase += freq >> 2;
}
old_reset = inlet_reset;

int32_t saw;

saw = (phase >> 4) - (1 << 27);
outlet_0 = (1 << 27) - ___ABS(saw);

saw = ((phase - 0x40000000) >> 4) - (1 << 27);
outlet_90 = (1 << 27) - ___ABS(saw);

Variant: 4

Inlets

frac32.bipolar pitch

bool32.rising reset phase

Outlets

frac32.bipolar 0 deg triangle wave

frac32.bipolar 90 deg triangle wave

Parameters

frac32.s.map.lfopitch pitch

Declaration
uint32_t phase;
uint32_t old_reset;
__attribute__((always_inline)) __STATIC_INLINE int32_t ___ABS(int32_t op1) {
  int32_t result;
  __ASM volatile("movs  %0, %1\n"
                 "it    mi\n"
                 "rsbmi %0, %0, #0"
                 : "=r"(result)
                 : "r"(op1));
  return (result);
};
Init
phase = 0;
old_reset = 0;
Control Rate
if (inlet_reset && !old_reset) {
  phase = 0;
} else {
  int32_t freq;
  MTOFEXTENDED(param_pitch + inlet_pitch, freq);
  phase += freq >> 2;
}
old_reset = inlet_reset;

int32_t saw;

saw = (phase >> 4) - (1 << 27);
outlet_0 = (1 << 27) - ___ABS(saw << 1);

saw = ((phase - 0x40000000) >> 4) - (1 << 27);
outlet_90 = (1 << 27) - ___ABS(saw << 1);

Privacy

© 2024 Zrna Research