Arpeggiator.
It features various playing modes, repeats on several ranges (octaves), can handle output notes falling out of a given note range in different ways, and more.
It is not concerned with timing and hence has to be used with an external trigger (e.g., bwp_trig).
Version: 1.0.1
This algorithm is deprecated, thus we are not offering new licensese for it.
The current version is bwp_arp_v2.
Module type: Utility
typedef enum {
bwp_arp_mode_off,
bwp_arp_mode_up,
bwp_arp_mode_down,
bwp_arp_mode_up_down,
bwp_arp_mode_up_down_no_repeat,
bwp_arp_mode_first_to_last,
bwp_arp_mode_last_to_first,
bwp_arp_mode_first_to_last_and_back,
bwp_arp_mode_first_to_last_and_back_no_repeat,
bwp_arp_mode_random
} bwp_arp_mode;
Note playing modes:
bwp_arp_mode_off: arpeggiator off (bypass);bwp_arp_mode_up: play notes by increasing pitch;bwp_arp_mode_down: play notes by decreasing pitch;bwp_arp_mode_up_down: play notes by increasing then decreasing pitch;bwp_arp_mode_up_down_no_repeat: play notes by increasing then decreasing pitch, avoiding to repeat same notes within the same range, if possible;bwp_arp_mode_first_to_last: play notes by increasing pressing time order;bwp_arp_mode_last_to_first: play notes by decreasing pressing time order;bwp_arp_mode_first_to_last_and_back: play notes by increasing then decreasing pressing time order;bwp_arp_mode_first_to_last_and_back_no_repeat: play notes by increasing then decreasing pressing time order, avoiding to repeat same notes within the same range, if possible;bwp_arp_mode_random: play notes in random order.typedef enum {
bwp_arp_outside_mode_dont_play,
bwp_arp_outside_mode_skip
} bwp_arp_outside_mode;
Modes for handling notes falling outside of the current output note range:
bwp_arp_outside_mode_dont_play: just don't play anything;bwp_arp_outside_mode_skip: skip them and play the next one in range.typedef struct bwp_arp bwp_arp;
Arpeggiator object.
static inline void bwp_arp_init(
bwp_arp * BW_RESTRICT arp,
uint64_t * BW_RESTRICT rand_state);
Initializes option values in arp and sets the rand_state pointer to obtain pseudo-random numbers in arp.
rand_state can be BW_NULL, in which case you must not use bwp_arp_mode_random mode.
Call this on arp before other functions in this API.
static inline void bwp_arp_reset(
bwp_arp * BW_RESTRICT arp);
Resets arp to its initial state.
This must be called at least once before calling bwp_arp_process().
static inline void bwp_arp_process(
bwp_arp * BW_RESTRICT arp,
const bw_note_queue * BW_RESTRICT queue,
size_t trig_count);
Lets arp process events in the input queue, where trig_count is the number of trigger events since last call, if any.
static inline void bwp_arp_set_mode(
bwp_arp * BW_RESTRICT arp,
bwp_arp_mode value);
Sets the note playing mode to value in arp.
If rand_state was BW_NULL when calling bwp_arp_init(), then bwp_arp_mode_random is invalid.
Default value: bwp_arp_mode_off.
static inline void bwp_arp_set_range_min(
bwp_arp * BW_RESTRICT arp,
signed char value);
Sets the minimum repeat range value (octaves) in arp.
By the time bwp_arp_reset() or bwp_arp_process() is called, range_min must be less than or equal to range_max.
Default value: 0.
static inline void bwp_arp_set_range_max(
bwp_arp * BW_RESTRICT arp,
signed char value);
Sets the maximum repeat range value (octaves) in arp.
By the time bwp_arp_reset() or bwp_arp_process() is called, range_min must be less than or equal to range_max.
Default value: 0.
static inline void bwp_arp_set_note_on_min(
bwp_arp * BW_RESTRICT arp,
unsigned char value);
Sets the minimum note of the output note range to value in arp.
By the time bwp_arp_reset() or bwp_arp_process() is called, note_on_min must be less than or equal to note_on_max.
Valid range: [0, 127].
Default value: 0.
static inline void bwp_arp_set_note_on_max(
bwp_arp * BW_RESTRICT arp,
unsigned char value);
Sets the maximum note of the output note range to value in arp.
By the time bwp_arp_reset() or bwp_arp_process() is called, note_on_min must be less than or equal to note_on_max.
Valid range: [0, 127].
Default value: 127.
static inline void bwp_arp_set_outside_mode(
bwp_arp * BW_RESTRICT arp,
bwp_arp_outside_mode value);
Sets the modes for handling notes falling outside of the current output note range to value in arp.
Default value: bwp_arp_outside_mode_dont_play.
static inline void bwp_arp_set_immediate_off(
bwp_arp * BW_RESTRICT arp,
char value);
Sets whether all notes should be immediately turned off when no notes are played in the input queue (value non-0) or not (0).
Defalut value: 0.
static inline bw_note_queue * bwp_arp_get_queue(
bwp_arp * BW_RESTRICT arp);
Returns a pointer to arp's internal output note queue, which has to be cleared by the user of this API.
static inline char bwp_arp_is_valid(
bwp_arp * BW_RESTRICT arp);
Tries to determine whether arp is valid and returns non-0 if it seems to be the case and 0 if it is certainly not. False positives are possible, false negatives are not.
arp must at least point to a readable memory block of size greater than or equal to that of bwp_arp.
class Arp {
public:
Arp(
uint64_t * BW_RESTRICT randState);
void reset();
void process(
const bw_note_queue * BW_RESTRICT queue,
size_t trigCount);
void setMode(
bwp_arp_mode value);
void setRangeMin(
signed char value);
void setRangeMax(
signed char value);
void setNoteOnMin(
unsigned char value);
void setNoteOnMax(
unsigned char value);
void setOutsideMode(
bwp_arp_outside_mode value);
void setImmediateOff(
char value);
bw_note_queue * getQueue();
...
}
bwp_arp_set_note_on_max() and bwp_arp_is_valid().