Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
MidiEventVector Class Referencefinal

A lock-free thread-safe vector of MidiEvents. More...

#include <src/gui/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.
 
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, 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_file (MIDI_FILE *mf, int midi_track) const
 
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)
 

Detailed Description

A lock-free thread-safe vector of MidiEvents.

Not necessarily the best implementation, but it's good enough for now.

Definition at line 92 of file midi_event.h.

Member Typedef Documentation

◆ ChordDescriptor

◆ ConstIterator

using MidiEventVector::ConstIterator = std::vector<MidiEvent>::const_iterator

Definition at line 101 of file midi_event.h.

◆ Iterator

using MidiEventVector::Iterator = std::vector<MidiEvent>::iterator

Definition at line 100 of file midi_event.h.

Constructor & Destructor Documentation

◆ MidiEventVector()

MidiEventVector::MidiEventVector ( )
inline

Definition at line 95 of file midi_event.h.

Member Function Documentation

◆ add_cc_volume()

void MidiEventVector::add_cc_volume ( midi_byte_t channel,
midi_byte_t volume,
midi_time_t time )

Add CC volume event.

TODO

◆ add_control_change()

void 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.

Parameters
channelMIDI channel starting from 1.

◆ add_event_from_buf()

void 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.

◆ add_note_off()

void 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.

Parameters
channelMIDI channel starting from 1.
queuedAdd to queued events instead.

◆ add_note_on()

void 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.

Parameters
channelMIDI channel starting from 1.
queuedAdd to queued events instead.

◆ add_pitchbend()

void MidiEventVector::add_pitchbend ( midi_byte_t channel,
uint32_t pitchbend,
midi_time_t time )

Adds a control event to the given MidiEvents.

Parameters
channelMIDI channel starting from 1.
pitchbend0 to 16384.

◆ add_simple()

void MidiEventVector::add_simple ( midi_byte_t byte1,
midi_byte_t byte2,
midi_byte_t byte3,
midi_time_t time )
inline

Definition at line 342 of file midi_event.h.

◆ add_song_pos()

void MidiEventVector::add_song_pos ( int64_t total_sixteenths,
midi_time_t time )

Adds a song position event to the queue.

Parameters
total_sixteenthsTotal sixteenths.

◆ append()

void MidiEventVector::append ( const MidiEventVector & src,
nframes_t local_offset,
nframes_t nframes )

Appends the events from src.

Parameters
local_offsetThe start frame offset from 0 in this cycle.
nframesNumber of frames to process.

◆ append_w_filter()

void 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.

Parameters
channelsAllowed channels (array of 16 booleans).
local_offsetThe local offset from 0 in this cycle.
nframesNumber of frames to process.

◆ at()

MidiEvent MidiEventVector::at ( size_t index) const
inline

Definition at line 186 of file midi_event.h.

◆ back()

MidiEvent MidiEventVector::back ( ) const
inline

Definition at line 180 of file midi_event.h.

◆ begin() [1/2]

Iterator MidiEventVector::begin ( )
inline

Definition at line 104 of file midi_event.h.

◆ begin() [2/2]

ConstIterator MidiEventVector::begin ( ) const
inline

Definition at line 122 of file midi_event.h.

◆ capacity()

size_t MidiEventVector::capacity ( ) const
inline

Definition at line 214 of file midi_event.h.

◆ clear()

void MidiEventVector::clear ( )
inline

Definition at line 162 of file midi_event.h.

◆ empty()

bool MidiEventVector::empty ( ) const
inline

Definition at line 303 of file midi_event.h.

◆ end() [1/2]

Iterator MidiEventVector::end ( )
inline

Definition at line 110 of file midi_event.h.

◆ end() [2/2]

ConstIterator MidiEventVector::end ( ) const
inline

Definition at line 128 of file midi_event.h.

◆ erase()

void MidiEventVector::erase ( Iterator it,
Iterator it_end )
inline

Definition at line 116 of file midi_event.h.

◆ front()

MidiEvent MidiEventVector::front ( ) const
inline

Definition at line 174 of file midi_event.h.

◆ has_any()

bool MidiEventVector::has_any ( ) const
inline

Definition at line 302 of file midi_event.h.

◆ panic_without_lock()

void MidiEventVector::panic_without_lock ( )
inline

Adds a note off message to every MIDI channel.

Definition at line 372 of file midi_event.h.

◆ pop_back()

MidiEvent MidiEventVector::pop_back ( )
inline

Definition at line 154 of file midi_event.h.

◆ pop_front()

MidiEvent MidiEventVector::pop_front ( )
inline

Definition at line 146 of file midi_event.h.

◆ push_back() [1/2]

void MidiEventVector::push_back ( const MidiEvent & ev)
inline

Definition at line 134 of file midi_event.h.

◆ push_back() [2/2]

void MidiEventVector::push_back ( const std::vector< MidiEvent > & events)
inline

Definition at line 140 of file midi_event.h.

◆ remove()

void MidiEventVector::remove ( const MidiEvent & event)
inline

Removes all events that match event.

Definition at line 209 of file midi_event.h.

◆ remove_if()

void MidiEventVector::remove_if ( std::function< bool(const MidiEvent &)> predicate)
inline

Definition at line 198 of file midi_event.h.

◆ size()

size_t MidiEventVector::size ( ) const
inline

Definition at line 168 of file midi_event.h.

◆ swap()

void MidiEventVector::swap ( MidiEventVector & other)
inline

Definition at line 192 of file midi_event.h.

◆ transform_chord_and_append()

void MidiEventVector::transform_chord_and_append ( MidiEventVector & src,
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.


The documentation for this class was generated from the following file: