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);
71 prev_values_[i] = modulated;
76 void clear () { changes_.clear (); }
80 struct BaseProcessingCache
82 units::sample_rate_t sample_rate_;
83 units::sample_u32_t max_block_length_{};
85 std::vector<dsp::ProcessorParameter *> live_params_;
86 std::vector<dsp::PortPtrVariant> live_input_ports_;
87 std::vector<dsp::PortPtrVariant> live_output_ports_;
89 ParameterChangeTracker change_tracker_;
98 bool is_processing_ =
false;
104 dsp::PortRegistry &port_registry_;
119 void add_input_port (
const dsp::PortUuidReference &uuid);
120 void add_output_port (
const dsp::PortUuidReference &uuid);
121 void add_parameter (
const dsp::ProcessorParameterUuidReference &uuid);
123 auto &get_input_ports ()
const {
return input_ports_; }
124 auto &get_output_ports ()
const {
return output_ports_; }
125 auto &get_parameters ()
const {
return params_; }
135 assert (processing_caches_ && processing_caches_->is_processing_);
136 return processing_caches_->change_tracker_;
156 const dsp::TempoMap &tempo_map)
noexcept final;
159 units::sample_rate_t sample_rate,
160 units::sample_u32_t max_block_length)
final;
172 dsp::graph::ProcessBlockInfo time_nfo,
174 const dsp::TempoMap &tempo_map) noexcept [[clang::nonblocking]];
176 virtual
void custom_prepare_for_processing (
177 const graph::GraphNode * node,
178 units::sample_rate_t sample_rate,
179 units::sample_u32_t max_block_length)
183 virtual void custom_release_resources () { }
185 auto dependencies ()
const {
return dependencies_; }
188 static constexpr auto kProcessorNameKey =
"processorName"sv;
189 static constexpr auto kInputPortsKey =
"inputPorts"sv;
190 static constexpr auto kOutputPortsKey =
"outputPorts"sv;
191 static constexpr auto kParametersKey =
"parameters"sv;
192 friend void to_json (nlohmann::json &j,
const ProcessorBase &p);
193 friend void from_json (
const nlohmann::json &j, ProcessorBase &p);
196 ProcessorBaseDependencies dependencies_;
197 utils::Utf8String name_;
198 std::vector<dsp::PortUuidReference> input_ports_;
199 std::vector<dsp::PortUuidReference> output_ports_;
200 std::vector<dsp::ProcessorParameterUuidReference> params_;
203 std::unique_ptr<BaseProcessingCache> processing_caches_;
205 BOOST_DESCRIBE_CLASS (ProcessorBase, (), (), (), (name_))
A base class for processors in the DSP graph.
virtual void custom_process_block(dsp::graph::ProcessBlockInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) noexcept
Custom processor logic after processing all owned 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 process_block(dsp::graph::ProcessBlockInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) noexcept final
Calls custom_process_block() internally after processing all the parameters.
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.
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.