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-2025 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) noexcept override;
65
66 void custom_prepare_for_processing (
67 const graph::GraphNode * node,
68 units::sample_rate_t sample_rate,
69 nframes_t max_block_length) override;
70
71 void custom_release_resources () override;
72
73 // ============================================================================
74
75 friend void init_from (
76 ModulatorMacroProcessor &obj,
77 const ModulatorMacroProcessor &other,
78 utils::ObjectCloneType clone_type);
79
82 {
83 return *get_input_ports ().front ().get_object_as<dsp::CVPort> ();
84 }
85
92 {
93 return *get_output_ports ().front ().get_object_as<dsp::CVPort> ();
94 }
95
98 {
99 return *get_parameters ().front ().get_object_as<dsp::ProcessorParameter> ();
100 }
101
102private:
103 static constexpr auto kNameKey = "name"sv;
104 friend void to_json (nlohmann::json &j, const ModulatorMacroProcessor &p)
105 {
106 to_json (j, static_cast<const dsp::ProcessorBase &> (p));
107 j[kNameKey] = p.name_;
108 }
109 friend void from_json (const nlohmann::json &j, ModulatorMacroProcessor &p)
110 {
111 from_json (j, static_cast<dsp::ProcessorBase &> (p));
112 j.at (kNameKey).get_to (p.name_);
113 }
114
115private:
116 ProcessorBaseDependencies dependencies_;
117
124 utils::Utf8String name_;
125
126 // Processing caches
127 std::unique_ptr<ProcessingCaches> processing_caches_;
128
129 BOOST_DESCRIBE_CLASS (ModulatorMacroProcessor, (), (), (), (name_))
130};
131
132} // 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.
auto & get_cv_in_port()
CV input port for connecting CV signals to.
auto & get_cv_out_port()
CV output after macro is applied.
void custom_process_block(EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport) noexcept override
Custom processor logic after processing all owned parameters.
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:225
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