rndSines

sine oscillator with randomisation of pitch and volume. for both modes, the pitch and volume are randomised at phase-restart, but: Mode1: values are only updated if a random value is higher then the update-control and phase restarts. Mode2: values are always updated at each phase restart, but the update-control sets the maximum change from the former random value, creating a more or less continuous random drift.
Author: Remco van der most
License: BSD
Github: sss/osc/rndSines.axo

Inlets

frac32 rate

Outlets

frac32buffer.bipolar white noise

Parameters

int32.hradio mode

frac32.s.map.pitch rate

frac32.u.map Rmod

frac32.u.map volume

frac32.u.map Vmod

frac32.u.map update

Declaration
uint32_t count;
int32_t rnd;
int32_t Rnd;
int32_t prev;
int64_t rate;
int32_t Rate;
int32_t val1a;
int32_t val2a;
int32_t val1b;
int32_t val2b;
Init
rnd = (int32_t)(GenerateRandomNumber());
Audio Rate
count += Rate;
if (param_mode == 0) {
  if (count < prev) {
    int32_t RND = (uint32_t)(GenerateRandomNumber()) >> 5;
    if (param_update > RND) {
      rnd = (int32_t)(GenerateRandomNumber()) >> 5;
      Rnd = (int32_t)(GenerateRandomNumber()) >> 5;
    }
  }
}

if (param_mode == 1) {
  if (count < prev) {
    rnd = __SSAT(
        rnd + (___SMMUL(param_update, (int32_t)(GenerateRandomNumber()))), 28);
    Rnd = __SSAT(
        Rnd + (___SMMUL(param_update, (int32_t)(GenerateRandomNumber()))), 28);
  }
}

MTOFEXTENDED(
    __SSAT(param_rate + inlet_rate + ___SMMUL(param_Rmod << 3, rnd << 2), 28),
    rate)
Rate = rate >> 1;
int32_t sine;
SINE2TINTERP(count, sine)
outlet_out = ___SMMUL(sine, param_volume + ___SMMUL(param_Vmod << 3, Rnd << 2));
prev = count;

Privacy

© 2024 Zrna Research