pattern_selector

Step sequencer pattern selector
Author: Are Leistad
License: BSD
Github: drj/seq/pattern_selector.axo

Inlets

int32 Pattern number input

bool32.rising Clock pulse input

bool32.rising Start pulse input

frac32 Pattern 1 signal 1 input

frac32 Pattern 1 signal 2 input

frac32 Pattern 1 signal 3 input

frac32 Pattern 2 signal 1 input

frac32 Pattern 2 signal 2 input

frac32 Pattern 2 signal 3 input

frac32 Pattern 3 signal 1 input

frac32 Pattern 3 signal 2 input

frac32 Pattern 3 signal 3 input

frac32 Pattern 4 signal 1 input

frac32 Pattern 4 signal 2 input

frac32 Pattern 4 signal 3 input

bool32 Pattern 1 gate 1 input

bool32 Pattern 2 gate 1 input

bool32 Pattern 3 gate 1 input

bool32 Pattern 4 gate 1 input

Outlets

int32 Current pattern number output

bool32.pulse Pattern switch pulse output

frac32 Signal 1 output

frac32 Signal 2 output

frac32 Signal 3 output

bool32 Gate 1 output

Parameters

int32.hradio pattern

bool32.tgl Use the pattern number input

bool32.tgl Pattern switches on next clock pulse

bool32.tgl Pattern switches on next start pulse

bool32.tgl Mutes the pattern outputs

Displays

int32.label current

Declaration
int32_t current_pattern;
int32_t next_pattern;
uint32_t old_clock;
uint32_t old_start;
Init
current_pattern = 0;
next_pattern = -1;
old_clock = 0;
old_start = 0;
Control Rate
//  Cue up the next pattern for playing

if (param_extpattern) {
  if (inlet_pattern != current_pattern) {
    next_pattern = inlet_pattern;
  }
} else if (param_pattern != current_pattern) {
  next_pattern = param_pattern;
}

// Switch pattern according to the sync settings

outlet_switch = 0;
if (next_pattern != -1 && next_pattern != current_pattern) {
  bool do_switch = false;
  if (param_syncclock) {
    if (inlet_clock && !old_clock) {
      do_switch = true;
    }
  } else if (param_syncstart) {
    if (inlet_start && !old_start) {
      do_switch = true;
    }
  } else {
    do_switch = true;
  }

  if (do_switch) {
    current_pattern = next_pattern;
    next_pattern = -1;
    outlet_switch = 1;
  }
}

switch (param_mute ? 4 : current_pattern) {
case 0:
  outlet_s1 = inlet_p1s1;
  outlet_s2 = inlet_p1s2;
  outlet_s3 = inlet_p1s3;
  outlet_g1 = inlet_p1g1;
  break;
case 1:
  outlet_s1 = inlet_p2s1;
  outlet_s2 = inlet_p2s2;
  outlet_s3 = inlet_p2s3;
  outlet_g1 = inlet_p2g1;
  break;
case 2:
  outlet_s1 = inlet_p3s1;
  outlet_s2 = inlet_p3s2;
  outlet_s3 = inlet_p3s3;
  outlet_g1 = inlet_p3g1;
  break;
case 3:
  outlet_s1 = inlet_p4s1;
  outlet_s2 = inlet_p4s2;
  outlet_s3 = inlet_p4s3;
  outlet_g1 = inlet_p4g1;
  break;
case 4:
default:
  outlet_s1 = 0;
  outlet_s2 = 0;
  outlet_s3 = 0;
  outlet_g1 = 0;
  break;
}

outlet_pattern = current_pattern;
disp_current = current_pattern + 1;
old_clock = inlet_clock;
old_start = inlet_start;

Privacy

© 2024 Zrna Research