sampleController

description
Author: Remco van der Most
License: BSD
Github: sss/table/sampleController.axo

Inlets

int32 preset

Outlets

int32 startsample

int32 loopsample

int32 loopmode

int32 endsample

int32 samplelength

frac32 startpitch

frac32 startStrt

frac32 startEnd

frac32 looppitch

frac32 loopStrt

frac32 loopEnd

frac32 endpitch

frac32 endStrt

frac32 endEnd

frac32 FMwidth

bool32 LOOP

Parameters

int32 preset

int32 startsample

int32 loopsample

int32 loopmode

int32 endsample

int32 samplelength

bool32.tgl intExt

bool32.tgl LOOP

frac32.s.map FMwidth

frac32.s.map startpitch

frac32.s.map looppitch

frac32.s.map endpitch

frac32.u.map startStrt

frac32.u.map startEnd

frac32.u.map loopStrt

frac32.u.map loopEnd

frac32.u.map endStrt

frac32.u.map endEnd

Attributes

objref settings

objref samples

Displays

int8array128.vbar sample

Declaration
int i;
int j;
int32_t sum[128];
int gtrig;
int generate;
int32_t prevSS;
int32_t prevLS;
int32_t prevES;
int prevpreset;
int sample;
int pos1;
int pos2;
Control Rate
int32_t preset;
preset = param_preset << 4;

if (!(prevpreset == preset)) {
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_startsample],
                     attr_settings.array[preset], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_startpitch],
                     attr_settings.array[preset + 1], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_startStrt],
                     attr_settings.array[preset + 2], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_startEnd],
                     attr_settings.array[preset + 3], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_loopsample],
                     attr_settings.array[preset + 4], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_looppitch],
                     attr_settings.array[preset + 5], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_loopStrt],
                     attr_settings.array[preset + 6], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_loopEnd],
                     attr_settings.array[preset + 7], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_loopmode],
                     attr_settings.array[preset + 8], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_LOOP],
                     attr_settings.array[preset + 9], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_endsample],
                     attr_settings.array[preset + 10], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_endpitch],
                     attr_settings.array[preset + 11], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_endStrt],
                     attr_settings.array[preset + 12], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_endEnd],
                     attr_settings.array[preset + 13], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_samplelength],
                     attr_settings.array[preset + 14], 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_FMwidth],
                     attr_settings.array[preset + 15], 0xFFFD);
}

if (!(attr_settings.array[0] == param_startsample)) {
  attr_settings.array[preset] = param_startsample;
}
if (!(attr_settings.array[1 + preset] == param_startpitch)) {
  attr_settings.array[1 + preset] = param_startpitch;
}
if (!(attr_settings.array[2 + preset] == param_startStrt)) {
  attr_settings.array[2 + preset] = param_startStrt;
}
if (!(attr_settings.array[3 + preset] == param_startEnd)) {
  attr_settings.array[3 + preset] = param_startEnd;
}
if (!(attr_settings.array[4 + preset] == param_loopsample)) {
  attr_settings.array[4 + preset] = param_loopsample;
}
if (!(attr_settings.array[5 + preset] == param_looppitch)) {
  attr_settings.array[5 + preset] = param_looppitch;
}
if (!(attr_settings.array[6 + preset] == param_loopStrt)) {
  attr_settings.array[6 + preset] = param_loopStrt;
}
if (!(attr_settings.array[7 + preset] == param_loopEnd)) {
  attr_settings.array[7 + preset] = param_loopEnd;
}
if (!(attr_settings.array[8 + preset] == param_loopmode)) {
  attr_settings.array[8 + preset] = param_loopmode;
}
if (!(attr_settings.array[9 + preset] == param_LOOP)) {
  attr_settings.array[9 + preset] = param_LOOP;
}
if (!(attr_settings.array[10 + preset] == param_endsample)) {
  attr_settings.array[10 + preset] = param_endsample;
}
if (!(attr_settings.array[11 + preset] == param_endpitch)) {
  attr_settings.array[11 + preset] = param_endpitch;
}
if (!(attr_settings.array[12 + preset] == param_endStrt)) {
  attr_settings.array[12 + preset] = param_endStrt;
}
if (!(attr_settings.array[13 + preset] == param_endEnd)) {
  attr_settings.array[13 + preset] = param_endEnd;
}
if (!(attr_settings.array[14 + preset] == param_samplelength)) {
  attr_settings.array[14 + preset] = param_samplelength;
}
if (!(attr_settings.array[15 + preset] == param_FMwidth)) {
  attr_settings.array[15 + preset] = param_FMwidth;
}
int Preset;
if (param_intExt == 0) {
  Preset = inlet_preset << 4;
} else {
  Preset = param_preset << 4;
}

outlet_startsample = attr_settings.array[Preset];
outlet_startpitch = attr_settings.array[1 + Preset];
outlet_startStrt = attr_settings.array[2 + Preset];
outlet_startEnd = attr_settings.array[3 + Preset];
outlet_loopsample = attr_settings.array[4 + Preset];
outlet_looppitch = attr_settings.array[5 + Preset];
outlet_loopStrt = attr_settings.array[6 + Preset];
outlet_loopEnd = attr_settings.array[7 + Preset];
outlet_loopmode = attr_settings.array[8 + Preset];
outlet_LOOP = attr_settings.array[9 + Preset];
outlet_endsample = attr_settings.array[10 + Preset];
outlet_endpitch = attr_settings.array[11 + Preset];
outlet_endStrt = attr_settings.array[12 + Preset];
outlet_endEnd = attr_settings.array[13 + Preset];
outlet_samplelength = attr_settings.array[14 + Preset];
outlet_FMwidth = attr_settings.array[15 + Preset];

int32_t samplelength = 1 << param_samplelength;
int samplemask = 1 << (param_samplelength - 7);
int32_t totalcount = 128;
int32_t start = ___SMMUL(param_startStrt << 2, totalcount << 3);
int32_t stend = ___SMMUL(param_startEnd << 2, totalcount << 3);
int32_t enstart = ___SMMUL(param_endStrt << 2, totalcount << 3);
int32_t end = ___SMMUL(param_endEnd << 2, totalcount << 3);
int32_t loopstart = ___SMMUL(param_loopStrt << 2, totalcount << 3);
int32_t loopend = ___SMMUL(param_loopEnd << 2, totalcount << 3);
generate = 0;
if (!(param_startsample + start + stend == prevSS)) {
  sample = param_startsample;
  generate = 1;
  pos1 = start;
  pos2 = stend;
}
if (!(param_loopsample + loopstart + loopend == prevLS)) {
  sample = param_loopsample;
  generate = 1;
  pos1 = loopstart;
  pos2 = loopend;
}
if (!(param_endsample + enstart + end == prevES)) {
  sample = param_endsample;
  generate = 1;
  pos1 = enstart;
  pos2 = end;
}

if ((generate > 0) && !gtrig) {
  gtrig = 1;
  for (i = 0; i < 128; i++) {
    sum[i] = 0;
  }

  for (i = 0; i < 128; i++) {
    int32_t Sum = 0;
    for (j = 0; j < samplemask; j++) {
      int32_t temp =
          ((attr_samples.array[(j + i * samplemask) + sample * samplelength])
           << attr_samples.GAIN) >>
          12;
      int32_t tamp = temp;
      temp = temp > 0 ? temp : -temp;
      sum[i] = temp > Sum ? tamp : sum[i];
      Sum = temp > Sum ? temp : Sum;
    }
  }
  sum[pos1] = ((1 << 27) - 1) >> 8;
  sum[pos2] = -((1 << 27) - 1) >> 8;
} else if (generate == 0) {
  gtrig = 0;
}
for (i = 0; i < 128; i++) {
  disp_sample[i] = sum[i] >> 13;
}

prevSS = param_startsample + start + stend;
prevLS = param_loopsample + loopstart + loopend;
prevES = param_endsample + enstart + end;
prevpreset = preset;

Privacy

© 2024 Zrna Research