combinator

Combine two signals (after bitshifting them) with bitwise operations (and, or, xor) plus final bitshifting
Author: Sputnki
License: BSD
Github: sptnk/math/combinator.axo

Inlets

frac32 i1

frac32 i2

Outlets

frac32 o

Parameters

int32 positive - leftshift / neegative - rightshift

int32 positive - leftshift / neegative - rightshift

int32 positive - leftshift / neegative - rightshift

int32.hradio and/or/xor

Declaration
int32_t s1;
int32_t s2;
int32_t val;
Init
s1 = 0;
s2 = 0;
val = 0;
Control Rate
if (param_shift1 > 0)
  s1 = inlet_i1 << param_shift1;
else if (param_shift1 < 0)
  s1 = inlet_i1 >> -param_shift1;
else
  s1 = inlet_i1;

if (param_shift2 > 0)
  s2 = inlet_i2 << param_shift2;
else if (param_shift2 < 0)
  s2 = inlet_i2 >> -param_shift2;
else
  s2 = inlet_i2;

switch (param_operation) {
case 0:
  val = s1 & s2;
  break;
case 1:
  val = s1 | s2;
  break;
case 2:
  val = s1 ^ s2;
  break;
}

if (param_shift3 > 0)
  outlet_o = val << param_shift3;
else if (param_shift3 < 0)
  outlet_o = val >> -param_shift3;
else
  outlet_o = val;

Privacy

© 2024 Zrna Research