presetMorpher

EXPERT MODULE, be warned, this one could screw up your patch! Save your patch before use! Also, with next axoloti-update, it might not work anymore! This module is able to get the values from the parameters of other modules (coming after&below this module) and save them as a preset (pressing the "get" parameter/input). Attributes: Set the amount of parameters to be saved using the "parameters" attribute (count all parameters between this module and the last parameter you want to be able to save). Set the amount of available presets using the "presets" attribute Use the "preparams" attribute to skip the first row of parameters, if there's anything in-between. "value" selector..... forget it, not there for you, but somehow I needed it for the "first" parameter where the parameter-count starts.. Params/Saving/Morphing Before you're able to morph, you first need to create a nice preset, select a preset-number and then hit "get". After you've made multiple presets, you're able to smoothly morph between them. Be warned though, morphing to an empty preset can go to extreme random values beyond the limits of the parameters!!!! You can morph through the presets manually, using the on-module parameters or control it externally (eg. over midi-> gate=morph, note=preset, velocity/touch=rate. I used a toggleswitch-controlled "demux" to switch between "get" input and "morph" input)
Author: Remco van der Most
License: BSD
Github: sss/patch/expert/presetMorpher.axo

Inlets

frac32 rate

bool32 morph

bool32 get

int32 preset

Outlets

int32 pre

frac32 rate

Parameters

int32.mini value

bool32.mom morph

bool32.mom get

bool32.mom rnd

int32 preset

frac32.s.map rate

Attributes

spinner parameters

spinner presets

spinner preparams

Declaration
bool get;
static const uint32_t params = attr_parameters;
static const uint32_t presets = attr_presets;
static const uint32_t LENGTH = params * presets;
int32_t *pst;
int i;
int j;
bool A;
bool rnd;
int32_t TP[params];
bool pv;
int P;
int16_t pre;
bool DO;
Init
static int32_t _array[LENGTH] __attribute__((section(".sdram")));
pst = &_array[0];
pre = 0;
DO = 1;
Control Rate
if (DO) {
  while (!(parent->PExch[pre].value == param_value)) {
    pre += 1;
  }

  pre += 6;
  DO = 0;
}

if (param_preset >= presets) {
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_preset],
                     presets - 1, 0xFFFD);
}
P = param_preset + inlet_preset;
P = P - P / presets * presets;
P = (P < 0 ? P + presets : P) * params;
int32_t rate;
MTOF(__SSAT((-1 << 27) + (inlet_rate << 1), 29), rate)
rate = rate >> 2;

A = param_morph || inlet_morph;
bool GET = param_get || inlet_get;

if ((GET > 0) && !get) {
  get = 1;
  for (i = 0; i < params; i++) {
    pst[P + i] = parent->PExch[i + pre].value;
  }
} else if (GET == 0) {
  get = 0;
}

if (A > 0) {
  for (j = 0; j < params; j++) {
    if (!(pst[P + j] == parent->PExch[j + pre].value)) {
      if (!(pv == A)) {
        TP[j] = (pst[P + j]) - (parent->PExch[j + pre].value);
      }
      int32_t Tm = ___SMMUL(TP[j], rate);
      Tm = Tm == 0 ? TP[j] > 0 ? 1 : -1 : Tm;
      int32_t tmp = Tm + parent->PExch[j + pre].value;
      if (TP[j] > 0) {
        tmp = tmp > pst[P + j] ? pst[P + j] : tmp;
      } else {
        tmp = tmp < pst[P + j] ? pst[P + j] : tmp;
      }
      PExParameterChange(
          &parent->PExch[PARAM_INDEX_attr_legal_name_value + j + 6], tmp,
          0xFFFD);
    }
  }
}

if ((param_rnd > 0) && !rnd) {
  rnd = 1;
  for (j = 0; j < params; j++) {
    for (i = 0; i < presets; i++) {
      pst[i * params + j] = (int32_t)GenerateRandomNumber() >> 4;
    }
  }

} else if (param_rnd == 0) {
  rnd = 0;
}
outlet_pre = pre;
pv = A;

Privacy

© 2024 Zrna Research