Vital
Loading...
Searching...
No Matches
compressor_module.cpp
Go to the documentation of this file.
1#include "compressor_module.h"
2#include "compressor.h"
3
4namespace vital {
5
6 CompressorModule::CompressorModule() : SynthModule(0, kNumOutputs), compressor_(nullptr) { }
7
9 // Destructor ensures proper cleanup of the compressor_ pointer if necessary.
10 }
11
29
30 Output* compressor_attack = createMonoModControl("compressor_attack");
31 Output* compressor_release = createMonoModControl("compressor_release");
32 Output* compressor_low_gain = createMonoModControl("compressor_low_gain");
33 Output* compressor_band_gain = createMonoModControl("compressor_band_gain");
34 Output* compressor_high_gain = createMonoModControl("compressor_high_gain");
35
36 Value* compressor_enabled_bands = createBaseControl("compressor_enabled_bands");
37
38 Value* compressor_low_upper_ratio = createBaseControl("compressor_low_upper_ratio");
39 Value* compressor_band_upper_ratio = createBaseControl("compressor_band_upper_ratio");
40 Value* compressor_high_upper_ratio = createBaseControl("compressor_high_upper_ratio");
41 Value* compressor_low_lower_ratio = createBaseControl("compressor_low_lower_ratio");
42 Value* compressor_band_lower_ratio = createBaseControl("compressor_band_lower_ratio");
43 Value* compressor_high_lower_ratio = createBaseControl("compressor_high_lower_ratio");
44
45 Value* compressor_low_upper_threshold = createBaseControl("compressor_low_upper_threshold");
46 Value* compressor_band_upper_threshold = createBaseControl("compressor_band_upper_threshold");
47 Value* compressor_high_upper_threshold = createBaseControl("compressor_high_upper_threshold");
48 Value* compressor_low_lower_threshold = createBaseControl("compressor_low_lower_threshold");
49 Value* compressor_band_lower_threshold = createBaseControl("compressor_band_lower_threshold");
50 Value* compressor_high_lower_threshold = createBaseControl("compressor_high_lower_threshold");
51
52 Output* compressor_mix = createMonoModControl("compressor_mix");
53
54 // Plugging each parameter into the compressor.
61 compressor_->plug(compressor_enabled_bands, MultibandCompressor::kEnabledBands);
62
63 compressor_->plug(compressor_low_upper_ratio, MultibandCompressor::kLowUpperRatio);
64 compressor_->plug(compressor_band_upper_ratio, MultibandCompressor::kBandUpperRatio);
65 compressor_->plug(compressor_high_upper_ratio, MultibandCompressor::kHighUpperRatio);
66 compressor_->plug(compressor_low_lower_ratio, MultibandCompressor::kLowLowerRatio);
67 compressor_->plug(compressor_band_lower_ratio, MultibandCompressor::kBandLowerRatio);
68 compressor_->plug(compressor_high_lower_ratio, MultibandCompressor::kHighLowerRatio);
69
70 compressor_->plug(compressor_low_upper_threshold, MultibandCompressor::kLowUpperThreshold);
71 compressor_->plug(compressor_band_upper_threshold, MultibandCompressor::kBandUpperThreshold);
72 compressor_->plug(compressor_high_upper_threshold, MultibandCompressor::kHighUpperThreshold);
73 compressor_->plug(compressor_low_lower_threshold, MultibandCompressor::kLowLowerThreshold);
74 compressor_->plug(compressor_band_lower_threshold, MultibandCompressor::kBandLowerThreshold);
75 compressor_->plug(compressor_high_lower_threshold, MultibandCompressor::kHighLowerThreshold);
76
78 }
79
80 void CompressorModule::setSampleRate(int sample_rate) {
85 SynthModule::setSampleRate(sample_rate);
86 compressor_->setSampleRate(sample_rate);
87 }
88
89 void CompressorModule::processWithInput(const poly_float* audio_in, int num_samples) {
96 SynthModule::process(num_samples);
97 compressor_->processWithInput(audio_in, num_samples);
98 }
99
108
115} // namespace vital
@ kAudio
Definition compressor_module.h:32
@ kLowOutputMeanSquared
Definition compressor_module.h:36
@ kLowInputMeanSquared
Definition compressor_module.h:33
@ kBandOutputMeanSquared
Definition compressor_module.h:37
@ kHighOutputMeanSquared
Definition compressor_module.h:38
@ kBandInputMeanSquared
Definition compressor_module.h:34
@ kHighInputMeanSquared
Definition compressor_module.h:35
MultibandCompressor * compressor_
The internal multiband compressor processor.
Definition compressor_module.h:96
virtual void hardReset() override
Performs a hard reset of the compressor, clearing buffers and resetting all states.
Definition compressor_module.cpp:109
virtual void processWithInput(const poly_float *audio_in, int num_samples) override
Processes a block of samples through the compressor with the given input.
Definition compressor_module.cpp:89
virtual ~CompressorModule()
Destroys the CompressorModule and releases its resources.
Definition compressor_module.cpp:8
virtual void enable(bool enable) override
Enables or disables the compressor module.
Definition compressor_module.cpp:100
virtual void init() override
Initializes the compressor module and sets up internal parameters and controls.
Definition compressor_module.cpp:12
CompressorModule()
Constructs a CompressorModule, initializing outputs and internal variables.
Definition compressor_module.cpp:6
virtual void setSampleRate(int sample_rate) override
Sets the sample rate for the compressor to ensure time-based parameters (attack, release) are correct...
Definition compressor_module.cpp:80
A Processor implementing multiband compression using multiple Compressor instances.
Definition compressor.h:182
@ kHighOutputMeanSquared
High band output mean squared.
Definition compressor.h:235
@ kLowOutputMeanSquared
Low band output mean squared.
Definition compressor.h:233
@ kBandOutputMeanSquared
Band output mean squared.
Definition compressor.h:234
@ kLowInputMeanSquared
Low band input mean squared.
Definition compressor.h:230
@ kBandInputMeanSquared
Band input mean squared.
Definition compressor.h:231
@ kHighInputMeanSquared
High band input mean squared.
Definition compressor.h:232
@ kHighUpperThreshold
Upper threshold (dB) for high band.
Definition compressor.h:198
@ kLowLowerThreshold
Lower threshold (dB) for low band.
Definition compressor.h:199
@ kEnabledBands
Enabled bands (see BandOptions)
Definition compressor.h:207
@ kHighUpperRatio
Upper ratio for high band.
Definition compressor.h:192
@ kLowUpperThreshold
Upper threshold (dB) for low band.
Definition compressor.h:196
@ kHighLowerThreshold
Lower threshold (dB) for high band.
Definition compressor.h:201
@ kBandUpperRatio
Upper ratio for band.
Definition compressor.h:191
@ kHighOutputGain
Output gain (dB) for high band.
Definition compressor.h:204
@ kBandLowerThreshold
Lower threshold (dB) for band.
Definition compressor.h:200
@ kAttack
Global attack control.
Definition compressor.h:205
@ kLowLowerRatio
Lower ratio for low band.
Definition compressor.h:193
@ kRelease
Global release control.
Definition compressor.h:206
@ kMix
Dry/wet mix for all bands.
Definition compressor.h:208
@ kBandUpperThreshold
Upper threshold (dB) for band.
Definition compressor.h:197
@ kAudio
Input audio signal.
Definition compressor.h:189
@ kBandOutputGain
Output gain (dB) for band.
Definition compressor.h:203
@ kLowUpperRatio
Upper ratio for low band.
Definition compressor.h:190
@ kHighLowerRatio
Lower ratio for high band.
Definition compressor.h:195
@ kLowOutputGain
Output gain (dB) for low band.
Definition compressor.h:202
@ kBandLowerRatio
Lower ratio for band.
Definition compressor.h:194
void setSampleRate(int sample_rate) override
Sets the current sample rate for the internal filters and compressors.
Definition compressor.cpp:312
virtual void processWithInput(const poly_float *audio_in, int num_samples) override
Processes audio using the given input buffer and writes to output.
Definition compressor.cpp:433
void reset(poly_mask reset_mask) override
Resets internal states and filters.
Definition compressor.cpp:325
void useOutput(Output *output)
Uses an existing Output object as this Processor's first output.
Definition processor.cpp:138
void plug(const Output *source)
Connects an external Output to this Processor's first input.
Definition processor.cpp:79
virtual void process(int num_samples)=0
Main processing function. Called by the ProcessorRouter.
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
virtual void setSampleRate(int sample_rate)
Updates the sample rate of this Processor (scaled by oversampling).
Definition processor.h:285
virtual void init()
Called after constructor, used for any additional initialization. Subclasses can override....
Definition processor.h:258
virtual void addIdleProcessor(Processor *processor)
Adds a Processor that should remain idle (not processed) in the router.
Definition processor_router.cpp:146
A ProcessorRouter that encapsulates a cohesive unit of functionality in the synthesizer.
Definition synth_module.h:129
Value * createBaseControl(std::string name, bool audio_rate=false, bool smooth_value=false)
Creates a simple control processor for a given parameter name.
Definition synth_module.cpp:22
virtual void enable(bool enable) override
Enables or disables this SynthModule and its owned processors.
Definition synth_module.cpp:516
Output * createMonoModControl(std::string name, bool audio_rate=false, bool smooth_value=false, Output *internal_modulation=nullptr)
Creates a monophonic mod control, including applying parameter scaling.
Definition synth_module.cpp:104
A Processor that maintains and outputs a constant poly_float value.
Definition value.h:24
const poly_mask kFullMask
A mask covering all lanes of a poly_float vector.
Definition synth_constants.h:257
Contains classes and functions used within the Vital synthesizer framework.
Holds and manages a buffer of samples (poly_float) for a Processor's output.
Definition processor.h:35
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600