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

A Processor implementing multiband compression using multiple Compressor instances. More...

#include <compressor.h>

Inheritance diagram for vital::MultibandCompressor:
vital::Processor

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 Processorclone () 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.
 
- 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 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 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.
 

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.
 
- 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

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.
 
- 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.
 

Additional Inherited Members

- Static Protected Attributes inherited from vital::Processor
static const Output null_source_
 A null (dummy) source used for unconnected inputs.
 

Detailed Description

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.

Member Enumeration Documentation

◆ anonymous enum

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.

◆ BandOptions

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 

◆ OutputType

Enumerator
kAudioOut 

Combined compressed output.

kLowInputMeanSquared 

Low band input mean squared.

kBandInputMeanSquared 

Band input mean squared.

kHighInputMeanSquared 

High band input mean squared.

kLowOutputMeanSquared 

Low band output mean squared.

kBandOutputMeanSquared 

Band output mean squared.

kHighOutputMeanSquared 

High band output mean squared.

kNumOutputs 

Total number of outputs.

Constructor & Destructor Documentation

◆ MultibandCompressor()

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.

◆ ~MultibandCompressor()

virtual vital::MultibandCompressor::~MultibandCompressor ( )
inlinevirtual

Default destructor.

Member Function Documentation

◆ clone()

virtual Processor * vital::MultibandCompressor::clone ( ) const
inlineoverridevirtual

Creates a clone of this Processor. (Not implemented for MultibandCompressor).

Returns
Returns nullptr.

Implements vital::Processor.

◆ packFilterOutput()

void vital::MultibandCompressor::packFilterOutput ( LinkwitzRileyFilter * filter,
int num_samples,
poly_float * dest )
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.

Parameters
filterPointer to a LinkwitzRileyFilter.
num_samplesNumber of samples to process.
destBuffer to which the filter output is written.

This method merges low and high filter outputs in a way that suits Vital’s polyphonic approach.

Parameters
filterPointer to the LinkwitzRileyFilter.
num_samplesNumber of samples to process.
destDestination buffer for combined low/high results.

◆ packLowBandCompressor()

void vital::MultibandCompressor::packLowBandCompressor ( int num_samples,
poly_float * dest )
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.

Parameters
num_samplesNumber of samples to process.
destBuffer to write combined data.
num_samplesNumber of samples to process.
destBuffer into which the combined result is written.

◆ process()

void vital::MultibandCompressor::process ( int num_samples)
overridevirtual

Processes audio using the input audio buffer.

Processes audio by pulling from kAudio input and splitting/compressing bands as necessary.

Parameters
num_samplesNumber of samples to process.

Implements vital::Processor.

◆ processWithInput()

void vital::MultibandCompressor::processWithInput ( const poly_float * audio_in,
int num_samples )
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.

Parameters
audio_inPointer to the input buffer.
num_samplesNumber 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.

Parameters
audio_inPointer to the input buffer.
num_samplesNumber of samples to process.

Reimplemented from vital::Processor.

◆ reset()

void vital::MultibandCompressor::reset ( poly_mask reset_mask)
overridevirtual

Resets internal states and filters.

Resets filters and internal compressors, and clears mean squared outputs.

Parameters
reset_maskA poly_mask specifying which voices should be reset.

Reimplemented from vital::Processor.

◆ setOversampleAmount()

void vital::MultibandCompressor::setOversampleAmount ( int oversample)
overridevirtual

Sets the amount of oversampling for the internal filters and compressors.

Sets the oversampling factor for the multiband compressor filters and internal compressors.

Parameters
oversampleThe oversampling factor.

Reimplemented from vital::Processor.

◆ setSampleRate()

void vital::MultibandCompressor::setSampleRate ( int sample_rate)
overridevirtual

Sets the current sample rate for the internal filters and compressors.

Configures the sample rate for internal filters and compressors.

Parameters
sample_rateThe new sample rate (in Hz).
sample_rateThe new sample rate in Hz.

Reimplemented from vital::Processor.

◆ writeAllCompressorOutputs()

void vital::MultibandCompressor::writeAllCompressorOutputs ( int num_samples,
poly_float * dest )
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.

Parameters
num_samplesNumber of samples to process.
destBuffer to write the combined data.

Used when both low and high bands are enabled (i.e., full multiband mode).

Parameters
num_samplesNumber of samples to process.
destBuffer for the combined output.

◆ writeCompressorOutputs()

void vital::MultibandCompressor::writeCompressorOutputs ( Compressor * compressor,
int num_samples,
poly_float * dest )
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.

Parameters
compressorPointer to the compressor from which to retrieve data.
num_samplesNumber of samples to process.
destBuffer to write the data.
compressorPointer to the compressor whose output is being written.
num_samplesNumber of samples to process.
destBuffer for the output data.

Member Data Documentation

◆ band_high_compressor_

Compressor vital::MultibandCompressor::band_high_compressor_
protected

Compressor handling band + high, or high only if configured.

◆ band_high_filter_

LinkwitzRileyFilter vital::MultibandCompressor::band_high_filter_
protected

A Linkwitz-Riley filter splitting audio into band and high bands.

◆ band_high_lower_ratio_

cr::Output vital::MultibandCompressor::band_high_lower_ratio_
protected

◆ band_high_lower_threshold_

cr::Output vital::MultibandCompressor::band_high_lower_threshold_
protected

◆ band_high_output_gain_

cr::Output vital::MultibandCompressor::band_high_output_gain_
protected

◆ band_high_upper_ratio_

cr::Output vital::MultibandCompressor::band_high_upper_ratio_
protected

◆ band_high_upper_threshold_

cr::Output vital::MultibandCompressor::band_high_upper_threshold_
protected

◆ low_band_compressor_

Compressor vital::MultibandCompressor::low_band_compressor_
protected

Compressor handling the low band.

◆ low_band_filter_

LinkwitzRileyFilter vital::MultibandCompressor::low_band_filter_
protected

A Linkwitz-Riley filter splitting audio into low band and the rest (band + high).

◆ low_band_lower_ratio_

cr::Output vital::MultibandCompressor::low_band_lower_ratio_
protected

◆ low_band_lower_threshold_

cr::Output vital::MultibandCompressor::low_band_lower_threshold_
protected

◆ low_band_output_gain_

cr::Output vital::MultibandCompressor::low_band_output_gain_
protected

Gain controls for low and band/high compressors.

◆ low_band_upper_ratio_

cr::Output vital::MultibandCompressor::low_band_upper_ratio_
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.

◆ low_band_upper_threshold_

cr::Output vital::MultibandCompressor::low_band_upper_threshold_
protected

◆ was_high_enabled_

bool vital::MultibandCompressor::was_high_enabled_
protected

Whether the high band was enabled on the previous process() call.

◆ was_low_enabled_

bool vital::MultibandCompressor::was_low_enabled_
protected

Whether the low band was enabled on the previous process() call.


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