1 #ifndef __synthVoice_h__ 2 #define __synthVoice_h__ 29 struct SynthVoiceParameters
31 SynthVoiceParameters() {}
34 uint32_t synthModeIndex =
enumToInt(SynthMode::kMono);
37 uint32_t filterModeIndex =
enumToInt(FilterMode::kSeries);
40 bool enablePortamento =
false;
43 double glideTime_mSec = 0.0;
46 bool legatoMode =
false;
49 double unisonDetuneCents = 0.0;
50 double unisonStartPhase = 0.0;
51 double unisonPan = 0.0;
57 enum class voiceState { kNoteOnState, kNoteOffState };
129 SynthVoice(std::shared_ptr<MidiInputData> _midiInputData,
130 std::shared_ptr<MidiOutputData> _midiOutputData,
131 std::shared_ptr<SynthVoiceParameters> _parameters,
132 std::shared_ptr<WavetableDatabase> _wavetableDatabase,
133 std::shared_ptr<PCMSampleDatabase> _sampleDatabase,
134 uint32_t _blockSize = 64);
139 virtual bool reset(
double _sampleRate);
143 virtual bool initialize(
const char* dllPath =
nullptr);
168 std::shared_ptr<SynthVoiceParameters>
parameters =
nullptr;
171 double sampleRate = 0.0;
172 uint32_t blockSize = 64;
180 std::shared_ptr<AudioBuffer>
mixBuffers =
nullptr;
181 void accumulateToMixBuffer(std::shared_ptr<AudioBuffer> oscBuffers, uint32_t samplesInBlock,
double scaling);
182 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
uint32_t midiData1
BYTE data 1 as UINT.
Definition: synthstructures.h:196
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:163
void clearTimestamp()
reset timestamp after voice is turned off
Definition: synthvoice.h:157
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
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:151
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:164
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
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:136
bool isVoiceActive()
Definition: synthvoice.h:148
uint32_t getTimestamp()
get current timestamp, the higher the value, the older the voice has been running ...
Definition: synthvoice.h:155
bool voiceIsActive
activity flag
Definition: synthvoice.h:499
void incrementTimestamp()
increment timestamp when a new note is triggered
Definition: synthvoice.h:156
voiceState voiceNoteState
state variable
Definition: synthvoice.h:496
unsigned int getMIDINoteNumber()
note is data byte 1, velocity is byte 2
Definition: synthvoice.h:160
hard-coded arrays of FIR filter coefficients for the sample rate conversion objects (Interpolator and...
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
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.