Vital
Loading...
Searching...
No Matches
reverb_module.cpp
Go to the documentation of this file.
1#include "reverb_module.h"
2#include "reverb.h"
3
4namespace vital {
5
11 ReverbModule::ReverbModule() : SynthModule(0, 1), reverb_(nullptr) { }
12
18
26 reverb_ = new Reverb();
29
30 // Create controls for reverb parameters.
31 Output* reverb_decay_time = createMonoModControl("reverb_decay_time");
32 Output* reverb_pre_low_cutoff = createMonoModControl("reverb_pre_low_cutoff");
33 Output* reverb_pre_high_cutoff = createMonoModControl("reverb_pre_high_cutoff");
34 Output* reverb_low_shelf_cutoff = createMonoModControl("reverb_low_shelf_cutoff");
35 Output* reverb_low_shelf_gain = createMonoModControl("reverb_low_shelf_gain");
36 Output* reverb_high_shelf_cutoff = createMonoModControl("reverb_high_shelf_cutoff");
37 Output* reverb_high_shelf_gain = createMonoModControl("reverb_high_shelf_gain");
38 Output* reverb_chorus_amount = createMonoModControl("reverb_chorus_amount");
39 Output* reverb_chorus_frequency = createMonoModControl("reverb_chorus_frequency");
40 Output* reverb_size = createMonoModControl("reverb_size");
41 Output* reverb_delay = createMonoModControl("reverb_delay");
42 Output* reverb_wet = createMonoModControl("reverb_dry_wet");
43
44 // Connect parameter controls to the Reverb processor.
45 reverb_->plug(reverb_decay_time, Reverb::kDecayTime);
46 reverb_->plug(reverb_pre_low_cutoff, Reverb::kPreLowCutoff);
47 reverb_->plug(reverb_pre_high_cutoff, Reverb::kPreHighCutoff);
48 reverb_->plug(reverb_low_shelf_cutoff, Reverb::kLowCutoff);
49 reverb_->plug(reverb_low_shelf_gain, Reverb::kLowGain);
50 reverb_->plug(reverb_high_shelf_cutoff, Reverb::kHighCutoff);
51 reverb_->plug(reverb_high_shelf_gain, Reverb::kHighGain);
52 reverb_->plug(reverb_chorus_amount, Reverb::kChorusAmount);
53 reverb_->plug(reverb_chorus_frequency, Reverb::kChorusFrequency);
54 reverb_->plug(reverb_delay, Reverb::kDelay);
55 reverb_->plug(reverb_size, Reverb::kSize);
56 reverb_->plug(reverb_wet, Reverb::kWet);
57
59 }
60
67
75 void ReverbModule::enable(bool enable) {
77 process(1); // Process a single sample to update state if enabling
78 if (!enable)
80 }
81
89 void ReverbModule::setSampleRate(int sample_rate) {
90 SynthModule::setSampleRate(sample_rate);
91 reverb_->setSampleRate(sample_rate);
92 }
93
100 void ReverbModule::processWithInput(const poly_float* audio_in, int num_samples) {
101 SynthModule::process(num_samples);
102 reverb_->processWithInput(audio_in, num_samples);
103 }
104} // namespace vital
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
virtual void process(int num_samples) override
Processes audio through all Processors managed by this router.
Definition processor_router.cpp:57
A Processor implementing a dense feedback network reverb.
Definition reverb.h:16
void hardReset() override
Resets the reverb, clearing buffer contents and resetting filters.
Definition reverb.cpp:483
void setSampleRate(int sample_rate) override
Overrides base class to update reverb internal buffers at a new sample rate.
Definition reverb.cpp:462
@ kChorusFrequency
Frequency of the chorus LFO (Hz)
Definition reverb.h:107
@ kPreHighCutoff
Pre-filter high cutoff (MIDI note)
Definition reverb.h:101
@ kSize
Overall size (scales buffer size exponent)
Definition reverb.h:109
@ kChorusAmount
Amount of chorusing applied to feedback lines.
Definition reverb.h:106
@ kHighGain
High-frequency attenuation (dB)
Definition reverb.h:105
@ kDelay
Additional pre-delay in samples.
Definition reverb.h:110
@ kPreLowCutoff
Pre-filter low cutoff (MIDI note)
Definition reverb.h:100
@ kHighCutoff
Internal feedback high cutoff (MIDI note)
Definition reverb.h:104
@ kLowCutoff
Internal feedback low cutoff (MIDI note)
Definition reverb.h:102
@ kDecayTime
Reverb decay time in seconds.
Definition reverb.h:99
@ kLowGain
Low-frequency attenuation (dB)
Definition reverb.h:103
@ kWet
Dry/wet mix.
Definition reverb.h:111
void processWithInput(const poly_float *audio_in, int num_samples) override
Processes a block of audio using a provided input buffer.
Definition reverb.cpp:128
void enable(bool enable) override
Enables or disables the reverb module.
Definition reverb_module.cpp:75
void init() override
Initializes the reverb module and sets up parameter controls.
Definition reverb_module.cpp:25
void processWithInput(const poly_float *audio_in, int num_samples) override
Processes an input audio buffer through the reverb effect.
Definition reverb_module.cpp:100
Reverb * reverb_
Definition reverb_module.h:80
void hardReset() override
Performs a hard reset of the reverb.
Definition reverb_module.cpp:64
void setSampleRate(int sample_rate) override
Sets the sample rate of the reverb processor.
Definition reverb_module.cpp:89
ReverbModule()
Constructs a ReverbModule.
Definition reverb_module.cpp:11
virtual ~ReverbModule()
Destructor for ReverbModule.
Definition reverb_module.cpp:16
A ProcessorRouter that encapsulates a cohesive unit of functionality in the synthesizer.
Definition synth_module.h:129
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
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