Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
midi_panic_processor.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <atomic>
7
8#include "dsp/processor_base.h"
9
10namespace zrythm::dsp
11{
12
16class MidiPanicProcessor final : public QObject, public dsp::ProcessorBase
17{
18 Q_OBJECT
19
20public:
21 MidiPanicProcessor (
22 utils::IObjectRegistry &registry,
23 QObject * parent = nullptr);
24
30 void request_panic () { panic_.store (true); }
31
32 // ============================================================================
33 // ProcessorBase Interface
34 // ============================================================================
35
38 const dsp::ITransport &transport,
39 const dsp::TempoMap &tempo_map) noexcept override
40 {
41 const auto panic = panic_.exchange (false);
42 if (!panic)
43 return;
44
45 // queue panic event
46 midi_out_->midi_events_.queued_events_.panic_without_lock (
47 time_nfo.buffer_offset_);
48 }
49
50 void custom_prepare_for_processing (
51 const graph::GraphNode * node,
52 units::sample_rate_t sample_rate,
53 units::sample_u32_t max_block_length) override
54 {
55 midi_out_ = get_output_ports ().front ().get_object_as<dsp::MidiPort> ();
56 }
57
58 void custom_release_resources () override { midi_out_ = nullptr; }
59
60 // ============================================================================
61
62private:
63 std::atomic_bool panic_;
64
65 // Processing caches
66 dsp::MidiPort * midi_out_{};
67};
68} // namespace zrythm::dsp
Interface for transport.
Definition itransport.h:16
void custom_process_block(dsp::graph::ProcessBlockInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) noexcept override
Custom processor logic after processing all owned parameters.
void request_panic()
Request panic messages to be sent.
MIDI port specifics.
Definition midi_port.h:21
A base class for processors in the DSP graph.
Represents a node in a DSP graph.
Definition graph_node.h:173
Abstract interface for a UUID-keyed object registry.
Common struct to pass around during processing to avoid repeating the data in function arguments.
Definition graph_node.h:51