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/processor_base.h"
7
8namespace zrythm::dsp
9{
10
20class ModulatorMacroProcessor final : public QObject, public dsp::ProcessorBase
21{
22 Q_OBJECT
23 Q_PROPERTY (QString name READ name CONSTANT)
24 QML_ELEMENT
25 QML_UNCREATABLE ("")
26
27 struct ProcessingCaches
28 {
29 dsp::ProcessorParameter * macro_param_{};
30 dsp::CVPort * cv_in_{};
31 dsp::CVPort * cv_out_{};
32 };
33
34public:
35 ModulatorMacroProcessor (
36 ProcessorBaseDependencies dependencies,
37 int idx,
38 QObject * parent = nullptr);
39
40 // ========================================================================
41 // QML Interface
42 // ========================================================================
43
44 QString name () const { return name_.to_qstring (); }
45
46 // ========================================================================
47
48 utils::Utf8String get_full_designation_for_port (const dsp::Port &port) const;
49
50 auto get_name () const { return name_; }
51
52 // void set_name (const utils::Utf8String &name) { name_ = name; }
53
54 // ============================================================================
55 // ProcessorBase Interface
56 // ============================================================================
57
60 const dsp::ITransport &transport,
61 const dsp::TempoMap &tempo_map) noexcept override;
62
63 void custom_prepare_for_processing (
64 const graph::GraphNode * node,
65 units::sample_rate_t sample_rate,
66 units::sample_u32_t max_block_length) override;
67
68 void custom_release_resources () override;
69
70 // ============================================================================
71
72 friend void init_from (
73 ModulatorMacroProcessor &obj,
74 const ModulatorMacroProcessor &other,
75 utils::ObjectCloneType clone_type);
76
79 {
80 return *get_input_ports ().front ().get_object_as<dsp::CVPort> ();
81 }
82
89 {
90 return *get_output_ports ().front ().get_object_as<dsp::CVPort> ();
91 }
92
95 {
96 return *get_parameters ().front ().get_object_as<dsp::ProcessorParameter> ();
97 }
98
99private:
100 static constexpr auto kNameKey = "name"sv;
101 friend void to_json (nlohmann::json &j, const ModulatorMacroProcessor &p);
102 friend void from_json (const nlohmann::json &j, ModulatorMacroProcessor &p);
103
104private:
105 ProcessorBaseDependencies dependencies_;
106
115 utils::Utf8String name_;
116
117 // Processing caches
118 std::unique_ptr<ProcessingCaches> processing_caches_;
119
120 BOOST_DESCRIBE_CLASS (ModulatorMacroProcessor, (), (), (), (name_))
121};
122
123} // namespace zrythm::dsp
Control Voltage port.
Definition cv_port.h:26
Interface for transport.
Definition itransport.h:16
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(dsp::graph::EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) 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:29
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:167
Represents a node in a DSP graph.
Definition graph_node.h:160
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:37
Common struct to pass around during processing to avoid repeating the data in function arguments.
Definition graph_node.h:51