pitch-randomizer

Randomizes the incoming pitch...
Author: Jan Vantomme
License: BSD
Github: jv/conv/pitch randomizer.axo

Inlets

frac32.bipolar input

bool32.rising trigger

Outlets

frac32.bipolar output

Parameters

int32 chance

int32.hradio mode

Declaration
int32_t val;
int ntrig;
Control Rate
// 25165824 = 12 semitones

if ((inlet_trigger > 0) && !ntrig) {

  if (param_mode == 0) {

    // Randomizer is off
    val = inlet_in;

  } else {

    // random number between 0 and 100
    uint8_t rand_chance = rand() % 101;

    if (rand_chance < param_chance) {

      if (param_mode == 1) {

        // Randomizer UP
        val = inlet_in + 25165824;

      } else if (param_mode == 2) {

        // Randomizer DOWN
        val = inlet_in - 25165824;

      } else if (param_mode == 3) {

        // Randomizer UP + DOWN
        uint8_t rand_updown = rand() % 101;

        if (rand_updown < 50) {

          // Randomizer UP
          val = inlet_in + 25165824;

        } else {

          // Randomizer DOWN
          val = inlet_in - 25165824;
        }
      }

    } else {

      // Not randomized
      val = inlet_in;
    }
  }

  ntrig = 1;

} else if (!(inlet_trigger > 0)) {

  ntrig = 0;
}

outlet_out = val;

Privacy

© 2024 Zrna Research