4#ifndef __AUDIO_RTMIDI_DEVICE_H__
5#define __AUDIO_RTMIDI_DEVICE_H__
7#include "zrythm-config.h"
10#include "utils/monotonic_time_provider.h"
11#include "utils/ring_buffer.h"
25constexpr size_t MIDI_BUFFER_SIZE = 32768;
33 RTMIDI_DEVICE_FLOW_OUTPUT,
34 RTMIDI_DEVICE_FLOW_INPUT,
40 using TimestampGenerator = std::function<utils::MonotonicTime ()>;
41 using DeviceNameProvider = std::function<std::string ()>;
50 unsigned int device_id,
51 DeviceNameProvider device_name_provider,
52 std::string name =
"");
66 rtmidi_in_free (in_handle_);
70 rtmidi_out_free (out_handle_);
91 void start (TimestampGenerator timestamp_generator);
114 RtMidiInPtr in_handle_{};
117 RtMidiOutPtr out_handle_{};
123 RingBuffer<MidiEvent> midi_ring_{ 1024 };
127 MidiEventVector events_;
130 std::binary_semaphore midi_ring_sem_{ 1 };
132 TimestampGenerator timestamp_generator_;
134 DeviceNameProvider device_name_provider_;