allEqtempScales

generic scaling module. Input expects 1v/note, so with 19 notes in an octave, next octave starts at 20. Output is scaled back to 12v/octave to be used with the oscillators with a "pitch" input. "key" sets the key for the scale that's being generated, jumps with "interval" size through the available notes in the octave. This parameter is normalised to the "notes" parameter, so it always fits the total amount of notes per octave. "Notes" sets the total amount of notes per octave (this means without scaling. western temperament = 12 notes) This can go up to even 128 notes per octave! Famous scales are 12, 19, 22, 31, 53. "Use" sets the amount of notes which are active in the scale (western temperament = 7 notes). This parameter is normalised to the "notes" parameter, so it always fits the total amount of notes per octave. "Interval" sets the interval by which the active notes are selected (western temperament = interval 7). This parameter is normalised to the "notes" parameter, so it always fits the total amount of notes per octave.
Author: Remco van der Most
License: BSD
Github: sss/harmony/allEqtempScales.axo

Inlets

frac32 pitch

Outlets

int32 notes

frac32 note

Parameters

frac32.s.map key

int32 notes

frac32.u.map use

frac32.u.map interval

Displays

int32.label use

int32.label interval

int32.label key

Declaration
int array[64];
int i;
int j;
int32_t temp[64];
int32_t tamp[64];
int8_t count;
int32_t postnotes;
int32_t postuse;
int32_t postinterval;
int32_t use;
int32_t interval;
int32_t key;
Control Rate
use = ___SMMUL(param_use << 3, param_notes << 2);
interval = ___SMMUL(param_interval << 3, param_notes << 2);
key = ___SMMUL(param_key << 3, param_notes << 2) * interval;
key = (key) - (((key) / param_notes) * param_notes);
key = key >= 0 ? key : param_notes + key - 1;
disp_use = use;
disp_interval = interval;
disp_key = key;
int32_t render;
render = param_use == postuse ? 0 : 1;
render += param_interval == postinterval ? 0 : 1;
render += param_notes == postnotes ? 0 : 1;

int32_t pitch;
pitch = (inlet_pitch >> 21) + key;
int32_t patch;
patch = pitch / param_notes;
pitch = pitch - (patch * param_notes);
pitch = pitch >= 0 ? pitch : param_notes - 1 + pitch;

if (render > 0) {
  for (i = 0; i < (use); i++) {
    array[i] = (i * interval) - (((i * interval) / param_notes) * param_notes);
  }
}

if (!(render > 0)) {
  for (j = 0; j < (use - 1); j++) {
    if (array[j] > array[j + 1]) {
      temp[j] = array[j + 1];
      tamp[j] = array[j];
      array[j + 1] = tamp[j];
      array[j] = temp[j];
    }
  }
}

outlet_note = (((array[pitch * use / param_notes] << 21) * 12) / param_notes) +
              ((12 * patch) << 21) - ((key << 21) * 12 / param_notes);

postnotes = param_notes;
postuse = param_use;
postinterval = param_interval;
outlet_notes = param_notes;

Privacy

© 2024 Zrna Research