Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
modulator_macro_processor.h
1// SPDX-FileCopyrightText: © 2021-2022, 2024-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/graph_node.h"
7#include "dsp/parameter.h"
8#include "dsp/port_fwd.h"
9#include "dsp/processor_base.h"
10#include "utils/types.h"
11
12namespace zrythm::dsp
13{
14
24class ModulatorMacroProcessor final : public QObject, public dsp::ProcessorBase
25{
26 Q_OBJECT
27 Q_PROPERTY (QString name READ name CONSTANT)
28 QML_ELEMENT
29 QML_UNCREATABLE ("")
30
31 struct ProcessingCaches
32 {
33 dsp::ProcessorParameter * macro_param_{};
34 dsp::CVPort * cv_in_{};
35 dsp::CVPort * cv_out_{};
36 };
37
38public:
39 ModulatorMacroProcessor (
40 ProcessorBaseDependencies dependencies,
41 int idx,
42 QObject * parent = nullptr);
43
44 // ========================================================================
45 // QML Interface
46 // ========================================================================
47
48 QString name () const { return name_.to_qstring (); }
49
50 // ========================================================================
51
52 utils::Utf8String get_full_designation_for_port (const dsp::Port &port) const;
53
54 auto get_name () const { return name_; }
55
56 // void set_name (const utils::Utf8String &name) { name_ = name; }
57
58 // ============================================================================
59 // ProcessorBase Interface
60 // ============================================================================
61
63 EngineProcessTimeInfo time_nfo,
64 const dsp::ITransport &transport,
65 const dsp::TempoMap &tempo_map) noexcept override;
66
67 void custom_prepare_for_processing (
68 const graph::GraphNode * node,
69 units::sample_rate_t sample_rate,
70 nframes_t max_block_length) override;
71
72 void custom_release_resources () override;
73
74 // ============================================================================
75
76 friend void init_from (
77 ModulatorMacroProcessor &obj,
78 const ModulatorMacroProcessor &other,
79 utils::ObjectCloneType clone_type);
80
83 {
84 return *get_input_ports ().front ().get_object_as<dsp::CVPort> ();
85 }
86
93 {
94 return *get_output_ports ().front ().get_object_as<dsp::CVPort> ();
95 }
96
99 {
100 return *get_parameters ().front ().get_object_as<dsp::ProcessorParameter> ();
101 }
102
103private:
104 static constexpr auto kNameKey = "name"sv;
105 friend void to_json (nlohmann::json &j, const ModulatorMacroProcessor &p);
106 friend void from_json (const nlohmann::json &j, ModulatorMacroProcessor &p);
107
108private:
109 ProcessorBaseDependencies dependencies_;
110
119 utils::Utf8String name_;
120
121 // Processing caches
122 std::unique_ptr<ProcessingCaches> processing_caches_;
123
124 BOOST_DESCRIBE_CLASS (ModulatorMacroProcessor, (), (), (), (name_))
125};
126
127} // namespace zrythm::dsp
Control Voltage port.
Definition cv_port.h:26
Interface for transport.
Definition itransport.h:17
Modulator macro button processor.
auto & get_macro_param()
Control port controlling the amount.
void custom_process_block(EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) noexcept override
Custom processor logic after processing all owned parameters.
auto & get_cv_in_port()
CV input port for connecting CV signals to.
auto & get_cv_out_port()
CV output after macro is applied.
A base class for ports used for connecting processors in the DSP graph.
Definition port.h:30
A base class for processors in the DSP graph.
Processor parameter that accepts automation and modulation sources and integrates with QML and the DS...
Definition parameter.h:220
Represents a node in a DSP graph.
Definition graph_node.h:131
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