Vital
Loading...
Searching...
No Matches
synth_types.h
Go to the documentation of this file.
1/*
2Summary:
3In these files, we define fundamental types and structures that are central to the internal state and logic of the Vital synthesizer engine. The ModulationConnection and ModulationConnectionBank manage the links between modulation sources (like LFOs) and destinations (like filter cutoff). The StringLayout helps map a computer keyboard to musical notes. The modulation_change, control_map, input_map, and output_map typedefs provide convenient, strongly-typed ways to manage changes to controls, handle various inputs, and track outputs throughout the synthesizer’s audio graph.
4*/
5
6#pragma once
7
8#include "circular_queue.h"
9#include "synth_parameters.h"
10#include "operators.h"
11#include "value.h"
12
13#include <map>
14#include <string>
15
16namespace vital {
17
18 class ValueSwitch;
19 class ModulationConnectionProcessor;
20
36 ModulationConnection(int index) : ModulationConnection(index, "", "") { }
37
45 ModulationConnection(int index, std::string from, std::string to);
46
51
60 static bool isModulationSourceDefaultBipolar(const std::string& source);
61
68 void resetConnection(const std::string& from, const std::string& to) {
69 source_name = from;
71 }
72
73 std::string source_name;
74 std::string destination_name;
75 std::unique_ptr<ModulationConnectionProcessor> modulation_processor;
76
77 private:
78 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationConnection)
79 };
80
88 public:
93
98
106 ModulationConnection* createConnection(const std::string& from, const std::string& to);
107
114 ModulationConnection* atIndex(int index) { return all_connections_[index].get(); }
115
121 size_t numConnections() { return all_connections_.size(); }
122
123 private:
124 std::vector<std::unique_ptr<ModulationConnection>> all_connections_;
125
126 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationConnectionBank)
127 };
128
135 public:
140
146 std::wstring getLayout() { return layout_; }
147
153 void setLayout(const std::wstring& layout) { layout_ = layout; }
154
160 wchar_t getUpKey() { return up_key_; }
161
167 void setUpKey(wchar_t up_key) { up_key_ = up_key; }
168
174 wchar_t getDownKey() { return down_key_; }
175
181 void setDownKey(wchar_t down_key) { down_key_ = down_key; }
182
183 protected:
184 std::wstring layout_;
187
188 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StringLayout)
189 };
190
210
214 typedef std::map<std::string, Value*> control_map;
215
219 typedef std::pair<Value*, mono_float> control_change;
220
224 typedef std::map<std::string, Processor*> input_map;
225
229 typedef std::map<std::string, Output*> output_map;
230} // namespace vital
A container managing a fixed number of ModulationConnections.
Definition synth_types.h:87
ModulationConnection * atIndex(int index)
Retrieves a ModulationConnection by index.
Definition synth_types.h:114
size_t numConnections()
Returns the total number of connections allocated (including unused ones).
Definition synth_types.h:121
~ModulationConnectionBank()
Destroys the ModulationConnectionBank and its connections.
Definition synth_types.cpp:58
ModulationConnection * createConnection(const std::string &from, const std::string &to)
Creates a new modulation connection by finding an empty slot and assigning source/destination.
Definition synth_types.cpp:60
ModulationConnectionBank()
Constructs the bank and pre-allocates all modulation connection slots.
Definition synth_types.cpp:50
A processor that applies a modulation signal to a parameter, performing mapping, scaling,...
Definition modulation_connection_processor.h:18
Base class for all signal-processing units in Vital.
Definition processor.h:212
Manages a keyboard layout mapping for a computer keyboard used as a MIDI input device.
Definition synth_types.h:134
int up_key_
The key code (wchar_t) for octave up.
Definition synth_types.h:185
void setDownKey(wchar_t down_key)
Sets the character assigned to decrease the octave.
Definition synth_types.h:181
std::wstring layout_
The mapping of keys to notes.
Definition synth_types.h:184
void setUpKey(wchar_t up_key)
Sets the character assigned to increase the octave.
Definition synth_types.h:167
StringLayout()
Constructs a StringLayout with no keys and an empty layout.
Definition synth_types.h:139
wchar_t getUpKey()
Gets the character assigned to increase the octave.
Definition synth_types.h:160
int down_key_
The key code (wchar_t) for octave down.
Definition synth_types.h:186
std::wstring getLayout()
Retrieves the current keyboard layout (a wstring of character-to-note mappings).
Definition synth_types.h:146
void setLayout(const std::wstring &layout)
Sets the current keyboard layout.
Definition synth_types.h:153
wchar_t getDownKey()
Gets the character assigned to decrease the octave.
Definition synth_types.h:174
A specialized Value processor that selects one of multiple input sources to pass through,...
Definition value_switch.h:28
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::pair< Value *, mono_float > control_change
Represents a single control change: pairs a parameter Value with the new requested value.
Definition synth_types.h:219
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
A structure representing a single modulation connection between a modulation source and a destination...
Definition synth_types.h:30
void resetConnection(const std::string &from, const std::string &to)
Resets this modulation connection to a new source and destination.
Definition synth_types.h:68
ModulationConnection(int index)
Constructs a ModulationConnection with an index and empty source/destination.
Definition synth_types.h:36
std::unique_ptr< ModulationConnectionProcessor > modulation_processor
Processor applying scaling/mapping.
Definition synth_types.h:75
~ModulationConnection()
Destroys the ModulationConnection, cleaning up its processor.
Definition synth_types.cpp:41
std::string destination_name
The name of the destination parameter.
Definition synth_types.h:74
std::string source_name
The name of the modulation source.
Definition synth_types.h:73
static bool isModulationSourceDefaultBipolar(const std::string &source)
Checks if a given modulation source is bipolar by default.
Definition synth_types.cpp:43
Holds and manages a buffer of samples (poly_float) for a Processor's output.
Definition processor.h:35
A structure describing changes to the modulation routing in the engine.
Definition synth_types.h:199
Processor * poly_destination
The poly modulation destination (if any).
Definition synth_types.h:202
Processor * mono_destination
The mono modulation destination (if any).
Definition synth_types.h:201
ValueSwitch * poly_modulation_switch
Switch to enable/disable poly modulation.
Definition synth_types.h:205
int num_audio_rate
Count of audio-rate modulations connected from the same source.
Definition synth_types.h:208
bool disconnecting
True if this change represents a disconnection.
Definition synth_types.h:207
Output * source
The modulation source output.
Definition synth_types.h:200
mono_float destination_scale
Scaling factor for the destination parameter.
Definition synth_types.h:203
ModulationConnectionProcessor * modulation_processor
The processor for applying modulation shape/curve.
Definition synth_types.h:206
ValueSwitch * mono_modulation_switch
Switch to enable/disable mono modulation.
Definition synth_types.h:204
Declares Value processors that output a constant value and can be dynamically set.