Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
A lock-free thread-safe vector of MidiEvents. More...
#include <src/dsp/midi_event.h>
Public Types | |
using | ChordDescriptor = dsp::ChordDescriptor |
using | Iterator = std::vector<MidiEvent>::iterator |
using | ConstIterator = std::vector<MidiEvent>::const_iterator |
Public Member Functions | |
Iterator | begin () |
Iterator | end () |
void | erase (Iterator it, Iterator it_end) |
ConstIterator | begin () const |
ConstIterator | end () const |
void | push_back (const MidiEvent &ev) |
void | push_back (const std::vector< MidiEvent > &events) |
MidiEvent | pop_front () |
MidiEvent | pop_back () |
void | clear () |
size_t | size () const |
MidiEvent | front () const |
MidiEvent | back () const |
MidiEvent | at (size_t index) const |
void | swap (MidiEventVector &other) |
void | remove_if (std::function< bool(const MidiEvent &)> predicate) |
void | remove (const MidiEvent &event) |
Removes all events that match event . | |
void | foreach_event (std::function< void(const MidiEvent &)> func) const |
size_t | capacity () const |
void | print () const |
void | append_w_filter (const MidiEventVector &src, std::optional< std::array< bool, 16 > > channels, nframes_t local_offset, nframes_t nframes) |
Appends the events from src . | |
void | append (const MidiEventVector &src, nframes_t local_offset, nframes_t nframes) |
Appends the events from src . | |
void | transform_chord_and_append (MidiEventVector &src, std::function< const ChordDescriptor *(midi_byte_t)> note_number_to_chord_descriptor, midi_byte_t velocity_to_use, nframes_t local_offset, nframes_t nframes) |
Transforms the given MIDI input to the MIDI notes of the corresponding chord. | |
void | add_note_on (midi_byte_t channel, midi_byte_t note_pitch, midi_byte_t velocity, midi_time_t time) |
Adds a note on event to the given MidiEvents. | |
void | add_note_ons_from_chord_descr (const ChordDescriptor &descr, midi_byte_t channel, midi_byte_t velocity, midi_time_t time) |
Adds a note on for each note in the chord. | |
void | add_note_offs_from_chord_descr (const ChordDescriptor &descr, midi_byte_t channel, midi_time_t time) |
Adds a note off for each note in the chord. | |
void | add_cc_volume (midi_byte_t channel, midi_byte_t volume, midi_time_t time) |
Add CC volume event. | |
bool | has_any () const |
bool | empty () const |
void | add_event_from_buf (midi_time_t time, midi_byte_t *buf, int buf_size) |
Parses a MidiEvent from a raw MIDI buffer. | |
void | add_note_off (midi_byte_t channel, midi_byte_t note_pitch, midi_time_t time) |
Adds a note off event to the given MidiEvents. | |
void | add_control_change (midi_byte_t channel, midi_byte_t controller, midi_byte_t control, midi_time_t time) |
Adds a control event to the given MidiEvents. | |
void | add_song_pos (int64_t total_sixteenths, midi_time_t time) |
Adds a song position event to the queue. | |
void | add_raw (uint8_t *buf, size_t buf_sz, midi_time_t time) |
void | add_simple (midi_byte_t byte1, midi_byte_t byte2, midi_byte_t byte3, midi_time_t time) |
void | add_pitchbend (midi_byte_t channel, uint32_t pitchbend, midi_time_t time) |
Adds a control event to the given MidiEvents. | |
void | add_channel_pressure (midi_byte_t channel, midi_byte_t value, midi_time_t time) |
void | add_all_notes_off (midi_byte_t channel, midi_time_t time, bool with_lock) |
Queues MIDI note off to event queue. | |
void | panic_without_lock () |
Adds a note off message to every MIDI channel. | |
void | panic () |
Must only be called from the UI thread. | |
void | write_to_midi_sequence (juce::MidiMessageSequence &sequence, bool update_matched_pairs) const |
Writes the events to a MIDI sequence. | |
void | clear_duplicates () |
Clears duplicates. | |
void | sort () |
Sorts the MidiEvents by time. | |
void | set_channel (midi_byte_t channel) |
Sets the given MIDI channel on all applicable MIDI events. | |
void | delete_event (const MidiEvent *ev) |
A lock-free thread-safe vector of MidiEvents.
Not necessarily the best implementation, but it's good enough for now.
Definition at line 77 of file midi_event.h.
Definition at line 82 of file midi_event.h.
using zrythm::dsp::MidiEventVector::ConstIterator = std::vector<MidiEvent>::const_iterator |
Definition at line 86 of file midi_event.h.
using zrythm::dsp::MidiEventVector::Iterator = std::vector<MidiEvent>::iterator |
Definition at line 85 of file midi_event.h.
|
inline |
Definition at line 80 of file midi_event.h.
void zrythm::dsp::MidiEventVector::add_cc_volume | ( | midi_byte_t | channel, |
midi_byte_t | volume, | ||
midi_time_t | time ) |
Add CC volume event.
TODO
void zrythm::dsp::MidiEventVector::add_control_change | ( | midi_byte_t | channel, |
midi_byte_t | controller, | ||
midi_byte_t | control, | ||
midi_time_t | time ) |
Adds a control event to the given MidiEvents.
channel | MIDI channel starting from 1. |
void zrythm::dsp::MidiEventVector::add_event_from_buf | ( | midi_time_t | time, |
midi_byte_t * | buf, | ||
int | buf_size ) |
Parses a MidiEvent from a raw MIDI buffer.
This must be a full 3-byte message. If in 'running status' mode, the caller is responsible for prepending the status byte.
void zrythm::dsp::MidiEventVector::add_note_off | ( | midi_byte_t | channel, |
midi_byte_t | note_pitch, | ||
midi_time_t | time ) |
Adds a note off event to the given MidiEvents.
channel | MIDI channel starting from 1. |
queued | Add to queued events instead. |
void zrythm::dsp::MidiEventVector::add_note_on | ( | midi_byte_t | channel, |
midi_byte_t | note_pitch, | ||
midi_byte_t | velocity, | ||
midi_time_t | time ) |
Adds a note on event to the given MidiEvents.
channel | MIDI channel starting from 1. |
queued | Add to queued events instead. |
void zrythm::dsp::MidiEventVector::add_pitchbend | ( | midi_byte_t | channel, |
uint32_t | pitchbend, | ||
midi_time_t | time ) |
Adds a control event to the given MidiEvents.
channel | MIDI channel starting from 1. |
pitchbend | 0 to 16384. |
|
inline |
Definition at line 334 of file midi_event.h.
void zrythm::dsp::MidiEventVector::add_song_pos | ( | int64_t | total_sixteenths, |
midi_time_t | time ) |
Adds a song position event to the queue.
total_sixteenths | Total sixteenths. |
void zrythm::dsp::MidiEventVector::append | ( | const MidiEventVector & | src, |
nframes_t | local_offset, | ||
nframes_t | nframes ) |
Appends the events from src
.
local_offset | The start frame offset from 0 in this cycle. |
nframes | Number of frames to process. |
void zrythm::dsp::MidiEventVector::append_w_filter | ( | const MidiEventVector & | src, |
std::optional< std::array< bool, 16 > > | channels, | ||
nframes_t | local_offset, | ||
nframes_t | nframes ) |
Appends the events from src
.
channels | Allowed channels (array of 16 booleans). |
local_offset | The local offset from 0 in this cycle. |
nframes | Number of frames to process. |
|
inline |
Definition at line 171 of file midi_event.h.
|
inline |
Definition at line 165 of file midi_event.h.
|
inline |
Definition at line 89 of file midi_event.h.
|
inline |
Definition at line 107 of file midi_event.h.
|
inline |
Definition at line 203 of file midi_event.h.
|
inline |
Definition at line 147 of file midi_event.h.
|
inline |
Definition at line 295 of file midi_event.h.
|
inline |
Definition at line 95 of file midi_event.h.
|
inline |
Definition at line 113 of file midi_event.h.
|
inline |
Definition at line 101 of file midi_event.h.
|
inline |
Definition at line 197 of file midi_event.h.
|
inline |
Definition at line 159 of file midi_event.h.
|
inline |
Definition at line 294 of file midi_event.h.
|
inline |
Adds a note off message to every MIDI channel.
Definition at line 364 of file midi_event.h.
|
inline |
Definition at line 139 of file midi_event.h.
|
inline |
Definition at line 131 of file midi_event.h.
|
inline |
Definition at line 119 of file midi_event.h.
|
inline |
Definition at line 125 of file midi_event.h.
|
inline |
Removes all events that match event
.
Definition at line 192 of file midi_event.h.
|
inline |
Definition at line 183 of file midi_event.h.
|
inline |
Definition at line 153 of file midi_event.h.
|
inline |
Definition at line 177 of file midi_event.h.
void zrythm::dsp::MidiEventVector::transform_chord_and_append | ( | MidiEventVector & | src, |
std::function< const ChordDescriptor *(midi_byte_t)> | note_number_to_chord_descriptor, | ||
midi_byte_t | velocity_to_use, | ||
nframes_t | local_offset, | ||
nframes_t | nframes ) |
Transforms the given MIDI input to the MIDI notes of the corresponding chord.
Only C0~B0 are considered.
void zrythm::dsp::MidiEventVector::write_to_midi_sequence | ( | juce::MidiMessageSequence & | sequence, |
bool | update_matched_pairs ) const |
Writes the events to a MIDI sequence.
This assumes that the event timestamps are in ticks.
sequence | |
update_matched_pairs | If true, ensures there are note off events for every note on event. |