guitarTable

this module is used to create a monophonic table for the guitarOscillator, so it can be used in a polyphonic setting (each oscillator reads from the same table, so the table itself doesn't have to be polyphonic). This was needed as otherwise each voice would create it's own table, filling up the available memory really quickly! "fixed" controls, even though you could change them live, this will create a harsh bleep as it has to recalculate the waveform. -damp: dampening-factor for each next added harmonic corresponding to harmonic number. -harmonics: how many harmonics will be generated for the wavetable (low numbers reduce recalculation time!) -jump: "jump" size for next added harmonic, skipping harmonics in-between -max: sets maximum harmonic number that can be added, wraps when above the max. -position: sets the read-out position of the guitar-element -strike: sets the position where the string is struck
Author: Remco van der Most
License: BSD
Github: sss/osc/guitarTable.axo

Inlets

None

Outlets

None

Parameters

frac32.u.map position

frac32.u.map strike

bool32.mom do

int32 damp

int32 minDiv

int32 harmonics

int32 jump

int32 max

int32 preset

Attributes

objref table

Declaration
uint32_t phase;
int i;
int j;
int32_t sum;
int32_t r;
int32_t posWidth;
int32_t position;
int32_t prev;
int ctrig;
int create;
int32_t Pos;
int k;
int32_t start;
float32_t A;
float32_t B;
uint32_t PM;
int DO;
Init
DO = 1;
Control Rate
if ((param_do > 0) || DO > 0) {
  DO = 0;
  int32_t preset = param_preset;
  preset = preset - (preset / attr_table.Waveforms) * attr_table.Waveforms;
  int32_t update = param_position + param_strike + param_damp +
                   param_harmonics + param_jump + param_max + param_minDiv;

  if ((!(prev == (update))) && !create) {
    create = 1;
    attr_table.Do = 1;
    Pos = param_position;
    start = param_strike;
    for (i = 0; i < attr_table.LENGTH; i++) {
      attr_table.array[i + param_preset * attr_table.LENGTH] = 0;
    }
    for (j = 0; j < param_harmonics; j++) {
      k = (j * param_jump - (j * param_jump / param_max) * param_max);
      position = ((j + 1) * Pos << 4);
      SINE2TINTERP(position, posWidth)
      for (i = 0; i < attr_table.LENGTH; i++) {
        SINE2TINTERP((i << 32 - attr_table.LENGTHPOW) / param_minDiv *
                             (k + param_minDiv) -
                         (start << 3) * (k + param_minDiv),
                     r)
        attr_table.array[i + preset * attr_table.LENGTH] +=
            ___SMMUL(r >> 3, posWidth >> 3) / (1 + k * param_damp);
      }
    }
  } else if (prev == (update)) {
    create = 0;
  }

  prev = update;
} else if (param_do == 0) {
  attr_table.Do = 0;
}

Privacy

© 2024 Zrna Research