Zrythm v2.0.0-alpha.1+31.4967fd053471
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
recording_midi_packet.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/midi_event_buffer.h"
7#include "utils/units.h"
8
9namespace zrythm::controllers
10{
11
13{
14 units::sample_t timeline_position;
15 bool transport_recording{};
16 units::sample_u32_t nframes;
17 dsp::MidiEventBuffer midi_events;
18
19 static void write_to_slot (
21 units::sample_t timeline_position,
22 bool transport_recording,
23 const dsp::MidiEventBuffer &events,
24 units::sample_u32_t nframes) noexcept [[clang::nonblocking]]
25 {
26 assert (slot.midi_events.capacity () > 0);
27 slot.timeline_position = timeline_position;
28 slot.transport_recording = transport_recording;
29 slot.nframes = nframes;
30 slot.midi_events.clear ();
31 for (const auto &ev : events)
32 {
33 slot.midi_events.push_back (ev.time (), ev.data ());
34 }
35 }
36
37 static void
38 copy_from (RecordingMidiPacket &slot, const RecordingMidiPacket &source)
39 [[clang::blocking]]
40 {
41 slot.timeline_position = source.timeline_position;
42 slot.transport_recording = source.transport_recording;
43 slot.nframes = source.nframes;
44 slot.midi_events.clear ();
45 for (const auto &ev : source.midi_events)
46 {
47 slot.midi_events.push_back (ev.time (), ev.data ());
48 }
49 }
50
51 static void
52 resize (RecordingMidiPacket &slot, units::sample_u32_t /*block_length*/)
53 {
55 }
56};
57}
Packed contiguous buffer for RT MIDI events.
static constexpr size_t kMaxReserveBytes
Max bytes to hold in queues.
size_t capacity() const noexcept
Bytes reserved in storage.
void reserve(size_t bytes=kMaxReserveBytes)
Pre-allocate internal byte storage (and scratch/index buffers).
void clear() noexcept
Reset buffer.
bool push_back(units::sample_u32_t time, std::span< const midi_byte_t > event_data) noexcept
Append an event.