Skip to content

Sequencer API

ianhattwick edited this page Jun 3, 2021 · 2 revisions

Sequence API

Constructor

Sequencer(uint8_t steps);

  • steps sets number of sequencer stepSize

Basic functions

int16_t get();

  • reads the value of the current step without incrementing index

int16_t get(uint8_t step);

  • reads the value of specific step step without incrementing index

void set(uint8_t step, int16_t val);

  • set the value of index step to val
  • val can be in the full range of your sequencer, e.g. 12-bit by default (0-4095)

int16_t trigger();

  • advances sequencer to the next step, and returns the value of the new step

uint8_t getCurStep();

  • returns the index number of the current step

controlling the current index

void reset();

  • resets the curStep index number to 0.
  • The next trigger will return the value of step 0 and will not advance the step as normal void reset(uint8_t step);
  • resets the curStep index number to step
  • The next trigger will return the value of step and will not advance the step as normal

uint8_t range(uint8_t begin, uint8_t end);

  • constrain the curStep index number to the range (begin, end), inclusive

void reverse();

  • set the curStep index increment to be a positive number

void forward();

  • set the curStep index increment to be a negative number

void stepSize(uint8_t step);

  • sets the increment for the curStep index.
  • the default increment is 1
  • the increment is added to the curStep when trigger() is called.

uint8_t endOfCycle();

  • returns 1 if curStep is the last step of the sequence

uint8_t startOfCycle();

  • returns 1 if curStep is the first step of the sequence

reading the current sequence into external array

uint8_t getArray(int16_t *arr, uint8_t size);

  • copies the array containing the current sequence to an external array
  • you will have to define an uint16_t arr[seqSize]
  • and then pass the address of this array as the first argument to getArray.
  • returns the number of bytes copied (kinda)

fill the array with a sequence

void fill(int16_t val);

  • set all steps to a single value

void fill(int16_t *arr, uint8_t size);

  • use an external array to fill the sequence.
  • If the external array is shorter than the sequence size, the array will be read multiple times until the sequence is filled void fill(int16_t *arr, uint8_t size, uint8_t offset);
  • Same as the above except the first element of arr is copied to the sequence step offset, and the subsequent values go from there
  • values will wrap around the sequence to fill all sequence values

copy an array into the sequence

void setArray(int16_t *arr, uint8_t size);

void setArray(int16_t *arr, uint8_t size, uint8_t offset);