73class MidiEventVector final
76 MidiEventVector () { events_.reserve (MAX_MIDI_EVENTS); }
81 using Iterator = std::vector<MidiEvent>::iterator;
82 using ConstIterator = std::vector<MidiEvent>::const_iterator;
87 const std::lock_guard<crill::spin_mutex> lock (lock_);
88 return events_.begin ();
93 const std::lock_guard<crill::spin_mutex> lock (lock_);
94 return events_.end ();
97 void erase (Iterator it, Iterator it_end)
99 const std::lock_guard<crill::spin_mutex> lock (lock_);
100 events_.erase (it, it_end);
103 ConstIterator begin ()
const
105 const std::lock_guard<crill::spin_mutex> lock (lock_);
106 return events_.begin ();
109 ConstIterator end ()
const
111 const std::lock_guard<crill::spin_mutex> lock (lock_);
112 return events_.end ();
117 const std::lock_guard<crill::spin_mutex> lock (lock_);
118 events_.push_back (ev);
121 void push_back (
const std::vector<MidiEvent> &events)
123 const std::lock_guard<crill::spin_mutex> lock (lock_);
124 events_.insert (events_.end (), events.begin (), events.end ());
129 const std::lock_guard<crill::spin_mutex> lock (lock_);
131 events_.erase (events_.begin ());
137 const std::lock_guard<crill::spin_mutex> lock (lock_);
145 const std::lock_guard<crill::spin_mutex> lock (lock_);
151 const std::lock_guard<crill::spin_mutex> lock (lock_);
152 return events_.size ();
157 const std::lock_guard<crill::spin_mutex> lock (lock_);
158 return events_.front ();
163 const std::lock_guard<crill::spin_mutex> lock (lock_);
164 return events_.back ();
169 const std::lock_guard<crill::spin_mutex> lock (lock_);
170 return events_.at (index);
173 void swap (MidiEventVector &other)
175 const std::lock_guard<crill::spin_mutex> lock (lock_);
176 events_.swap (other.events_);
179 void remove_if (std::function<
bool (
const MidiEvent &)> predicate)
181 const std::lock_guard<crill::spin_mutex> lock (lock_);
185 std::remove_if (events_.begin (), events_.end (), std::move (predicate));
186 events_.erase (it, events_.end ());
194 remove_if ([&event] (
const MidiEvent &e) {
return e == event; });
197 void foreach_event (std::function<
void (
const MidiEvent &)> func)
const
199 const std::lock_guard<crill::spin_mutex> lock (lock_);
200 std::ranges::for_each (events_, func);
203 size_t capacity ()
const
205 const std::lock_guard<crill::spin_mutex> lock (lock_);
206 return events_.capacity ();
219 const MidiEventVector &src,
220 std::optional<std::array<bool, 16>> channels,
221 units::sample_u32_t local_offset,
222 units::sample_u32_t nframes);
231 const MidiEventVector &src,
232 units::sample_u32_t local_offset,
233 units::sample_u32_t nframes);
235 using NotePitchToChordDescriptorFunc =
236 std::function<
const ChordDescriptor *(
midi_byte_t)>;
245 const MidiEventVector &src,
246 NotePitchToChordDescriptorFunc note_number_to_chord_descriptor,
248 units::sample_u32_t local_offset,
249 units::sample_u32_t nframes);
261 units::sample_u32_t time);
267 const ChordDescriptor &descr,
270 units::sample_u32_t time);
276 const ChordDescriptor &descr,
278 units::sample_u32_t time);
288 units::sample_u32_t time);
297 bool has_note_on (
bool check_main,
bool check_queued);
300 bool has_any ()
const {
return !empty (); }
301 bool empty ()
const {
return size () == 0; }
321 units::sample_u32_t time);
332 units::sample_u32_t time);
339 void add_song_pos (int64_t total_sixteenths, units::sample_u32_t time);
341 void add_raw (
const uint8_t * buf,
size_t buf_sz, units::sample_u32_t time);
347 units::sample_u32_t time)
349 push_back (
MidiEvent (byte1, byte2, byte3, time));
361 units::sample_u32_t time);
363 void add_channel_pressure (
366 units::sample_u32_t time);
373 units::sample_u32_t time,
402 juce::MidiMessageSequence &sequence,
403 bool update_matched_pairs)
const;
414 bool check_for_note_on (
int note);
420 bool delete_note_on (
int note);
434 void delete_event (
const MidiEvent * ev);
437 std::vector<MidiEvent> events_;
440 mutable crill::spin_mutex lock_;