1 #ifndef __synthCore_h__ 2 #define __synthCore_h__ 5 #include "synthvoice.h" 8 #include "../../source/synthbase.h" 9 #include "../../source/audiodelay.h" 43 struct SynthEngineParameters
45 SynthEngineParameters() {}
48 bool enableMIDINoteEvents =
true;
51 uint32_t synthModeIndex =
enumToInt(SynthMode::kMono);
54 double globalVolume_dB = 0.0;
57 uint32_t globalPitchBendSensCoarse = 7;
58 uint32_t globalPitchBendSensFine = 0;
62 int32_t globalTuningCoarse = 0;
63 int32_t globalTuningFine = 0;
66 double globalUnisonDetune_Cents = 0.0;
69 std::shared_ptr<SynthVoiceParameters> voiceParameters = std::make_shared<SynthVoiceParameters>();
74 WaveSequencerStatusMeters wsStatusMeters;
77 std::shared_ptr<AudioDelayParameters> audioDelayParameters = std::make_shared<AudioDelayParameters>();
78 bool enableDelayFX =
false;
101 SynthEngine(uint32_t blockSize = 64, DMConfig* config =
nullptr);
105 virtual bool reset(
double _sampleRate);
106 virtual bool render(SynthProcessInfo& synthProcessInfo);
108 virtual bool initialize(
const char* dllPath =
nullptr);
111 void accumulateVoice(SynthProcessInfo& synthProcessInfo,
double scaling = 0.707);
115 void getParameters(std::shared_ptr<SynthEngineParameters>& _parameters) { _parameters = parameters; }
118 void setParameters(std::shared_ptr<SynthEngineParameters>& _parameters);
135 uint32_t getVoiceCount() {
return MAX_VOICES; }
136 void setDynamicModules(std::vector<std::shared_ptr<SynthLab::ModuleCore>> modules, uint32_t voiceIndex);
141 SynthProcessInfo voiceProcessInfo;
145 std::shared_ptr<SynthEngineParameters> parameters = std::make_shared<SynthEngineParameters>();
148 std::shared_ptr<MidiInputData> midiInputData = std::make_shared<MidiInputData>();
149 std::shared_ptr<MidiOutputData> midiOutputData = std::make_shared<MidiOutputData>();
155 std::shared_ptr<WavetableDatabase> wavetableDatabase =
nullptr;
158 std::shared_ptr<PCMSampleDatabase> sampleDatabase =
nullptr;
161 std::unique_ptr<AudioDelay> pingPongDelay =
nullptr;
#define enumToInt(ENUM)
macro helper to cast a typed enum to an int
Definition: synthfunctions.h:251
virtual bool reset(double _sampleRate)
Resets all voices and the audio delay object.
Definition: synthengine.cpp:82
std::vector< std::string > getModuleCoreNames(uint32_t moduleType)
Gets module core names, four per object.
Definition: synthengine.cpp:113
void accumulateVoice(SynthProcessInfo &synthProcessInfo, double scaling=0.707)
Accumulates voice buffers into a single mix buffer for each channel.
Definition: synthengine.cpp:230
int getFreeVoiceIndex()
Helper function to find a free voice to use.
Definition: synthengine.cpp:451
int getActiveVoiceIndexInNoteOn(unsigned int midiNoteNumber)
Helper function to find the voice that is playing a certain MIDI note.
Definition: synthengine.cpp:500
std::unique_ptr< SynthVoice > synthVoices[MAX_VOICES]
array of voice objects for the engine
Definition: synthengine.h:129
SynthEngine(uint32_t blockSize=64)
Construction:
Definition: synthengine.cpp:31
virtual bool render(SynthProcessInfo &synthProcessInfo)
Render a buffer of output audio samples.
Definition: synthengine.cpp:131
Definition: addosccore.cpp:4
std::vector< std::string > getModuleStrings(uint32_t mask)
Gets module-specific core STRINGS (e.g. waveform names for oscillators, filter types for filters...
Definition: synthengine.cpp:125
int getStealingVoiceIndexInNoteOn(unsigned int midiNoteNumber)
Helper function to find the voice that is playing a certain MIDI note and that will be stolen...
Definition: synthengine.cpp:520
int getVoiceIndexToSteal()
Helper function to find a free voice to steal based on some kind of heuristic.
Definition: synthengine.cpp:469
void setAllCustomUpdateCodes()
Forwards custom code settings to first voice (since all voices share the same architecture) ...
Definition: synthengine.cpp:88
void setParameters(std::shared_ptr< SynthEngineParameters > &_parameters)
Function to update the engine and voice parameters.
Definition: synthengine.cpp:396
const uint32_t MAX_VOICES
Definition: synthconstants.h:35
virtual bool initialize(const char *dllPath=nullptr)
Initializes all voices with the DLL path.
Definition: synthengine.cpp:103
void applyGlobalVolume(SynthProcessInfo &synthProcessInfo)
Apply a single global volume control to output mix buffers.
Definition: synthengine.cpp:195
void setDynamicModules(std::vector< std::shared_ptr< SynthLab::ModuleCore >> modules, uint32_t voiceIndex)
Adds dynamic module cores to the voice's member obejcts.
Definition: synthengine.cpp:99
virtual ~SynthEngine()
Destruction:
Definition: synthengine.cpp:68
virtual bool processMIDIEvent(midiEvent &event)
The MIDI event handler function; for note on/off messages it finds the voices to turn on/off...
Definition: synthengine.cpp:255
std::vector< std::string > getModKnobStrings(uint32_t mask)
Gets module-specific Mod Knob label STRINGS.
Definition: synthengine.cpp:142