Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
midi_port.h
1// SPDX-FileCopyrightText: © 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/midi_event.h"
7#include "dsp/port.h"
8#include "utils/icloneable.h"
9#include "utils/ring_buffer.h"
10
11namespace zrythm::dsp
12{
13
17class MidiPort final
18 : public QObject,
19 public Port,
20 public PortConnectionsCacheMixin<MidiPort>,
22{
23 Q_OBJECT
24 QML_ELEMENT
25 QML_UNCREATABLE ("")
26
27public:
28 MidiPort (utils::Utf8String label, PortFlow flow);
29
30 [[gnu::hot]] void process_block (
31 EngineProcessTimeInfo time_nfo,
32 const dsp::ITransport &transport) noexcept override;
33
35 const graph::GraphNode * node,
36 units::sample_rate_t sample_rate,
37 nframes_t max_block_length) override;
38
39 void release_resources () override;
40
41 void clear_buffer (std::size_t offset, std::size_t nframes) override;
42
43 friend void init_from (
44 MidiPort &obj,
45 const MidiPort &other,
46 utils::ObjectCloneType clone_type);
47
48private:
49 friend void to_json (nlohmann::json &j, const MidiPort &p)
50 {
51 to_json (j, static_cast<const Port &> (p));
52 }
53 friend void from_json (const nlohmann::json &j, MidiPort &p)
54 {
55 from_json (j, static_cast<Port &> (p));
56 }
57
58public:
63
74 std::unique_ptr<RingBuffer<dsp::MidiEvent>> midi_ring_;
75
76 BOOST_DESCRIBE_CLASS (MidiPort, (Port), (), (), ())
77};
78
79} // namespace zrythm::dsp
Interface for transport.
Definition itransport.h:17
Container for passing midi events through ports.
Definition midi_event.h:440
MIDI port specifics.
Definition midi_port.h:22
std::unique_ptr< RingBuffer< dsp::MidiEvent > > midi_ring_
Ring buffer for saving MIDI events to be used in the UI instead of directly accessing the events.
Definition midi_port.h:74
void release_resources() override
Called to release resources allocated by prepare_for_processing().
void prepare_for_processing(const graph::GraphNode *node, units::sample_rate_t sample_rate, nframes_t max_block_length) override
Called to allocate resources required for processing.
void clear_buffer(std::size_t offset, std::size_t nframes) override
Clears the port buffer.
dsp::MidiEvents midi_events_
Contains raw MIDI data (MIDI ports only).
Definition midi_port.h:62
A base class for ports used for connecting processors in the DSP graph.
Definition port.h:30
Represents a node in a DSP graph.
Definition graph_node.h:129
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38
uint32_t nframes_t
Frame count.
Definition types.h:58
Common struct to pass around during processing to avoid repeating the data in function arguments.
Definition types.h:133