32 val =
new Value(default_value);
47 data_->controls[name] = val;
60 bool smooth_value,
Output* internal_modulation) {
71 data_->mono_mod_destinations[name] = mono_total;
72 data_->mono_modulation_readout[name] = mono_total->
output();
76 control_switch->
plugNext(mono_total);
78 if (internal_modulation)
79 mono_total->
plugNext(internal_modulation);
86 if (smooth_value || internal_modulation)
87 control_switch->
set(1);
89 control_switch->
set(0);
91 data_->mono_modulation_switches[name] = control_switch;
105 bool smooth_value,
Output* internal_modulation) {
109 return control_rate_total;
119 scale->
plug(control_rate_total);
121 control_rate_total = scale->
output();
131 scale->
plug(control_rate_total);
133 control_rate_total = scale->
output();
143 scale->
plug(control_rate_total);
145 control_rate_total = scale->
output();
149 exponential->
plug(control_rate_total);
151 control_rate_total = exponential->
output();
155 root->
plug(control_rate_total);
157 control_rate_total = root->
output();
160 return control_rate_total;
174 bool smooth_value,
Output* internal_modulation,
Input* reset) {
189 data_->poly_mod_destinations[name] = poly_total;
194 modulation_total =
new Add();
196 modulation_total =
new cr::Add();
198 modulation_total->
plug(base_control, 0);
199 modulation_total->
plug(poly_total, 1);
202 data_->poly_modulation_readout[name] = poly_total->
output();
206 control_switch->
plugNext(base_control);
207 control_switch->
plugNext(modulation_total);
209 if (internal_modulation) {
210 poly_total->
plugNext(internal_modulation);
211 control_switch->
set(1);
216 control_switch->
set(0);
219 data_->poly_modulation_switches[name] = control_switch;
225 return control_rate_total;
235 scale->
plug(control_rate_total);
237 control_rate_total = scale->
output();
247 scale->
plug(control_rate_total);
249 control_rate_total = scale->
output();
259 scale->
plug(control_rate_total);
261 control_rate_total = scale->
output();
265 exponential->
plug(control_rate_total);
267 control_rate_total = exponential->
output();
271 root->
plug(control_rate_total);
273 control_rate_total = root->
output();
276 return control_rate_total;
290 const Output* beats_per_second,
bool poly,
Input* midi) {
298 data_->controls[name +
"_sync"] = sync;
308 Output* keytrack_transpose =
nullptr;
309 Output* keytrack_tune =
nullptr;
329 return tempo_chooser->
output();
338 data_->status_outputs[name] = std::make_unique<StatusOutput>(source);
345 all_controls.insert(sub_controls.begin(), sub_controls.end());
351 if (
data_->mod_sources.count(name))
352 return data_->mod_sources[name];
363 if (
data_->status_outputs.count(name))
364 return data_->status_outputs.at(name).get();
376 if (poly && poly_destination)
377 return poly_destination;
383 if (
data_->mono_mod_destinations.count(name))
384 return data_->mono_mod_destinations[name];
395 if (
data_->poly_mod_destinations.count(name))
396 return data_->poly_mod_destinations[name];
413 if (
data_->mono_modulation_switches.count(name))
414 return data_->mono_modulation_switches[name];
425 if (
data_->poly_modulation_switches.count(name))
426 return data_->poly_modulation_switches[name];
438 for (
auto& mod_switch :
data_->mono_modulation_switches) {
439 bool enable =
data_->mono_mod_destinations[mod_switch.first]->connectedInputs() > 1;
440 if (
data_->poly_mod_destinations.count(mod_switch.first))
441 enable =
enable ||
data_->poly_mod_destinations[mod_switch.first]->connectedInputs() > 0;
442 mod_switch.second->set(
enable ? 1.0f : 0.0f);
446 for (
auto& mod_switch :
data_->poly_modulation_switches)
447 mod_switch.second->
set(
data_->poly_mod_destinations[mod_switch.first]->connectedInputs() > 0);
458 all_sources.insert(sub_sources.begin(), sub_sources.end());
467 all_destinations.insert(sub_destinations.begin(), sub_destinations.end());
469 return all_destinations;
476 all_destinations.insert(sub_destinations.begin(), sub_destinations.end());
478 return all_destinations;
485 all_readouts.insert(sub_readouts.begin(), sub_readouts.end());
494 all_readouts.insert(sub_readouts.begin(), sub_readouts.end());
532 data_->owned_mono_processors.push_back(processor);
Adds two input buffers sample-by-sample.
Definition operators.h:205
A special sum operator that can accumulate control-rate and audio-rate modulation signals.
Definition operators.h:256
@ kReset
Definition operators.h:259
static const ValueDetails & getDetails(const std::string &name)
Definition synth_parameters.h:200
Base class for all signal-processing units in Vital.
Definition processor.h:212
void plugNext(const Output *source)
Connects an external Output to the first available (unplugged) input.
Definition processor.cpp:104
force_inline bool enabled() const
Checks if this Processor is enabled.
Definition processor.h:310
void useInput(Input *input)
Uses an existing Input object as this Processor's first input.
Definition processor.cpp:126
void plug(const Output *source)
Connects an external Output to this Processor's first input.
Definition processor.cpp:79
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
virtual void enable(bool enable)
Enables or disables this Processor.
Definition processor.h:318
virtual void reset(poly_mask reset_mask)
Called to reset the Processor's per-voice state (e.g., on note-on).
Definition processor.h:267
virtual ProcessorRouter * getMonoRouter()
Gets the mono router that corresponds to this ProcessorRouter.
Definition processor_router.cpp:263
virtual void addIdleProcessor(Processor *processor)
Adds a Processor that should remain idle (not processed) in the router.
Definition processor_router.cpp:146
virtual void addProcessor(Processor *processor)
Adds a Processor to be managed by this router.
Definition processor_router.cpp:121
A Value processor that smoothly transitions from its current value to a target value.
Definition smooth_value.h:23
A helper class to track the "status" of a particular Output as a poly_float value.
Definition synth_module.h:35
A ProcessorRouter that encapsulates a cohesive unit of functionality in the synthesizer.
Definition synth_module.h:129
Processor * getPolyModulationDestination(std::string name)
Retrieves a poly modulation destination by name.
Definition synth_module.cpp:394
output_map & getModulationSources()
Returns a reference to the map of modulation sources.
Definition synth_module.cpp:454
Output * createPolyModControl(std::string name, bool audio_rate=false, bool smooth_value=false, Output *internal_modulation=nullptr, Input *reset=nullptr)
Creates a polyphonic mod control, including applying parameter scaling.
Definition synth_module.cpp:173
virtual output_map & getMonoModulations()
Returns a reference to the map of mono modulation readouts.
Definition synth_module.cpp:481
void addMonoProcessor(Processor *processor, bool own=true)
Adds a mono processor to this module.
Definition synth_module.cpp:529
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
void addIdleMonoProcessor(Processor *processor)
Adds a mono processor that is considered idle (not part of main processing chain).
Definition synth_module.cpp:540
std::shared_ptr< ModuleData > data_
Shared data storage for this SynthModule.
Definition synth_module.h:354
ValueSwitch * getMonoModulationSwitch(std::string name)
Retrieves a mono modulation switch by name.
Definition synth_module.cpp:412
input_map & getPolyModulationDestinations()
Returns a reference to the map of poly modulation destinations.
Definition synth_module.cpp:472
control_map getControls()
Returns a map of all controls from this module and its submodules.
Definition synth_module.cpp:341
ValueSwitch * getPolyModulationSwitch(std::string name)
Retrieves a poly modulation switch by name.
Definition synth_module.cpp:424
Processor * getMonoModulationDestination(std::string name)
Retrieves a mono modulation destination by name.
Definition synth_module.cpp:382
Processor * getModulationDestination(std::string name, bool poly)
Retrieves a modulation destination Processor by name and poly mode.
Definition synth_module.cpp:374
virtual output_map & getPolyModulations()
Returns a reference to the map of poly modulation readouts.
Definition synth_module.cpp:490
Output * createTempoSyncSwitch(std::string name, Processor *frequency, const Output *beats_per_second, bool poly, Input *midi=nullptr)
Creates a tempo sync switch that toggles between tempo-based frequency and free-running frequency.
Definition synth_module.cpp:289
Output * getModulationSource(std::string name)
Retrieves a modulation source output by name.
Definition synth_module.cpp:350
input_map & getMonoModulationDestinations()
Returns a reference to the map of mono modulation destinations.
Definition synth_module.cpp:463
ValueSwitch * getModulationSwitch(std::string name, bool poly)
Retrieves a modulation switch by name and poly mode.
Definition synth_module.cpp:406
Output * createBaseModControl(std::string name, bool audio_rate=false, bool smooth_value=false, Output *internal_modulation=nullptr)
Creates a base mod control, which is a control combined with a modulation input.
Definition synth_module.cpp:59
void updateAllModulationSwitches()
Updates all modulation switches based on whether their destinations have inputs.
Definition synth_module.cpp:436
void createStatusOutput(std::string name, Output *source)
Creates a status output associated with a given Output.
Definition synth_module.cpp:337
void enableOwnedProcessors(bool enable)
Enables or disables all owned processors.
Definition synth_module.cpp:503
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
const StatusOutput * getStatusOutput(std::string name) const
Retrieves a StatusOutput by name.
Definition synth_module.cpp:362
Chooses a frequency based on tempo sync or direct frequency modes.
Definition operators.h:580
@ kTempoIndex
Definition operators.h:593
@ kSync
Definition operators.h:595
@ kKeytrackTune
Definition operators.h:598
@ kKeytrackTranspose
Definition operators.h:597
@ kFrequency
Definition operators.h:592
@ kMidi
Definition operators.h:596
@ kBeatsPerSecond
Definition operators.h:594
A Processor that maintains and outputs a constant poly_float value.
Definition value.h:24
A specialized Value processor that selects one of multiple input sources to pass through,...
Definition value_switch.h:28
void addProcessor(Processor *processor)
Adds a processor to be enabled or disabled depending on the selected source.
Definition value_switch.h:69
@ kSwitch
The selected input signal output.
Definition value_switch.h:36
virtual void set(poly_float value) override
Sets the control value, selecting the corresponding input as the output.
Definition value_switch.cpp:21
Control-rate addition of two values.
Definition operators.h:700
Control-rate operator cubing a single value.
Definition operators.h:786
Control-rate operator computing x^3 + offset.
Definition operators.h:845
Raises scale_ to the power of the input value (clamped to [min_, max_]).
Definition operators.h:912
Control-rate operator computing x^2 + offset.
Definition operators.h:823
Control-rate operator raising a single value to the 4th power.
Definition operators.h:804
Control-rate operator computing x^4 + offset.
Definition operators.h:867
Control-rate operator computing sqrt(x) + offset.
Definition operators.h:890
A control-rate version of the SmoothValue that smooths values at control rate instead of audio rate.
Definition smooth_value.h:91
Control-rate operator squaring a single value.
Definition operators.h:768
A control-rate variant of the Value processor.
Definition value.h:82
Control-rate version of summing multiple inputs into one.
Definition operators.h:944
#define VITAL_ASSERT(x)
Definition common.h:11
Contains classes and functions used within the Vital synthesizer framework.
std::map< std::string, Output * > output_map
Maps parameter names to Output pointers, representing output signals from various modules.
Definition synth_types.h:229
std::map< std::string, Value * > control_map
Maps parameter names to Value pointers representing synth control parameters.
Definition synth_types.h:214
std::map< std::string, Processor * > input_map
Maps parameter names to Processor pointers, representing input processors for signals.
Definition synth_types.h:224
float mono_float
Definition common.h:33
Declares the SmoothValue classes, providing time-smoothed transitions for values.
Holds and manages a buffer of samples (poly_float) for a Processor's output.
Definition processor.h:35
Holds metadata about a single parameter (control) in the Vital synthesizer.
Definition synth_parameters.h:23
mono_float max
Maximum parameter value.
Definition synth_parameters.h:41
mono_float post_offset
Offset applied after scaling (for certain scale types).
Definition synth_parameters.h:43
@ kQuartic
Parameter value transformed by a quartic curve.
Definition synth_parameters.h:33
@ kSquareRoot
Parameter value transformed by a square root function.
Definition synth_parameters.h:34
@ kCubic
Parameter value transformed by a cubic curve.
Definition synth_parameters.h:32
@ kExponential
Parameter value transformed by an exponential function.
Definition synth_parameters.h:35
@ kQuadratic
Parameter value transformed by a quadratic curve.
Definition synth_parameters.h:31
mono_float min
Minimum parameter value.
Definition synth_parameters.h:40
mono_float default_value
Default value for the parameter.
Definition synth_parameters.h:42
ValueScale value_scale
The scaling mode of the parameter value.
Definition synth_parameters.h:45
Defines the SynthModule class which extends ProcessorRouter to form a building block of the Vital syn...
Declares the ValueSwitch class, which allows switching the output buffer based on a control value.