Vital
Loading...
Searching...
No Matches
vital::Operator Class Reference

Base class for operator nodes that perform arithmetic or other transformations in the processing graph. More...

#include <operators.h>

Inheritance diagram for vital::Operator:
vital::Processor vital::Add vital::BilinearInterpolate vital::Clamp vital::Interpolate vital::Inverse vital::LinearScale vital::ModulationSum vital::Multiply vital::Negate vital::SampleAndHoldBuffer vital::SmoothMultiply vital::Square vital::StereoEncoder vital::Subtract vital::TempoChooser vital::VariableAdd vital::cr::Add vital::cr::BilinearInterpolate vital::cr::Clamp vital::cr::Cube vital::cr::Cubic vital::cr::ExponentialScale vital::cr::FrequencyToPhase vital::cr::FrequencyToSamples vital::cr::Interpolate vital::cr::LowerBound vital::cr::MagnitudeScale vital::cr::MidiScale vital::cr::Multiply vital::cr::Quadratic vital::cr::Quart vital::cr::Quartic vital::cr::Root vital::cr::Square vital::cr::TimeToSamples vital::cr::UpperBound vital::cr::VariableAdd

Public Member Functions

 Operator (int num_inputs, int num_outputs, bool control_rate=false)
 Constructs an Operator with a specified number of inputs/outputs and control-rate setting.
 
force_inline bool hasEnoughInputs ()
 Checks if this Operator has at least one connected input.
 
void setEnabled ()
 Updates this operator’s enabled state based on connected inputs and external status.
 
void numInputsChanged () override
 Called when the number of inputs changes (e.g., dynamically connected or disconnected).
 
void enable (bool enable) override
 Enables or disables the Operator, storing the external enable state.
 
virtual bool hasState () const override
 Indicates whether this operator has internal state that must be preserved or reset.
 
- Public Member Functions inherited from vital::Processor
 Processor (int num_inputs, int num_outputs, bool control_rate=false, int max_oversample=1)
 Constructs a Processor with a given number of inputs/outputs and oversampling.
 
virtual ~Processor ()
 Virtual destructor.
 
virtual Processorclone () const =0
 Clones this Processor for polyphonic expansion. Must be overridden by subclasses.
 
virtual void process (int num_samples)=0
 Main processing function. Called by the ProcessorRouter.
 
virtual void processWithInput (const poly_float *audio_in, int num_samples)
 An optional processing function taking explicit input buffer. Fallback is an assertion failure (not supported).
 
virtual void init ()
 Called after constructor, used for any additional initialization. Subclasses can override. Sets the initialized flag.
 
virtual void reset (poly_mask reset_mask)
 Called to reset the Processor's per-voice state (e.g., on note-on).
 
virtual void hardReset ()
 Called to perform a "hard" reset for all voices.
 
bool initialized ()
 Returns whether this Processor has been initialized.
 
virtual void setSampleRate (int sample_rate)
 Updates the sample rate of this Processor (scaled by oversampling).
 
virtual void setOversampleAmount (int oversample)
 Sets the oversampling amount and updates the effective sample rate.
 
force_inline bool enabled () const
 Checks if this Processor is enabled.
 
force_inline int getSampleRate () const
 Retrieves the current (effective) sample rate.
 
force_inline int getOversampleAmount () const
 Retrieves the current oversampling factor.
 
force_inline bool isControlRate () const
 Checks if this Processor is running at control rate (buffer_size == 1).
 
virtual void setControlRate (bool control_rate)
 Sets whether this Processor runs at control rate.
 
force_inline poly_mask getResetMask (int input_index) const
 Retrieves a mask indicating which voices triggered a note-on event. Compares the input's trigger_value to kVoiceOn.
 
force_inline void clearOutputBufferForReset (poly_mask reset_mask, int input_index, int output_index) const
 Clears output samples for voices that are about to be reset, based on the trigger offset.
 
bool inputMatchesBufferSize (int input=0)
 Checks whether the buffer size of a particular input matches the size needed by this Processor.
 
bool checkInputAndOutputSize (int num_samples)
 Checks if all inputs and outputs have buffers big enough for num_samples.
 
virtual bool isPolyphonic () const
 Checks if this Processor is polyphonic by querying its ProcessorRouter.
 
void plug (const Output *source)
 Connects an external Output to this Processor's first input.
 
void plug (const Output *source, unsigned int input_index)
 Connects an external Output to a specified input index.
 
void plug (const Processor *source)
 Connects the first output of a Processor to this Processor's first input.
 
void plug (const Processor *source, unsigned int input_index)
 Connects the first output of a Processor to a specified input index.
 
void plugNext (const Output *source)
 Connects an external Output to the first available (unplugged) input.
 
void plugNext (const Processor *source)
 Connects the first output of a Processor to the first available (unplugged) input.
 
void useInput (Input *input)
 Uses an existing Input object as this Processor's first input.
 
void useInput (Input *input, int index)
 Uses an existing Input object at a specified input index.
 
void useOutput (Output *output)
 Uses an existing Output object as this Processor's first output.
 
void useOutput (Output *output, int index)
 Uses an existing Output object at a specified output index.
 
int connectedInputs ()
 Counts how many inputs are connected to a real source (not null_source_).
 
virtual void unplugIndex (unsigned int input_index)
 Removes the connection at a specified input index, if any.
 
virtual void unplug (const Output *source)
 Removes a connection to a given Output from all inputs.
 
virtual void unplug (const Processor *source)
 Removes connections to all outputs from a given Processor.
 
force_inline void router (ProcessorRouter *router)
 Sets the ProcessorRouter that owns or manages this Processor.
 
force_inline ProcessorRouterrouter () const
 Returns the ProcessorRouter that currently owns this Processor.
 
ProcessorRoutergetTopLevelRouter () const
 Gets the topmost (root) ProcessorRouter by traversing parent routers.
 
virtual void registerInput (Input *input, int index)
 Registers a new input, appending it to the input list.
 
virtual OutputregisterOutput (Output *output, int index)
 Registers a new Output in the output list at a specified index.
 
virtual void registerInput (Input *input)
 Registers a new Input by appending it to the end of the input list.
 
virtual OutputregisterOutput (Output *output)
 Registers a new Output by appending it to the end of the output list.
 
force_inline int numInputs () const
 Returns the total number of Input pointers (owned or otherwise).
 
force_inline int numOutputs () const
 Returns the total number of Output pointers (owned or otherwise).
 
force_inline int numOwnedInputs () const
 Returns how many Input objects this Processor owns.
 
force_inline int numOwnedOutputs () const
 Returns how many Output objects this Processor owns.
 
force_inline Inputinput (unsigned int index=0) const
 Retrieves the Input pointer at a given index.
 
force_inline bool isInputSourcePolyphonic (int index=0)
 Checks if the input source at a given index is polyphonic.
 
force_inline InputownedInput (unsigned int index=0) const
 Retrieves an owned Input pointer at a given index.
 
force_inline Outputoutput (unsigned int index=0) const
 Retrieves the Output pointer at a given index.
 
force_inline OutputownedOutput (unsigned int index=0) const
 Retrieves an owned Output pointer at a given index.
 
void setPluggingStart (int start)
 Sets the position at which plugNext starts searching for an open input.
 

Additional Inherited Members

- Protected Member Functions inherited from vital::Processor
OutputaddOutput (int oversample=1)
 Creates and registers a new Output. Handles control rate vs. audio rate.
 
InputaddInput ()
 Creates and registers a new Input, initially connected to null_source_.
 
- Protected Attributes inherited from vital::Processor
std::shared_ptr< ProcessorStatestate_
 Shared state (sample rate, oversample, etc.)
 
int plugging_start_
 The index at which plugNext starts searching for an unplugged input.
 
std::vector< std::shared_ptr< Input > > owned_inputs_
 Inputs owned by this Processor.
 
std::vector< std::shared_ptr< Output > > owned_outputs_
 Outputs owned by this Processor.
 
std::shared_ptr< std::vector< Input * > > inputs_
 All inputs, owned or external.
 
std::shared_ptr< std::vector< Output * > > outputs_
 All outputs, owned or external.
 
ProcessorRouterrouter_
 The ProcessorRouter that manages this Processor.
 
- Static Protected Attributes inherited from vital::Processor
static const Output null_source_
 A null (dummy) source used for unconnected inputs.
 

Detailed Description

Base class for operator nodes that perform arithmetic or other transformations in the processing graph.

An Operator is a Processor that can be enabled or disabled based on whether sufficient inputs are connected and whether it has been externally enabled.

Constructor & Destructor Documentation

◆ Operator()

vital::Operator::Operator ( int num_inputs,
int num_outputs,
bool control_rate = false )
inline

Constructs an Operator with a specified number of inputs/outputs and control-rate setting.

Parameters
num_inputsNumber of input channels to this operator.
num_outputsNumber of output channels from this operator.
control_rateTrue if operating at control rate, false if audio rate.

Member Function Documentation

◆ enable()

void vital::Operator::enable ( bool enable)
inlineoverridevirtual

Enables or disables the Operator, storing the external enable state.

Parameters
enableTrue to enable, false to disable.

Reimplemented from vital::Processor.

◆ hasEnoughInputs()

force_inline bool vital::Operator::hasEnoughInputs ( )
inline

Checks if this Operator has at least one connected input.

Returns
True if at least one input is connected.

◆ hasState()

virtual bool vital::Operator::hasState ( ) const
inlineoverridevirtual

Indicates whether this operator has internal state that must be preserved or reset.

Returns
False by default, meaning no internal state is stored.

Reimplemented from vital::Processor.

Reimplemented in vital::ModulationSum, vital::SmoothMultiply, and vital::StereoEncoder.

◆ numInputsChanged()

void vital::Operator::numInputsChanged ( )
inlineoverridevirtual

Called when the number of inputs changes (e.g., dynamically connected or disconnected).

Reimplemented from vital::Processor.

◆ setEnabled()

void vital::Operator::setEnabled ( )
inline

Updates this operator’s enabled state based on connected inputs and external status.


The documentation for this class was generated from the following file: