waveformGuitar

this module is used to create a waveform-table for the guitarOscillator. it saves it generated waveforms into the table of the "waveformGenerator" Amount of waveforms created depends on the setting on the "waveformGenerator". Use "waveformTableCombinor" to combine tables. randomised settings: -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/waveformGuitar.axo

Inlets

None

Outlets

None

Parameters

bool32.mom do

int32 minHarm

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;

int32_t preset;
Init
DO = 1;
preset = 32;
Control Rate
preset += 1;
preset = preset > 32 ? 32 : preset;
if ((param_do > 0) && !create) {
  preset = 0;
  create = 1;
} else if (param_do == 0) {
  create = 0;
}

if (preset < (32)) {
  int32_t max = (((uint32_t)(GenerateRandomNumber())) & 63) + param_minHarm;
  int32_t harmonics =
      (((uint32_t)(GenerateRandomNumber())) & 31) + param_minHarm;
  int32_t minDiv = 1;
  int32_t damp = (((uint32_t)(GenerateRandomNumber())) & 1) + 1;

  Pos = (((uint32_t)(GenerateRandomNumber())) >> 6) + (16 << 21);
  start = (((uint32_t)(GenerateRandomNumber())) >> 6) + (16 << 21);
  for (i = 0; i < attr_table.LENGTH; i++) {
    attr_table.array[i + preset * attr_table.LENGTH] = 0;
  }
  for (j = 0; j < harmonics; j++) {
    int32_t jump = (((uint32_t)(GenerateRandomNumber())) & 63) + 1;
    k = (j * jump - (j * jump / max) * max);
    position = ((j + 1) * Pos << 4);
    SINE2TINTERP(position, posWidth)
    for (i = 0; i < attr_table.LENGTH; i++) {
      SINE2TINTERP((i << 32 - attr_table.LENGTHPOW) / minDiv * (k + minDiv) -
                       (start << 3) * (k + minDiv),
                   r)
      attr_table.array[i + preset * attr_table.LENGTH] +=
          ___SMMUL(r >> 3, posWidth >> 3) / (1 + k * damp);
    }
  }
}
if (preset == (31)) {
  attr_table.Do = 1;
}

Privacy

© 2024 Zrna Research