songtracker

(USE WITH MODULE: patt/songsetup) A tracker consisting of several counters that uses the stored table of the "songsetup" module to play a song. The integer outputs give the "counter position" or "counter maximum" of the respective counters. These are seperated into: -independent outputs for the different counters (steps/measure, measures/bar,bars/part,parts/song) and their own maximum steplength. -combinations of 2,3 or 4 counters and their combined maximum steplength. By controlling pattern and preset generators/controllers with these outputs, these two modules should be able to setup whole songs (hopefully)
Author: Johannes Taelman
License: BSD
Github: sss/patt/songtracker.axo

Inlets

frac32 sets tempo base (tempo of the measure, denominator sets the rate according to the amount of steps per measure based on this tempo)

bool32.rising instant restart song while playing

bool32 when triggered, song starts playing

bool32 when triggered, song pauses at current position until play is pressed

bool32 when triggered, song stops and is reset to start position

Outlets

bool32 goes high when sequencer is running

bool32.pulse main clock output (denominator * main tempo)

int32 step position within measure

int32 maximum steps in the measure

int32 measure position within the bar

int32 maximum measures in the bar

int32 bar position within the part

int32 maximum bars in the part

int32 part position within the song

int32 maximum pars in the song

int32 preset selection of the part

int32 position of stop+measure within bar

int32 maximum steps in bar

int32 position of stop+measure+bar within part

int32 maximum steps in part

int32 WRONG position of stop+measure+bar+part within song(difference in steps per part!)

int32 WRONG maximum steps in song (difference in steps per part!)

int32 position of measure+bar within part (steps quantized to measure)

int32 maximumum measures in part

int32 WRONG position of measure+bar+part within song (difference in measures per part!)

int32 WRONG maximum measures in song (difference in measures per part!)

int32 WRONG position of bar+part within song (difference in bars per part!)

int32 WRONG maximum bars in song (difference in bars per part!)

Attributes

objref memory

Declaration
int32_t phs;
bool ntrig, rtrig, start, play, pause, stop, run;
int i;
int cnt[5];
int Sc;
int Sm;
int Mc;
int Mm;
int Bc;
int Bm;
int Pc;
int Pm;
Init
for (i = 0; i < 5; i++) {
  cnt[i] = 0;
}
ntrig = 0;
rtrig = 0;
start = 1;
run = 0;
Control Rate
if (inlet_play && !play) {
  play = 1;
  run = 1;
} else if (play && !inlet_play) {
  play = 0;
}

if (inlet_pause && !pause) {
  pause = 1;
  run = 0;
} else if (pause && !inlet_pause) {
  pause = 0;
}
int rst = inlet_r;
if (inlet_stop && !stop) {
  stop = 1;
  run = 0;
  rst = 1;
} else if (stop && !inlet_stop) {
  stop = 0;
}

if ((rst > 0) && !rtrig) {
  for (i = 0; i < 5; i++) {
    cnt[i] = 0;
  }
  rtrig = 1;
  start = 1;
} else if (!(rst > 0)) {
  rtrig = 0;
}
int part = cnt[3] << 3;
outlet_clock = 0;
if (run > 0) {
  int32_t frq;
  MTOF(inlet_tempo, frq)
  frq = frq >> 2;

  phs += frq * (attr_memory.array[2 + part] + 1);
  if (phs > 0) {
    outlet_clock = 1;
  }
  if ((phs > 0) && !ntrig) {

    cnt[0] += 1; // steps cnt[0]
    if (start == 1) {
      cnt[0] = 0;
      start = 0;
    }
    if (cnt[0] >= (attr_memory.array[part + 1] + 1)) { // measure cnt[1]
      cnt[0] = 0;
      cnt[1] += 1;
      if (cnt[1] >= (attr_memory.array[part + 3] + 1)) { // bars cnt[3]
        cnt[1] = 0;
        cnt[2] += 1;
        if (cnt[2] >= (attr_memory.array[part + 4] + 1)) {
          if (attr_memory.array[part + 5] == 0) { // loopback off
            cnt[3] += 1;
          } else { // loopback on
            if (cnt[4] < (attr_memory.array[7] + 1)) {
              cnt[3] = attr_memory.array[part + 6];
              cnt[4] += 1;
            } else {
              cnt[3] += 1;
              cnt[4] = 0;
            }
          }
          cnt[2] = 0;
        }
      }
    }
    ntrig = 1;
  } else if (!(phs > 0)) {
    ntrig = 0;
  }
}

if (cnt[3] >= attr_memory.max) {
  if (attr_memory.loop > 0) {
    for (i = 0; i < 5; i++) {
      cnt[i] = 0;
      start = 1;
    }
  } else {
    run = 0;
    for (i = 0; i < 5; i++) {
      cnt[i] = 0;
    }
    start = 1;
  }
}
outlet_run = run;

if (run > 0) {
  Sc = cnt[0];
  Sm = attr_memory.array[part + 1] + 1;
  Mc = cnt[1];
  Mm = attr_memory.array[part + 3] + 1;
  Bc = cnt[2];
  Bm = attr_memory.array[part + 4] + 1;
  Pc = cnt[3];
  Pm = attr_memory.max;
}

outlet_step = Sc;
outlet_maxstep = Sm;
outlet_measure = Mc;
outlet_maxmeasure = Mm;
outlet_bar = Bc;
outlet_maxbar = Bm;
outlet_part = Pc;
outlet_maxparts = Pm;
outlet_preset = attr_memory.array[part];

outlet_sm = Sc + Mc * Sm;
outlet_smmax = Sm * Mm;
outlet_smb = outlet_sm + Bc * Mm * Sm;
outlet_smbmax = outlet_smmax * Bm;
outlet_smbp = outlet_smb + Pc * Bm * Mm * Sm;
outlet_smbpmax = outlet_smbmax * Pm;
outlet_mb = Mc + Bc * Mm;
outlet_mbmax = Mm * Bm;
outlet_mbp = outlet_mb + Pc * Mm * Bm;
outlet_mbpmax = outlet_mbmax * Pm;
outlet_bp = Bc + Pc * Bm;
outlet_bpmax = Bm * Pm;

Privacy

© 2024 Zrna Research