1 #ifndef __synthVoice_h__ 2 #define __synthVoice_h__ 5 #include "../source/synthbase.h" 8 #include "../source/modmatrix.h" 9 #include "../source/dca.h" 10 #include "../source/lfo.h" 11 #include "../source/envelopegenerator.h" 12 #include "../source/synthfilter.h" 23 #include "../source/wtoscillator.h" 27 #include "../source/vaoscillator.h" 31 #include "../source/pcmoscillator.h" 35 #include "../source/ksoscillator.h" 39 #include "../source/fmoperator.h" 43 #include "../source/wsoscillator.h" 44 #include "../source/sequencer.h" 66 enum class lfoCoreType { standardLFO, fmLFO };
69 enum class egCoreType { analogEG, dxEG };
72 enum class filterCoreType { virtualAnalog, biQuad };
76 const lfoCoreType lfoCores[
NUM_LFO] =
78 lfoCoreType::standardLFO,
83 const egCoreType ampEGCore = egCoreType::analogEG;
84 const egCoreType filterEGCore = egCoreType::analogEG;
85 const egCoreType auxEGCore = egCoreType::dxEG;
90 filterCoreType::virtualAnalog,
91 filterCoreType::biQuad
98 const bool useAnalogFGN =
false;
101 enum class wtCoreType { classicWT, morphingWT, soundFXWT, drumWT };
104 const wtCoreType wtCores[
NUM_OSC] =
106 wtCoreType::classicWT,
107 wtCoreType::classicWT,
108 wtCoreType::morphingWT,
109 wtCoreType::soundFXWT
113 enum class pcmCoreType { legacyPCM, mellotronPCM, waveslicePCM };
116 const pcmCoreType pcmCores[
NUM_OSC] =
118 pcmCoreType::legacyPCM,
119 pcmCoreType::legacyPCM,
120 pcmCoreType::mellotronPCM,
121 pcmCoreType::waveslicePCM
249 uint32_t synthModeIndex =
enumToInt(SynthMode::kMono);
252 uint32_t filterModeIndex =
enumToInt(FilterMode::kSeries);
255 bool enablePortamento =
false;
258 double glideTime_mSec = 0.0;
261 bool legatoMode =
false;
264 bool freeRunOscMode =
false;
267 double unisonDetuneCents = 0.0;
268 double unisonStartPhase = 0.0;
269 double unisonPan = 0.0;
272 std::shared_ptr<WTOscParameters> wtOscParameters = std::make_shared<WTOscParameters>();
275 std::shared_ptr<LFOParameters> lfoParameters = std::make_shared<LFOParameters>();
278 std::shared_ptr<EGParameters> ampEGParameters = std::make_shared<EGParameters>();
281 std::shared_ptr<FilterParameters> filterParameters = std::make_shared<FilterParameters>();
284 std::shared_ptr<DCAParameters> dcaParameters = std::make_shared<DCAParameters>();
287 std::shared_ptr<ModMatrixParameters> modMatrixParameters = std::make_shared<ModMatrixParameters>();
290 uint32_t updateCodeDroplists = 0;
291 uint32_t updateCodeKnobs = 0;
298 std::shared_ptr<WTOscParameters> osc1Parameters = std::make_shared<WTOscParameters>();
299 std::shared_ptr<WTOscParameters> osc2Parameters = std::make_shared<WTOscParameters>();
300 std::shared_ptr<WTOscParameters> osc3Parameters = std::make_shared<WTOscParameters>();
301 std::shared_ptr<WTOscParameters> osc4Parameters = std::make_shared<WTOscParameters>();
302 #elif defined SYNTHLAB_VA 303 std::shared_ptr<VAOscParameters> osc1Parameters = std::make_shared<VAOscParameters>();
304 std::shared_ptr<VAOscParameters> osc2Parameters = std::make_shared<VAOscParameters>();
305 std::shared_ptr<VAOscParameters> osc3Parameters = std::make_shared<VAOscParameters>();
306 std::shared_ptr<VAOscParameters> osc4Parameters = std::make_shared<VAOscParameters>();
307 #elif defined SYNTHLAB_PCM 308 std::shared_ptr<PCMOscParameters> osc1Parameters = std::make_shared<PCMOscParameters>();
309 std::shared_ptr<PCMOscParameters> osc2Parameters = std::make_shared<PCMOscParameters>();
310 std::shared_ptr<PCMOscParameters> osc3Parameters = std::make_shared<PCMOscParameters>();
311 std::shared_ptr<PCMOscParameters> osc4Parameters = std::make_shared<PCMOscParameters>();
312 #elif defined SYNTHLAB_KS 313 std::shared_ptr<KSOscParameters> osc1Parameters = std::make_shared<KSOscParameters>();
314 std::shared_ptr<KSOscParameters> osc2Parameters = std::make_shared<KSOscParameters>();
315 std::shared_ptr<KSOscParameters> osc3Parameters = std::make_shared<KSOscParameters>();
316 std::shared_ptr<KSOscParameters> osc4Parameters = std::make_shared<KSOscParameters>();
317 #elif defined SYNTHLAB_DX 319 uint32_t fmAlgorithmIndex =
enumToInt(DX100Algo::kFM1);
320 std::shared_ptr<FMOperatorParameters> osc1Parameters = std::make_shared<FMOperatorParameters>();
321 std::shared_ptr<FMOperatorParameters> osc2Parameters = std::make_shared<FMOperatorParameters>();
322 std::shared_ptr<FMOperatorParameters> osc3Parameters = std::make_shared<FMOperatorParameters>();
323 std::shared_ptr<FMOperatorParameters> osc4Parameters = std::make_shared<FMOperatorParameters>();
324 #elif defined SYNTHLAB_WS 325 std::shared_ptr<WaveSequencerParameters> waveSequencerParameters = std::make_shared<WaveSequencerParameters>();
327 std::shared_ptr<WSOscParameters> wsOsc1Parameters = std::make_shared<WSOscParameters>();
328 std::shared_ptr<WSOscParameters> wsOsc2Parameters = std::make_shared<WSOscParameters>();
332 std::shared_ptr<LFOParameters> lfo1Parameters = std::make_shared<LFOParameters>();
333 std::shared_ptr<LFOParameters> lfo2Parameters = std::make_shared<LFOParameters>();
337 std::shared_ptr<EGParameters> filterEGParameters = std::make_shared<EGParameters>();
338 std::shared_ptr<EGParameters> auxEGParameters = std::make_shared<EGParameters>();
341 std::shared_ptr<FilterParameters> filter1Parameters = std::make_shared<FilterParameters>();
342 std::shared_ptr<FilterParameters> filter2Parameters = std::make_shared<FilterParameters>();
353 enum class voiceState { kNoteOnState, kNoteOffState };
425 SynthVoice(std::shared_ptr<MidiInputData> _midiInputData,
426 std::shared_ptr<MidiOutputData> _midiOutputData,
427 std::shared_ptr<SynthVoiceParameters> _parameters,
428 std::shared_ptr<WavetableDatabase> _wavetableDatabase,
429 std::shared_ptr<PCMSampleDatabase> _sampleDatabase,
430 uint32_t _blockSize = 64);
435 virtual bool reset(
double _sampleRate);
439 virtual bool initialize(
const char* dllPath =
nullptr);
470 std::unique_ptr<SynthLab::SynthLFO> lfo =
nullptr;
471 std::unique_ptr<SynthLab::EnvelopeGenerator> ampEG =
nullptr;
472 std::unique_ptr<SynthLab::WTOscillator> wtOsc =
nullptr;
473 std::unique_ptr<SynthLab::SynthFilter> filter =
nullptr;
474 std::unique_ptr<SynthLab::DCA> dca =
nullptr;
475 std::unique_ptr<SynthLab::ModMatrix> modMatrix =
nullptr;
478 double sampleRate = 0.0;
479 uint32_t blockSize = 64;
488 void accumulateToMixBuffer(std::shared_ptr<AudioBuffer> oscBuffers, uint32_t samplesInBlock,
double scaling);
489 void writeToMixBuffer(std::shared_ptr<AudioBuffer> oscBuffers, uint32_t samplesInBlock,
double scaling);
std::shared_ptr< MidiOutputData > midiOutputData
shared MIDI output data (not used in SynthLab)
Definition: synthvoice.h:483
#define enumToInt(ENUM)
macro helper to cast a typed enum to an int
Definition: synthfunctions.h:251
midiEvent voiceMIDIEvent
MIDI note event for current voice.
Definition: synthvoice.h:500
virtual bool initialize(const char *dllPath=nullptr)
Initialize the voice sub-components; this really only applies to PCM oscillators that need DLL path B...
Definition: synthvoice.cpp:120
This is the voice object for a software synth.
Definition: synthvoice.h:422
uint32_t midiData1
BYTE data 1 as UINT.
Definition: synthstructures.h:196
const uint32_t NUM_OSC
Definition: synthconstants.h:96
const uint32_t NUM_LFO
Definition: synthconstants.h:97
void accumulateToMixBuffer(std::shared_ptr< AudioBuffer > oscBuffers, uint32_t samplesInBlock, double scaling)
accumulating voice audio data
Definition: synthvoice.cpp:177
virtual bool reset(double _sampleRate)
Reset all SynthModules on init or when sample rate changes.
Definition: synthvoice.cpp:136
int32_t currentMIDINote
voice timestamp, for knowing the age of a voice
Definition: synthvoice.h:493
unsigned int getStealMIDINoteNumber()
note is data byte 1, velocity is byte 2
Definition: synthvoice.h:459
void clearTimestamp()
reset timestamp after voice is turned off
Definition: synthvoice.h:453
void writeToMixBuffer(std::shared_ptr< AudioBuffer > oscBuffers, uint32_t samplesInBlock, double scaling)
write to final mix buffer
Definition: synthvoice.cpp:201
Definition: addosccore.cpp:4
bool stealPending
stealing is inevitible
Definition: synthvoice.h:503
virtual bool doNoteOn(midiEvent &event)
Note-on handler for voice.
Definition: synthvoice.cpp:291
const uint32_t NUM_FILTER
Definition: synthconstants.h:98
void setAllCustomUpdateCodes()
one of many ways to keep track of what needs updating; this will likely be very dependent on your GUI...
Definition: synthvoice.h:462
SynthVoice(std::shared_ptr< MidiInputData > _midiInputData, std::shared_ptr< MidiOutputData > _midiOutputData, std::shared_ptr< SynthVoiceParameters > _parameters, std::shared_ptr< WavetableDatabase > _wavetableDatabase, std::shared_ptr< PCMSampleDatabase > _sampleDatabase, uint32_t _blockSize=64)
This is a template file with a minimal implementation.
Definition: synthvoice.cpp:40
voiceState getVoiceState()
Definition: synthvoice.h:447
std::shared_ptr< WavetableDatabase > wavetableDatabase
shared wavetable database
Definition: synthvoice.h:484
std::shared_ptr< PCMSampleDatabase > sampleDatabase
shared PCM database
Definition: synthvoice.h:485
virtual bool processMIDIEvent(midiEvent &event)
MIDI Event handler.
Definition: synthvoice.cpp:366
bool voiceIsStealing()
trur if voice will be stolen
Definition: synthvoice.h:460
std::shared_ptr< MidiInputData > midiInputData
shared MIDI input data
Definition: synthvoice.h:482
uint32_t timestamp
voice timestamp, for knowing the age of a voice
Definition: synthvoice.h:492
midiEvent voiceStealMIDIEvent
MIDI note event for the new (stolen) voice.
Definition: synthvoice.h:504
std::shared_ptr< AudioBuffer > mixBuffers
buffers for mixing audio and procesisng the voice digital audio engine
Definition: synthvoice.h:487
This structure holds all of the information needed to for the plugin framework to send MIDI informati...
Definition: synthbase.h:1384
Contains parameters for the Synth Voice component.
Definition: synthvoice.h:244
virtual bool render(SynthProcessInfo &synthProcessInfo)
Render a block of audio data for an active note event.
Definition: synthvoice.cpp:231
virtual ~SynthVoice()
empty destructor
Definition: synthvoice.h:432
bool isVoiceActive()
Definition: synthvoice.h:444
uint32_t getTimestamp()
get current timestamp, the higher the value, the older the voice has been running ...
Definition: synthvoice.h:451
bool voiceIsActive
activity flag
Definition: synthvoice.h:499
void incrementTimestamp()
increment timestamp when a new note is triggered
Definition: synthvoice.h:452
voiceState voiceNoteState
state variable
Definition: synthvoice.h:496
unsigned int getMIDINoteNumber()
note is data byte 1, velocity is byte 2
Definition: synthvoice.h:456
virtual bool doNoteOff(midiEvent &event)
Note-off handler for voice.
Definition: synthvoice.cpp:338
Information about a MIDI event.
Definition: synthstructures.h:166
std::shared_ptr< SynthVoiceParameters > parameters
Definition: synthvoice.h:467
virtual bool update()
Update voice specific stuff.
Definition: synthvoice.cpp:157