Pressed note tracker by pitch and time.
Version: 1.1.0
License: proprietary license
We can privately hand you one or more example plugins if you are interested.
Module type: Utility
typedef struct {
bwp_list by_pitch;
bwp_list by_time;
bwp_list_elem by_pitch_elems[128];
bwp_list_elem by_time_elems[128];
char pressed[128];
float velocities[128];
uint8_t n_pressed;
// here it will take a while before an overflow smashes everything :-)
uint64_t time_tokens[128];
uint64_t time_token_next;
} bwp_note_track;
Note tracking data:
by pitch: list of pressed notes ordered by increasing pitch;by time: list of pressed notes ordered by time (first to last);by pitch_elems: potential elements of by_pitch, where the array index corresponds to the note number;by time_elems: potential elements of by_time, where the array index corresponds to the note number;pressed: whether each note is pressed, where the array index corresponds to the note number;velocities: last note on/off velocities in [0.f, 1.f] or otherwise negative to indicate unknown / not available, where the array index corresponds to the note number;n_pressed: number of currently pressed notes;time_tokens: numbers representing the time order in which notes are pressed, where the array index corresponds to the note number (only valid for notes that are currently pressed);time_token_next: next time token (sequential, increasing take-a-number system).static inline void bwp_note_track_reset(
bwp_note_track * BW_RESTRICT track);
Resets the note tracker to its initial state (all notes off, next time token is 1).
static inline void bwp_note_track_process_on(
bwp_note_track * BW_RESTRICT track,
unsigned char note,
float velocity);
Feeds track with a note on event with the given note number and velocity.
static inline void bwp_note_track_process_off(
bwp_note_track * BW_RESTRICT track,
unsigned char note,
float velocity);
Feeds track with a note off event with the given note number and velocity.
#ifdef BW_NOTE_QUEUE_H
static inline void bwp_note_track_fill_queue(
const bwp_note_track * BW_RESTRICT track,
bw_note_queue * BW_RESTRICT queue);
#endif
Adds note on events to queue corresponding to all pressed notes in track following time order.
Only available if bw_note_queue is included first.
static inline char bwp_note_track_is_valid(
const bwp_note_track * BW_RESTRICT track);
Tries to determine whether track 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.
track must at least point to a readable memory block of size greater than or equal to that of bwp_note_track.
class NoteTrack {
public:
NoteTrack();
void processOn(
unsigned char note,
float velocity);
void processOff(
unsigned char note,
float velocity);
#ifdef BW_NOTE_QUEUE_H
void fillQueue(
bw_note_queue * BW_RESTRICT queue);
void fillQueue(
Brickworks::NoteQueue * BW_RESTRICT queue);
#endif
bwp_note_track track;
};
bwp_note_track_fill_queue() and optional dependency on bw_note_queue.bwp_note_track_process_off() and bwp_note_track_is_valid().