sampleplayer2

a simple sample player to play 4 independent samples from a samplebank made by the loadtrain modules.
Author: Remco van der Most
License: BSD
Github: sss/sampler/sampleplayer2.axo

Inlets

frac32 pitch for sample 1

frac32 pitch for sample 2

frac32 pitch for sample 3

frac32 pitch for sample 4

int32 sample 1 select

int32 sample 2 select

int32 sample 3 select

int32 sample 4 select

int32 first

int32 samples

bool32 trigger for sample 1

bool32 trigger for sample 2

bool32 trigger for sample3

bool32 trigger for sample4

Outlets

frac32buffer table[a]

Parameters

frac32.s.map offsets the pitch for all samplers

Attributes

objref this should refer to a 16bit table allocator (sdram)

objref this should refer to a 32bit table allocator

Declaration
bool gate[4];
uint32_t pos[4];
int32_t frq[4];
int32_t G[4];
int i;
int32_t v30 = 1 << 30;
int32_t v29 = 1 << 29;
int32_t P[4];
int32_t p[4];
int16_t S[4];
int16_t IS[4];
uint32_t width[4];
uint32_t sStart[4];
Init
for (i = 0; i < 4; i++) {
  pos[i] = -1 << 30;
  S[i] = 0;
}
Control Rate
G[0] = inlet_gate1;
G[1] = inlet_gate2;
G[2] = inlet_gate3;
G[3] = inlet_gate4;

IS[0] = inlet_sample1;
IS[1] = inlet_sample2;
IS[2] = inlet_sample3;
IS[3] = inlet_sample4;

p[0] = inlet_pitch1 + param_pitch;
p[1] = inlet_pitch2 + param_pitch;
p[2] = inlet_pitch3 + param_pitch;
p[3] = inlet_pitch4 + param_pitch;

for (i = 0; i < 4; i++) {
  if ((G[i] > 0) && !gate[i]) {
    gate[i] = 1;
    P[i] = 0;
    S[i] = IS[i] - IS[i] / inlet_samples * inlet_samples;
    S[i] += ((S[i] < 0 ? inlet_samples : 0) + inlet_first);
    S[i] = S[i] & attr_starts.LENGTHMASK;
  } else if (G[i] == 0) {
    gate[i] = 0;
  }
  sStart[i] = attr_starts.array[S[i]];
  width[i] = (attr_starts.array[S[i] + 1]) - sStart[i];
  uint32_t base;
  float32_t r1;
  MTOFEXTENDED(p[i], frq[i])
  MTOFEXTENDED(0, base)
  r1 = (float32_t)frq[i] / base;
  frq[i] = ((int64_t)1 << 32) / width[i] * r1;
}
Audio Rate
// P1=P1>PE?-8:P1;
outlet_out = 0;
for (i = 0; i < 4; i++) {
  pos[i] = ___SMMUL(width[i] << 1, P[i]);
  if ((pos[i] < width[i]) && (pos[i] >= 0)) {
    outlet_out += attr_samples.array[pos[i] + sStart[i]] << 12;
    P[i] += frq[i];
  }
}

Privacy

© 2024 Zrna Research