Vital
|
A Processor implementing multiband compression using multiple Compressor instances. More...
#include <compressor.h>
Public Types | |
enum | { kAudio , kLowUpperRatio , kBandUpperRatio , kHighUpperRatio , kLowLowerRatio , kBandLowerRatio , kHighLowerRatio , kLowUpperThreshold , kBandUpperThreshold , kHighUpperThreshold , kLowLowerThreshold , kBandLowerThreshold , kHighLowerThreshold , kLowOutputGain , kBandOutputGain , kHighOutputGain , kAttack , kRelease , kEnabledBands , kMix , kNumInputs } |
enum | BandOptions { kMultiband , kLowBand , kHighBand , kSingleBand , kNumBandOptions } |
Identifies which subset of bands are active in the MultibandCompressor. More... | |
enum | OutputType { kAudioOut , kLowInputMeanSquared , kBandInputMeanSquared , kHighInputMeanSquared , kLowOutputMeanSquared , kBandOutputMeanSquared , kHighOutputMeanSquared , kNumOutputs } |
Public Member Functions | |
MultibandCompressor () | |
Constructs a MultibandCompressor, creating internal compressors and filters. | |
virtual | ~MultibandCompressor () |
Default destructor. | |
virtual Processor * | clone () const override |
Creates a clone of this Processor. (Not implemented for MultibandCompressor). | |
virtual void | process (int num_samples) override |
Processes audio using the input audio buffer. | |
void | setOversampleAmount (int oversample) override |
Sets the amount of oversampling for the internal filters and compressors. | |
virtual void | processWithInput (const poly_float *audio_in, int num_samples) override |
Processes audio using the given input buffer and writes to output. | |
void | setSampleRate (int sample_rate) override |
Sets the current sample rate for the internal filters and compressors. | |
void | reset (poly_mask reset_mask) override |
Resets internal states and filters. | |
![]() | |
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 bool | hasState () const |
Indicates whether this Processor requires per-voice state. | |
virtual void | init () |
Called after constructor, used for any additional initialization. Subclasses can override. Sets the initialized flag. | |
virtual void | hardReset () |
Called to perform a "hard" reset for all voices. | |
bool | initialized () |
Returns whether this Processor has been initialized. | |
force_inline bool | enabled () const |
Checks if this Processor is enabled. | |
virtual void | enable (bool enable) |
Enables or disables this Processor. | |
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. | |
virtual void | numInputsChanged () |
Called when the number of inputs changes (e.g., new connections). Subclasses may override for dynamic behavior. | |
force_inline void | router (ProcessorRouter *router) |
Sets the ProcessorRouter that owns or manages this Processor. | |
force_inline ProcessorRouter * | router () const |
Returns the ProcessorRouter that currently owns this Processor. | |
ProcessorRouter * | getTopLevelRouter () 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 Output * | registerOutput (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 Output * | registerOutput (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 Input * | input (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 Input * | ownedInput (unsigned int index=0) const |
Retrieves an owned Input pointer at a given index. | |
force_inline Output * | output (unsigned int index=0) const |
Retrieves the Output pointer at a given index. | |
force_inline Output * | ownedOutput (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. | |
Protected Member Functions | |
void | packFilterOutput (LinkwitzRileyFilter *filter, int num_samples, poly_float *dest) |
Extracts the LinkwitzRileyFilter’s output into a combined buffer for further processing. | |
void | packLowBandCompressor (int num_samples, poly_float *dest) |
Combines band filter outputs into a single buffer for the low band compressor. | |
void | writeAllCompressorOutputs (int num_samples, poly_float *dest) |
Writes the combined output of both compressors to a buffer. | |
void | writeCompressorOutputs (Compressor *compressor, int num_samples, poly_float *dest) |
Writes a single compressor’s output to a buffer when only one band is active. | |
![]() | |
Output * | addOutput (int oversample=1) |
Creates and registers a new Output. Handles control rate vs. audio rate. | |
Input * | addInput () |
Creates and registers a new Input, initially connected to null_source_. | |
Protected Attributes | |
bool | was_low_enabled_ |
Whether the low band was enabled on the previous process() call. | |
bool | was_high_enabled_ |
Whether the high band was enabled on the previous process() call. | |
cr::Output | low_band_upper_ratio_ |
Outputs for the low/band compressor thresholds and ratios. | |
cr::Output | band_high_upper_ratio_ |
cr::Output | low_band_lower_ratio_ |
cr::Output | band_high_lower_ratio_ |
cr::Output | low_band_upper_threshold_ |
cr::Output | band_high_upper_threshold_ |
cr::Output | low_band_lower_threshold_ |
cr::Output | band_high_lower_threshold_ |
cr::Output | low_band_output_gain_ |
Gain controls for low and band/high compressors. | |
cr::Output | band_high_output_gain_ |
LinkwitzRileyFilter | low_band_filter_ |
A Linkwitz-Riley filter splitting audio into low band and the rest (band + high). | |
LinkwitzRileyFilter | band_high_filter_ |
A Linkwitz-Riley filter splitting audio into band and high bands. | |
Compressor | low_band_compressor_ |
Compressor handling the low band. | |
Compressor | band_high_compressor_ |
Compressor handling band + high, or high only if configured. | |
![]() | |
std::shared_ptr< ProcessorState > | state_ |
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. | |
ProcessorRouter * | router_ |
The ProcessorRouter that manages this Processor. | |
Additional Inherited Members | |
![]() | |
static const Output | null_source_ |
A null (dummy) source used for unconnected inputs. | |
A Processor implementing multiband compression using multiple Compressor instances.
Splits the audio signal into up to three bands (low, band, high) via LinkwitzRiley filters, and applies distinct compressors for each band. Consolidates the outputs for a final signal.
anonymous enum |
Enumerator | |
---|---|
kAudio | Input audio signal. |
kLowUpperRatio | Upper ratio for low band. |
kBandUpperRatio | Upper ratio for band. |
kHighUpperRatio | Upper ratio for high band. |
kLowLowerRatio | Lower ratio for low band. |
kBandLowerRatio | Lower ratio for band. |
kHighLowerRatio | Lower ratio for high band. |
kLowUpperThreshold | Upper threshold (dB) for low band. |
kBandUpperThreshold | Upper threshold (dB) for band. |
kHighUpperThreshold | Upper threshold (dB) for high band. |
kLowLowerThreshold | Lower threshold (dB) for low band. |
kBandLowerThreshold | Lower threshold (dB) for band. |
kHighLowerThreshold | Lower threshold (dB) for high band. |
kLowOutputGain | Output gain (dB) for low band. |
kBandOutputGain | Output gain (dB) for band. |
kHighOutputGain | Output gain (dB) for high band. |
kAttack | Global attack control. |
kRelease | Global release control. |
kEnabledBands | Enabled bands (see BandOptions) |
kMix | Dry/wet mix for all bands. |
kNumInputs | Total number of inputs. |
Identifies which subset of bands are active in the MultibandCompressor.
Enumerator | |
---|---|
kMultiband | All three bands active. |
kLowBand | Only low band active. |
kHighBand | Only high band active. |
kSingleBand | Single band (compressor passes audio directly) |
kNumBandOptions |
vital::MultibandCompressor::MultibandCompressor | ( | ) |
Constructs a MultibandCompressor, creating internal compressors and filters.
Constructs a MultibandCompressor with specialized LinkwitzRiley filters and separate Compressor objects for low and band/high processing.
|
inlinevirtual |
Default destructor.
|
inlineoverridevirtual |
Creates a clone of this Processor. (Not implemented for MultibandCompressor).
Implements vital::Processor.
|
protected |
Extracts the LinkwitzRileyFilter’s output into a combined buffer for further processing.
Packs the filter output into a single buffer for further band processing.
filter | Pointer to a LinkwitzRileyFilter. |
num_samples | Number of samples to process. |
dest | Buffer to which the filter output is written. |
This method merges low and high filter outputs in a way that suits Vital’s polyphonic approach.
filter | Pointer to the LinkwitzRileyFilter. |
num_samples | Number of samples to process. |
dest | Destination buffer for combined low/high results. |
|
protected |
Combines band filter outputs into a single buffer for the low band compressor.
Combines the low portion and band portion of the filter output for the low band compressor.
num_samples | Number of samples to process. |
dest | Buffer to write combined data. |
num_samples | Number of samples to process. |
dest | Buffer into which the combined result is written. |
|
overridevirtual |
Processes audio using the input audio buffer.
Processes audio by pulling from kAudio input and splitting/compressing bands as necessary.
num_samples | Number of samples to process. |
Implements vital::Processor.
|
overridevirtual |
Processes audio using the given input buffer and writes to output.
Processes audio with a given input buffer, handling multiband routing based on enabled bands.
audio_in | Pointer to the input buffer. |
num_samples | Number of samples to process. |
Splits the audio into low, band, and high frequencies with Linkwitz-Riley filters, feeds them to separate compressors, and combines or bypasses them depending on user settings.
audio_in | Pointer to the input buffer. |
num_samples | Number of samples to process. |
Reimplemented from vital::Processor.
|
overridevirtual |
Resets internal states and filters.
Resets filters and internal compressors, and clears mean squared outputs.
reset_mask | A poly_mask specifying which voices should be reset. |
Reimplemented from vital::Processor.
|
overridevirtual |
Sets the amount of oversampling for the internal filters and compressors.
Sets the oversampling factor for the multiband compressor filters and internal compressors.
oversample | The oversampling factor. |
Reimplemented from vital::Processor.
|
overridevirtual |
Sets the current sample rate for the internal filters and compressors.
Configures the sample rate for internal filters and compressors.
sample_rate | The new sample rate (in Hz). |
sample_rate | The new sample rate in Hz. |
Reimplemented from vital::Processor.
|
protected |
Writes the combined output of both compressors to a buffer.
Writes outputs from both the low band and band/high compressors into one buffer.
Used when both low and high bands are enabled.
num_samples | Number of samples to process. |
dest | Buffer to write the combined data. |
Used when both low and high bands are enabled (i.e., full multiband mode).
num_samples | Number of samples to process. |
dest | Buffer for the combined output. |
|
protected |
Writes a single compressor’s output to a buffer when only one band is active.
Writes the output of a single Compressor instance to the destination buffer, handling Vital’s polyphonic approach by swapping voices as needed.
compressor | Pointer to the compressor from which to retrieve data. |
num_samples | Number of samples to process. |
dest | Buffer to write the data. |
compressor | Pointer to the compressor whose output is being written. |
num_samples | Number of samples to process. |
dest | Buffer for the output data. |
|
protected |
Compressor handling band + high, or high only if configured.
|
protected |
A Linkwitz-Riley filter splitting audio into band and high bands.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Compressor handling the low band.
|
protected |
A Linkwitz-Riley filter splitting audio into low band and the rest (band + high).
|
protected |
|
protected |
|
protected |
Gain controls for low and band/high compressors.
|
protected |
Outputs for the low/band compressor thresholds and ratios.
These are used to pass threshold/ratio values to the low band compressor via the plug() system.
|
protected |
|
protected |
Whether the high band was enabled on the previous process() call.
|
protected |
Whether the low band was enabled on the previous process() call.