SynthLab SDK
synthstructures.h
1 #ifndef __synthSruxt_h__
2 #define __synthSruxt_h__
3 
4 #include <cmath>
5 #include <random>
6 #include <string>
7 #include <sstream>
8 #include <vector>
9 #include <stdint.h>
10 #include <memory>
11 
12 #include "synthconstants.h"
13 
14 #define _MATH_DEFINES_DEFINED
15 
16 namespace SynthLab
17 {
31  struct XFadeData
32  {
33  // --- stereo input/output crossfader
34  double linearGain[2] = { 0.0, 0.0 };
35  double constPwrGain[2] = { 0.0, 0.0 };
36  double squareLawGain[2] = { 0.0, 0.0 };
37  bool crossfadeFinished = false;
38  };
39 
40 
53  struct MidiOutputData
54  {
55  MidiOutputData() {}
56 
57  // --- shared MIDI tables, via IMIDIData
58  uint32_t globalMIDIData[kNumMIDIGlobals] = { 0 };
59  uint32_t ccMIDIData[kNumMIDICCs] = { 0 };
60  };
61 
74  struct WaveStringData
75  {
76  WaveStringData(uint32_t _coreIndex, uint32_t _coreWaveIndex)
77  : coreIndex(_coreIndex)
78  , coreWaveIndex(_coreWaveIndex) {}
79 
80  uint32_t coreIndex = 0;
81  uint32_t coreWaveIndex = 0;
82  };
83 
98  struct LookUpTable
99  {
100  LookUpTable(uint32_t _tableLength)
101  {
102  tableLength = _tableLength;
103  table = new double[tableLength];
104  }
105  ~LookUpTable()
106  {
107  if (table) delete[] table;
108  }
109  uint32_t tableLength = 1024;
110  double* table = nullptr;
111  };
112 
113 
127  struct PluginInfo
128  {
129  PluginInfo() {}
130 
131  PluginInfo& operator=(const PluginInfo& data) // need this override for collections to work
132  {
133  if (this == &data)
134  return *this;
135 
136  pathToDLL = data.pathToDLL;
137 
138  return *this;
139  }
140 
141  const char* pathToDLL;
142  };
143 
155  struct midiEvent
156  {
157  midiEvent() {}
158 
159  midiEvent(uint32_t _midiMessage,
160  uint32_t _midiChannel,
161  uint32_t _midiData1,
162  uint32_t _midiData2,
163  uint32_t _midiSampleOffset = 0)
164  : midiMessage(_midiMessage)
165  , midiChannel(_midiChannel)
166  , midiData1(_midiData1)
167  , midiData2(_midiData2)
168  , midiSampleOffset(_midiSampleOffset) {}
169 
170  midiEvent& operator=(const midiEvent& data) // need this override for collections to work
171  {
172  if (this == &data)
173  return *this;
174 
175  midiMessage = data.midiMessage;
176  midiChannel = data.midiChannel;
177  midiData1 = data.midiData1;
178  midiData2 = data.midiData2;
179  midiSampleOffset = data.midiSampleOffset;
180  return *this;
181  }
182 
183  uint32_t midiMessage = 0;
184  uint32_t midiChannel = 0;
185  uint32_t midiData1 = 0;
186  uint32_t midiData2 = 0;
187  uint32_t midiSampleOffset = 0;
188  };
189 
190 
202  struct GlideInfo
203  {
204  GlideInfo(uint32_t _startMIDINote, uint32_t _endMIDINote, double _glideTime_mSec, double _sampleRate)
205  : startMIDINote(_startMIDINote)
206  , endMIDINote(_endMIDINote)
207  , glideTime_mSec(_glideTime_mSec)
208  , sampleRate(_sampleRate) {}
209 
210  uint32_t startMIDINote = 0;
211  uint32_t endMIDINote = 0;
212  double glideTime_mSec = 0.0;
213  double sampleRate = 0.0;
214  };
215 
216 
228  struct MIDINoteEvent
229  {
230  // --- call with no params for default
231  MIDINoteEvent(double _midiPitch = 0.0, uint32_t _midiNoteNumber = 0, uint32_t _midiNoteVelocity = 0)
232  : midiPitch(_midiPitch)
233  , midiNoteNumber(_midiNoteNumber)
234  , midiNoteVelocity(_midiNoteVelocity) {}
235 
236  double midiPitch = 0.0;
237  uint32_t midiNoteNumber = 0;
238  uint32_t midiNoteVelocity = 0;
239  };
240 
253  struct ModuleCoreData
254  {
255  // --- one droplist control, depending on type of module can contain max 8 slots
256  const char* moduleStrings[MODULE_STRINGS];
257  const char* modKnobStrings[MOD_KNOBS];
258  };
259 
260 
272  struct MorphBankData
273  {
274  std::string bankName = empty_string.c_str();
275  uint32_t numTables = 1;
276  std::string tableNames[MODULE_STRINGS];
277  };
278 
279 } // namespace
280 
281 #endif /* defined(__synthDefs_h__) */
uint32_t midiData1
BYTE data 1 as UINT.
Definition: synthstructures.h:196
PluginInfo & operator=(const PluginInfo &data)
Definition: synthstructures.h:131
uint32_t globalMIDIData[kNumMIDIGlobals]
the global MIDI INPUT table that is shared across the voices via the IMIDIData interface ...
Definition: synthstructures.h:69
uint32_t numTables
number of wavetables in bank (up to 16)
Definition: synthstructures.h:285
double sampleRate
fs
Definition: synthstructures.h:246
uint32_t midiData2
BYTE data 2 as UINT.
Definition: synthstructures.h:197
uint32_t endMIDINote
ending MIDI note for the glide
Definition: synthstructures.h:244
std::string tableNames[MODULE_STRINGS]
names of wavetables
Definition: synthstructures.h:286
const char * moduleStrings[MODULE_STRINGS]
up to 16
Definition: synthstructures.h:267
uint32_t midiNoteNumber
note number (saved for portamento and voice steal)
Definition: synthstructures.h:221
Definition: synthengine.cpp:16
uint32_t midiChannel
BYTE channel as UINT.
Definition: synthstructures.h:195
uint32_t coreWaveIndex
selected waveform within core
Definition: synthstructures.h:92
double constPwrGain[2]
constant power coefficients
Definition: synthstructures.h:46
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:128
uint32_t coreIndex
selected core
Definition: synthstructures.h:91
bool crossfadeFinished
crossfade is done
Definition: synthstructures.h:48
double midiPitch
pitch in Hz of the MIDI note that was played
Definition: synthstructures.h:220
const char * modKnobStrings[MOD_KNOBS]
up to 4
Definition: synthstructures.h:268
double linearGain[2]
linear coefficients
Definition: synthstructures.h:45
const uint32_t MOD_KNOBS
Definition: synthconstants.h:131
uint32_t ccMIDIData[kNumMIDICCs]
the global MIDI CC INPUT table that is shared across the voices via the IMIDIData interface ...
Definition: synthstructures.h:70
double squareLawGain[2]
square law coefficients
Definition: synthstructures.h:47
const std::string empty_string
Definition: synthconstants.h:180
uint32_t startMIDINote
starting MIDI note for the glide
Definition: synthstructures.h:243
uint32_t midiMessage
BYTE message as UINT.
Definition: synthstructures.h:194
std::string bankName
one name for bank
Definition: synthstructures.h:284
uint32_t midiSampleOffset
sample offset of midi event within audio buffer
Definition: synthstructures.h:198
Structure that is used during the base class initilize( ) funciton call, after object instantiation i...
Definition: synthstructures.h:138
const char * pathToDLL
complete path to the DLL (component) without trailing backslash
Definition: synthstructures.h:152
uint32_t midiNoteVelocity
note velocity (saved for portamento and voice steal)
Definition: synthstructures.h:222
double glideTime_mSec
glide time to cover the range of notes
Definition: synthstructures.h:245
const uint32_t kNumMIDICCs
Definition: synthconstants.h:562