bwp_arp_v2

Arpeggiator.

It features various playing note and range (octaves) patterns, 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).

Examples

We can privately hand you one or more example plugins if you are interested.

Contact us

API

Module type: Utility

bwp_arp_v2_note_pattern

typedef enum {
	bwp_arp_v2_note_pattern_up,
	bwp_arp_v2_note_pattern_down,
	bwp_arp_v2_note_pattern_up_down,
	bwp_arp_v2_note_pattern_down_up,
	bwp_arp_v2_note_pattern_up_down_no_repeat,
	bwp_arp_v2_note_pattern_down_up_no_repeat,
	bwp_arp_v2_note_pattern_up_while_up_and_down_while_down,
	bwp_arp_v2_note_pattern_up_while_up_and_down_while_down_no_repeat,
	bwp_arp_v2_note_pattern_first_to_last,
	bwp_arp_v2_note_pattern_last_to_first,
	bwp_arp_v2_note_pattern_first_to_last_and_back,
	bwp_arp_v2_note_pattern_last_to_first_and_back,
	bwp_arp_v2_note_pattern_first_to_last_and_back_no_repeat,
	bwp_arp_v2_note_pattern_last_to_first_and_back_no_repeat,
	bwp_arp_v2_note_pattern_first_to_last_while_up_and_last_to_first_while_down,
	bwp_arp_v2_note_pattern_first_to_last_while_up_and_last_to_first_while_down_no_repeat,
	bwp_arp_v2_note_pattern_random
} bwp_arp_v2_note_pattern;

Note playing patterns:

  • bwp_arp_v2_note_pattern_up: play notes by increasing pitch;
  • bwp_arp_v2_note_pattern_down: play notes by decreasing pitch;
  • bwp_arp_v2_note_pattern_up_down: play notes by increasing then decreasing pitch;
  • bwp_arp_v2_note_pattern_down_up: play notes by decreasing then increasing pitch;
  • bwp_arp_v2_note_pattern_up_down_no_repeat: like bwp_arp_v2_note_pattern_up_down but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_note_pattern_down_up_no_repeat: like bwp_arp_v2_note_pattern_down_up but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_note_pattern_up_while_up_and_down_while_down: play notes by increasing pitch while going up with range and then by decreasing pitch in the opposite direction;
  • bwp_arp_v2_note_pattern_up_while_up_and_down_while_down_no_repeat: like bwp_arp_v2_note_pattern_up_while_up_and_down_while_down but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_note_pattern_first_to_last: play notes by increasing pressing time order;
  • bwp_arp_v2_note_pattern_last_to_first: play notes by decreasing pressing time order;
  • bwp_arp_v2_note_pattern_first_to_last_and_back: play notes by increasing then decreasing pressing time order;
  • bwp_arp_v2_note_pattern_last_to_first_and_back: play notes by decreasing then increasing pressing time order;
  • bwp_arp_v2_note_pattern_first_to_last_and_back_no_repeat: like bwp_arp_v2_note_pattern_first_to_last_and_back but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_note_pattern_last_to_first_and_back_no_repeat: like bwp_arp_v2_note_pattern_last_to_first_and_back but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_note_pattern_first_to_last_while_up_and_last_to_first_while_down: play notes by increasing pressing time order while going up with range and then by decreasing pressing time order in the opposite direction;
  • bwp_arp_v2_note_pattern_first_to_last_while_up_and_last_to_first_while_down_no_repeat: like `` but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_note_pattern_random: play notes randomly.

bwp_arp_v2_range_pattern

typedef enum {
	bwp_arp_v2_range_pattern_up,
	bwp_arp_v2_range_pattern_down,
	bwp_arp_v2_range_pattern_up_down,
	bwp_arp_v2_range_pattern_down_up,
	bwp_arp_v2_range_pattern_up_down_no_repeat,
	bwp_arp_v2_range_pattern_down_up_no_repeat,
	bwp_arp_v2_range_pattern_random
} bwp_arp_v2_range_pattern;

Range playing patterns:

  • bwp_arp_v2_range_pattern_up: increase from minimum to maximum;
  • bwp_arp_v2_range_pattern_down: decrease from maximum to minimum;
  • bwp_arp_v2_range_pattern_up_down: increase from minimum to maximum then then decrease from maximum to minimum;
  • bwp_arp_v2_range_pattern_up_down_no_repeat: like bwp_arp_v2_range_pattern_up_down but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_range_pattern_down_up_no_repeat: like bwp_arp_v2_range_pattern_down_up but without repeating extremes when changing direction, if possible;
  • bwp_arp_v2_range_pattern_random: pick a random range.

bwp_arp_v2_outside_mode

typedef enum {
	bwp_arp_v2_outside_mode_dont_play,
	bwp_arp_v2_outside_mode_skip
} bwp_arp_v2_outside_mode;

Modes for handling notes falling outside of the current output note range:

  • bwp_arp_v2_outside_mode_dont_play: just don't play anything;
  • bwp_arp_v2_outside_mode_skip: skip them and play the next one in range.

bwp_arp

typedef struct bwp_arp_v2 bwp_arp_v2;

Arpeggiator object.

bwp_arp_v2_init()

static inline void bwp_arp_v2_init(
	bwp_arp_v2 * 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_v2_note_pattern_random or bwp_arp_v2_range_pattern_random patterns.

Call this on arp before other functions in this API.

bwp_arp_v2_reset()

static inline void bwp_arp_v2_reset(
	bwp_arp_v2 * BW_RESTRICT arp);

Resets arp to its initial state.

This must be called at least once before calling bwp_arp_v2_process().

bwp_arp_v2_process()

static inline void bwp_arp_v2_process(
	bwp_arp_v2 * 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.

bwp_arp_v2_set_bypass()

static inline void bwp_arp_v2_set_bypass(
	bwp_arp_v2 * BW_RESTRICT arp,
	char                     value);

Sets whether arp is bypassed (value non-0) or not (0).

Default value: 0 (arpeggiator on).

bwp_arp_v2_set_note_pattern()

static inline void bwp_arp_v2_set_note_pattern(
	bwp_arp_v2 * BW_RESTRICT arp,
	bwp_arp_v2_note_pattern  value);

Sets the note playing pattern to value in arp.

If rand_state was BW_NULL when calling bwp_arp_v2_init(), then bwp_arp_v2_note_pattern_random is invalid.

Default value: bwp_arp_v2_note_pattern_up.

bwp_arp_v2_set_range_pattern()

static inline void bwp_arp_v2_set_range_pattern(
	bwp_arp_v2 * BW_RESTRICT arp,
	bwp_arp_v2_range_pattern value);

Sets the range playing pattern to value in arp.

If rand_state was BW_NULL when calling bwp_arp_v2_init(), then bwp_arp_v2_range_pattern_random is invalid.

Default value: bwp_arp_v2_range_pattern_up.

bwp_arp_v2_set_range_first()

static inline void bwp_arp_v2_set_range_first(
	bwp_arp_v2 * BW_RESTRICT arp,
	char                     value);

Sets whether the range pattern is played first per each note (value non-0) or otherwise the note pattern is played first per each range (value 0) in arp.

Default value: 0 (notes first).

bwp_arp_v2_set_range_min()

static inline void bwp_arp_v2_set_range_min(
	bwp_arp_v2 * BW_RESTRICT arp,
	signed char              value);

Sets the minimum repeat range value (octaves) in arp.

By the time bwp_arp_v2_reset() or bwp_arp_v2_process() is called, range_min must be less than or equal to range_max and range_start must be within [range_min, range_max].

Default value: 0.

bwp_arp_v2_set_range_max()

static inline void bwp_arp_v2_set_range_max(
	bwp_arp_v2 * BW_RESTRICT arp,
	signed char              value);

Sets the maximum repeat range value (octaves) in arp.

By the time bwp_arp_v2_reset() or bwp_arp_v2_process() is called, range_min must be less than or equal to range_max and range_start must be within [range_min, range_max].

Default value: 0.

bwp_arp_v2_set_range_start()

static inline void bwp_arp_v2_set_range_start(
	bwp_arp_v2 * BW_RESTRICT arp,
	signed char              value);

Sets the initial repeat range value (octaves) in arp.

This has no effect when the range playing pattern is bwp_arp_v2_range_pattern_random.

By the time bwp_arp_v2_reset() or bwp_arp_v2_process() is called, range_min must be less than or equal to range_max and range_start must be within [range_min, range_max].

Default value: 0.

bwp_arp_v2_set_note_on_min()

static inline void bwp_arp_v2_set_note_on_min(
	bwp_arp_v2 * BW_RESTRICT arp,
	unsigned char            value);

Sets the minimum note of the output note range to value in arp.

By the time bwp_arp_v2_reset() or bwp_arp_v2_process() is called, note_on_min must be less than or equal to note_on_max.

Valid range: [0, 127].

Default value: 0.

bwp_arp_v2_set_note_on_max()

static inline void bwp_arp_v2_set_note_on_max(
	bwp_arp_v2 * BW_RESTRICT arp,
	unsigned char            value);

Sets the maximum note of the output note range to value in arp.

By the time bwp_arp_v2_reset() or bwp_arp_v2_process() is called, note_on_min must be less than or equal to note_on_max.

Valid range: [0, 127].

Default value: 127.

bwp_arp_v2_set_outside_mode()

static inline void bwp_arp_v2_set_outside_mode(
	bwp_arp_v2 * BW_RESTRICT arp,
	bwp_arp_v2_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_v2_outside_mode_dont_play.

bwp_arp_v2_set_immediate_off()

static inline void bwp_arp_v2_set_immediate_off(
	bwp_arp_v2 * 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.

bwp_arp_v2_set_output_map()

static inline void bwp_arp_v2_set_output_map(
	bwp_arp_v2 * BW_RESTRICT arp,
	int (*func)(signed char note, signed char range));

Sets a mapping function func in arp that maps the output note and range to the actual final note number when arp is not bypassed.

If func is BW_NULL, the final note number will be computed as note

  • 12 * range.

Defalut value: BW_NULL (note + 12 * range).

bwp_arp_v2_get_queue()

static inline bw_note_queue * bwp_arp_v2_get_queue(
	bwp_arp_v2 * BW_RESTRICT arp);

Returns a pointer to arp's internal output note queue, which has to be cleared by the user of this API.

bwp_arp_v2_is_valid()

static inline char bwp_arp_v2_is_valid(
	bwp_arp_v2 * 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.

C++ wrapper

BrickworksPro::ArpV2
class ArpV2 {
public:
	ArpV2(
		uint64_t * BW_RESTRICT randState);

	void reset();

	void process(
		const bw_note_queue * BW_RESTRICT queue,
		size_t                            trigCount);

	void setBypass(
		bool value);

	void setNotePattern(
		bwp_arp_v2_note_pattern value);

	void setRangePattern(
		bwp_arp_v2_range_pattern value);

	void setRangeFirst(
		bool value);

	void setRangeMin(
		signed char value);

	void setRangeMax(
		signed char value);

	void setRangeStart(
		signed char value);

	void setNoteOnMin(
		unsigned char value);

	void setNoteOnMax(
		unsigned char value);

	void setOutsideMode(
		bwp_arp_v2_outside_mode value);

	void setImmediateOff(
		bool value);

	void setOutputMap(
		int (*func)(signed char note, signed char range));

	bw_note_queue * getQueue();
...
}

Changelog

  • Version 2.0.0:
    • Revamped API and implementation.
    • Fixed typos in the documentation of bwp_arp_set_note_on_max() and bwp_arp_is_valid().
  • Version 1.0.0:
    • First release.