Vital
Loading...
Searching...
No Matches
synth_voice_handler.h
Go to the documentation of this file.
1#pragma once
2
3#include "synth_module.h"
4#include "producers_module.h"
5#include "voice_handler.h"
6#include "wavetable.h"
7#include "synth_types.h"
8#include "line_generator.h"
9
10#include <vector>
11
12namespace vital {
13 class AudioRateEnvelope;
14 class FiltersModule;
15 class LegatoFilter;
16 class LineMap;
17 class LfoModule;
18 class EnvelopeModule;
19 class RandomLfoModule;
20 class TriggerRandom;
21
32 public:
38 SynthVoiceHandler(Output* beats_per_second);
39
43 virtual ~SynthVoiceHandler() { }
44
50 virtual Processor* clone() const override { VITAL_ASSERT(false); return nullptr; }
51
55 void init() override;
56
60 void prepareDestroy();
61
67 void process(int num_samples) override;
68
77 void noteOn(int note, mono_float velocity, int sample, int channel) override;
78
87 void noteOff(int note, mono_float lift, int sample, int channel) override;
88
95 bool shouldAccumulate(Output* output) override;
96
104 void correctToTime(double seconds) override;
105
112
118 void disableModSource(const std::string& source);
119
125 output_map& getPolyModulations() override;
126
132 ModulationConnectionBank& getModulationBank() { return modulation_bank_; }
133
140 Wavetable* getWavetable(int index) { return producers_->getWavetable(index); }
141
147 Sample* getSample() { return producers_->getSample(); }
148
155 LineGenerator* getLfoSource(int index) { return &lfo_sources_[index]; }
156
162 Output* getDirectOutput() { return getAccumulatedOutput(direct_output_->output()); }
163
169 Output* note_retrigger() { return &note_retriggered_; }
170
176 Output* midi_offset_output() { return midi_offset_output_; }
177
184
191
198 return enabled_modulation_processors_;
199 }
200
201 private:
205 void createNoteArticulation();
206
210 void createProducers();
211
215 void createModulators();
216
220 void createVoiceOutput();
221
227 void createFilters(Output* keytrack);
228
232 void setupPolyModulationReadouts();
233
234 ModulationConnectionBank modulation_bank_;
235 CircularQueue<ModulationConnectionProcessor*> enabled_modulation_processors_;
237 ProducersModule* producers_;
238 Output* beats_per_second_;
240 Processor* note_from_reference_;
241 Output* midi_offset_output_;
242 Processor* bent_midi_;
243 Processor* current_midi_note_;
244 EnvelopeModule* amplitude_envelope_;
245 Processor* amplitude_;
246 Processor* pitch_wheel_;
248 FiltersModule* filters_module_;
250 LfoModule* lfos_[kNumLfos];
251 EnvelopeModule* envelopes_[kNumEnvelopes];
253 Output note_retriggered_;
255 LineGenerator lfo_sources_[kNumLfos];
257 TriggerRandom* random_;
258 RandomLfoModule* random_lfos_[kNumRandomLfos];
260 LineMap* note_mapping_;
261 LineMap* velocity_mapping_;
262 LineMap* aftertouch_mapping_;
263 LineMap* slide_mapping_;
264 LineMap* lift_mapping_;
265 LineMap* mod_wheel_mapping_;
266 LineMap* pitch_wheel_mapping_;
268 cr::Value* stereo_;
269 cr::Multiply* note_percentage_;
271 Multiply* output_;
272 Multiply* direct_output_;
273 Output num_voices_;
275 output_map poly_readouts_;
276 poly_mask last_active_voice_mask_;
278 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SynthVoiceHandler)
279 };
280} // namespace vital
A class for generating and storing a line shape, defined by a series of points and associated powers.
Definition line_generator.h:20
A generic circular buffer (FIFO) data structure that allows adding and removing elements efficiently.
Definition circular_queue.h:32
A module that generates an envelope signal (ADSR-like) controlled by various parameters.
Definition envelope_module.h:17
A module that manages two filter modules and provides multiple routing configurations.
Definition filters_module.h:16
A module that generates a Low-Frequency Oscillation (LFO) signal from a LineGenerator source.
Definition lfo_module.h:18
A processor that maps a phase input through a line generator, producing a value and phase output.
Definition line_map.h:16
A container managing a fixed number of ModulationConnections.
Definition synth_types.h:87
A processor that applies a modulation signal to a parameter, performing mapping, scaling,...
Definition modulation_connection_processor.h:18
Multiplies two input buffers sample-by-sample.
Definition operators.h:318
Base class for all signal-processing units in Vital.
Definition processor.h:212
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
A module that manages multiple audio producers (oscillators and sampler) and routes their outputs.
Definition producers_module.h:17
Wavetable * getWavetable(int index)
Retrieves the Wavetable associated with a specified oscillator.
Definition producers_module.h:107
Sample * getSample()
Retrieves the current Sample used by the sampler.
Definition producers_module.h:116
A module that produces random low-frequency oscillations (LFOs) for modulation purposes.
Definition random_lfo_module.h:16
Holds and manages a single sampled waveform, including stereo or mono data and multiple band-limited ...
Definition sample_source.h:25
Manages per-voice processing of audio signals within the Vital synthesizer.
Definition synth_voice_handler.h:31
void prepareDestroy()
Prepares the voice handler for destruction, removing processors as needed.
Definition synth_voice_handler.cpp:134
output_map & getPolyModulations() override
Retrieves a map of all polyphonic modulations.
Definition synth_voice_handler.cpp:436
void init() override
Initializes the voice handler, creating and configuring all internal modules.
Definition synth_voice_handler.cpp:50
void noteOff(int note, mono_float lift, int sample, int channel) override
Handles a note-off event, releasing voices or retriggering them in legato contexts.
Definition synth_voice_handler.cpp:359
bool shouldAccumulate(Output *output) override
Determines if the given output should be accumulated across voices.
Definition synth_voice_handler.cpp:370
Output * note_retrigger()
Retrieves the output that triggers when a note is retriggered.
Definition synth_voice_handler.h:169
void process(int num_samples) override
Processes all active voices for a given number of samples.
Definition synth_voice_handler.cpp:312
void disableUnnecessaryModSources()
Disables all unnecessary modulation sources for efficiency.
Definition synth_voice_handler.cpp:391
Output * midi_offset_output()
Retrieves the MIDI offset output.
Definition synth_voice_handler.h:176
virtual ~SynthVoiceHandler()
Destructor.
Definition synth_voice_handler.h:43
Wavetable * getWavetable(int index)
Gets a wavetable from the producers module.
Definition synth_voice_handler.h:140
virtual Processor * clone() const override
Unsupported clone operation.
Definition synth_voice_handler.h:50
void disableModSource(const std::string &source)
Disables a specific modulation source by name.
Definition synth_voice_handler.cpp:407
LineGenerator * getLfoSource(int index)
Retrieves the LFO source LineGenerator at a given index.
Definition synth_voice_handler.h:155
Sample * getSample()
Gets the current sample from the producers module's sampler.
Definition synth_voice_handler.h:147
CircularQueue< ModulationConnectionProcessor * > & enabledModulationConnection()
Gets the queue of currently enabled modulation connection processors.
Definition synth_voice_handler.h:197
void enableModulationConnection(ModulationConnectionProcessor *processor)
Enables a modulation connection processor, making its modulation active.
Definition synth_voice_handler.cpp:415
Output * getDirectOutput()
Gets the direct output (bypassing filters/effects) for accumulation.
Definition synth_voice_handler.h:162
void noteOn(int note, mono_float velocity, int sample, int channel) override
Handles a note-on event, starting or retriggering voices as appropriate.
Definition synth_voice_handler.cpp:350
void correctToTime(double seconds) override
Corrects time-dependent parameters to a given playback time.
Definition synth_voice_handler.cpp:380
ModulationConnectionBank & getModulationBank()
Retrieves the modulation connection bank.
Definition synth_voice_handler.h:132
void disableModulationConnection(ModulationConnectionProcessor *processor)
Disables a modulation connection processor, removing it from active modulation.
Definition synth_voice_handler.cpp:422
SynthVoiceHandler(Output *beats_per_second)
Constructs a SynthVoiceHandler with a given beats-per-second reference.
Definition synth_voice_handler.cpp:24
A processor that outputs a random value on a trigger event.
Definition trigger_random.h:15
A SynthModule and NoteHandler that manages a pool of polyphonic voices, handles note-on/off logic,...
Definition voice_handler.h:380
force_inline Output * velocity()
Returns a pointer to velocity, the note-on velocity.
Definition voice_handler.h:634
force_inline Output * note()
Returns a pointer to the note Output, giving the current tuned note frequency or pitch.
Definition voice_handler.h:616
force_inline Output * channel()
Returns a pointer to channel, indicating the MIDI channel of the voice.
Definition voice_handler.h:631
force_inline Output * getAccumulatedOutput(Output *output)
Retrieves the accumulated Output associated with a given output pointer.
Definition voice_handler.h:665
force_inline Output * lift()
Returns a pointer to lift, the note-off velocity or release velocity.
Definition voice_handler.h:637
A class representing a wavetable, holding multiple frames of waveforms and their frequency-domain rep...
Definition wavetable.h:20
Control-rate multiplication of two values.
Definition operators.h:719
A control-rate variant of the Value processor.
Definition value.h:82
#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
constexpr int kNumRandomLfos
Number of random LFO sources (random modulation generators).
Definition synth_constants.h:25
constexpr int kNumEnvelopes
Number of envelope generators in Vital.
Definition synth_constants.h:22
constexpr int kNumLfos
Number of LFO sources available in the Vital synthesizer.
Definition synth_constants.h:13
float mono_float
Definition common.h:33
Holds and manages a buffer of samples (poly_float) for a Processor's output.
Definition processor.h:35
Represents a vector of integer values using SIMD instructions.
Definition poly_values.h:56
Defines the SynthModule class which extends ProcessorRouter to form a building block of the Vital syn...
Declares classes and data structures to handle polyphonic voices in Vital, including voice assignment...