7#include "dsp/graph_node.h"
8#include "dsp/parameter.h"
9#include "dsp/port_all.h"
40 float automated_value{};
41 float modulated_value{};
46 const auto &
changes ()
const {
return changes_; }
49 friend class ProcessorBase;
52 std::vector<Change> changes_;
55 std::vector<float> prev_values_;
59 void prepare (
size_t count)
61 prev_values_.assign (count, -1.f);
63 changes_.reserve (count);
76 prev_values_[i] = modulated;
81 void clear () { changes_.clear (); }
85 struct BaseProcessingCache
87 units::sample_rate_t sample_rate_;
88 units::sample_u32_t max_block_length_{};
90 std::vector<dsp::ProcessorParameter *> live_params_;
91 std::vector<dsp::PortPtrVariant> live_input_ports_;
92 std::vector<dsp::PortPtrVariant> live_output_ports_;
94 ParameterChangeTracker change_tracker_;
103 bool is_processing_ =
false;
109 dsp::PortRegistry &port_registry_;
124 void add_input_port (
const dsp::PortUuidReference &uuid);
125 void add_output_port (
const dsp::PortUuidReference &uuid);
126 void add_parameter (
const dsp::ProcessorParameterUuidReference &uuid);
128 auto &get_input_ports ()
const {
return input_ports_; }
129 auto &get_output_ports ()
const {
return output_ports_; }
130 auto &get_parameters ()
const {
return params_; }
140 assert (processing_caches_ && processing_caches_->is_processing_);
141 return processing_caches_->change_tracker_;
161 const dsp::TempoMap &tempo_map)
noexcept final;
164 units::sample_rate_t sample_rate,
165 units::sample_u32_t max_block_length)
final;
177 dsp::graph::EngineProcessTimeInfo time_nfo,
179 const dsp::TempoMap &tempo_map) noexcept [[clang::nonblocking]];
181 virtual
void custom_prepare_for_processing (
182 const graph::GraphNode * node,
183 units::sample_rate_t sample_rate,
184 units::sample_u32_t max_block_length)
188 virtual void custom_release_resources () { }
190 auto dependencies ()
const {
return dependencies_; }
193 static constexpr auto kProcessorNameKey =
"processorName"sv;
194 static constexpr auto kInputPortsKey =
"inputPorts"sv;
195 static constexpr auto kOutputPortsKey =
"outputPorts"sv;
196 static constexpr auto kParametersKey =
"parameters"sv;
197 friend void to_json (nlohmann::json &j,
const ProcessorBase &p);
198 friend void from_json (
const nlohmann::json &j, ProcessorBase &p);
201 ProcessorBaseDependencies dependencies_;
202 utils::Utf8String name_;
203 std::vector<dsp::PortUuidReference> input_ports_;
204 std::vector<dsp::PortUuidReference> output_ports_;
205 std::vector<dsp::ProcessorParameterUuidReference> params_;
208 std::unique_ptr<BaseProcessingCache> processing_caches_;
210 BOOST_DESCRIBE_CLASS (ProcessorBase, (), (), (), (name_))
A base class for processors in the DSP graph.
void process_block(dsp::graph::EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) noexcept final
Calls custom_process_block() internally after processing all the parameters.
const ParameterChangeTracker & change_tracker() const noexcept
Returns the change tracker.
void release_resources() final
Called to release resources allocated by prepare_for_processing().
void prepare_for_processing(const graph::GraphNode *node, units::sample_rate_t sample_rate, units::sample_u32_t max_block_length) final
Called to allocate resources required for processing.
void set_name(const utils::Utf8String &name)
Set a custom name to be used in the DSP graph.
utils::Utf8String get_node_name() const final
Returns a human friendly name of the node.
virtual void custom_process_block(dsp::graph::EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) noexcept
Custom processor logic after processing all owned parameters.
Helper class to insert nodes and connections pertaining to a ProcessorBase instance to a graph.
Wrapper over a Uuid registry that provides (slow) lookup by unique ID.
Processor parameter that accepts automation and modulation sources and integrates with QML and the DS...
Q_INVOKABLE float currentValue() const
Returns the current (normalized) value after any automation and modulation has been applied.
Q_INVOKABLE float valueAfterAutomationApplied() const
Returns the value after automation, but before modulation has been applied.
Represents a node in a DSP graph.
The Graph class represents a graph of DSP nodes.
Interface for objects that can be processed in the DSP graph.
Lightweight UTF-8 string wrapper with safe conversions.
constexpr bool floats_equal(T a, T b)
Checks if 2 floating point numbers are equal.
Tracks parameter value changes across processing cycles.
const auto & changes() const
Returns the changes accumulated during the current cycle.
Common struct to pass around during processing to avoid repeating the data in function arguments.