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 // -----------------------------
17 // --- SynthLab SDK File --- //
18 // ----------------------------
26 // -----------------------------------------------------------------------------
27 namespace SynthLab
28 {
42  struct XFadeData
43  {
44  // --- stereo input/output crossfader
45  double linearGain[2] = { 0.0, 0.0 };
46  double constPwrGain[2] = { 0.0, 0.0 };
47  double squareLawGain[2] = { 0.0, 0.0 };
48  bool crossfadeFinished = false;
49  };
50 
51 
65  {
66  MidiOutputData() {}
67 
68  // --- shared MIDI tables, via IMIDIData
69  uint32_t globalMIDIData[kNumMIDIGlobals] = { 0 };
70  uint32_t ccMIDIData[kNumMIDICCs] = { 0 };
71  };
72 
86  {
87  WaveStringData(uint32_t _coreIndex, uint32_t _coreWaveIndex)
88  : coreIndex(_coreIndex)
89  , coreWaveIndex(_coreWaveIndex) {}
90 
91  uint32_t coreIndex = 0;
92  uint32_t coreWaveIndex = 0;
93  };
94 
109  struct LookUpTable
110  {
111  LookUpTable(uint32_t _tableLength)
112  {
113  tableLength = _tableLength;
114  table = new double[tableLength];
115  }
116  ~LookUpTable()
117  {
118  if (table) delete[] table;
119  }
120  uint32_t tableLength = 1024;
121  double* table = nullptr;
122  };
123 
124 
138  struct PluginInfo
139  {
140  PluginInfo() {}
141 
142  PluginInfo& operator=(const PluginInfo& data) // need this override for collections to work
143  {
144  if (this == &data)
145  return *this;
146 
147  pathToDLL = data.pathToDLL;
148 
149  return *this;
150  }
151 
152  const char* pathToDLL;
153  };
154 
166  struct midiEvent
167  {
168  midiEvent() {}
169 
170  midiEvent(uint32_t _midiMessage,
171  uint32_t _midiChannel,
172  uint32_t _midiData1,
173  uint32_t _midiData2,
174  uint32_t _midiSampleOffset = 0)
175  : midiMessage(_midiMessage)
176  , midiChannel(_midiChannel)
177  , midiData1(_midiData1)
178  , midiData2(_midiData2)
179  , midiSampleOffset(_midiSampleOffset) {}
180 
181  midiEvent& operator=(const midiEvent& data) // need this override for collections to work
182  {
183  if (this == &data)
184  return *this;
185 
186  midiMessage = data.midiMessage;
187  midiChannel = data.midiChannel;
188  midiData1 = data.midiData1;
189  midiData2 = data.midiData2;
191  return *this;
192  }
193 
194  uint32_t midiMessage = 0;
195  uint32_t midiChannel = 0;
196  uint32_t midiData1 = 0;
197  uint32_t midiData2 = 0;
198  uint32_t midiSampleOffset = 0;
199  };
200 
213  {
214  // --- call with no params for default
215  MIDINoteEvent(double _midiPitch = 0.0, uint32_t _midiNoteNumber = 0, uint32_t _midiNoteVelocity = 0)
216  : midiPitch(_midiPitch)
217  , midiNoteNumber(_midiNoteNumber)
218  , midiNoteVelocity(_midiNoteVelocity) {}
219 
220  double midiPitch = 0.0;
221  uint32_t midiNoteNumber = 0;
222  uint32_t midiNoteVelocity = 0;
223  };
235  struct GlideInfo
236  {
237  GlideInfo(uint32_t _startMIDINote, uint32_t _endMIDINote, double _glideTime_mSec, double _sampleRate)
238  : startMIDINote(_startMIDINote)
239  , endMIDINote(_endMIDINote)
240  , glideTime_mSec(_glideTime_mSec)
241  , sampleRate(_sampleRate) {}
242 
243  uint32_t startMIDINote = 0;
244  uint32_t endMIDINote = 0;
245  double glideTime_mSec = 0.0;
246  double sampleRate = 0.0;
247  };
248 
249 
250 
251 
265  {
266  // --- one droplist control, depending on type of module can contain max 8 slots
267  const char* moduleStrings[MODULE_STRINGS] = { "","","","","","","","","","","","","","","","" };
268  int32_t uniqueIndexes[MODULE_STRINGS] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
269  const char* modKnobStrings[MOD_KNOBS] = { "","","","" };
270  };
271 
273  //\struct MorphBankData
274  //\ingroup SynthStructures
275  //\brief
276  //Information about a bank of wavetables that are used in the morphing wavetable core.
277 
278  //\author Will Pirkle http://www.willpirkle.com
279  //\remark This object is included in Designing Software Synthesizer Plugins in C++ 2nd Ed. by Will Pirkle
280  //\version Revision : 1.0
281  //\date Date : 2021 / 05 / 02
282  //*/
283  //struct MorphBankData
284  //{
285  // std::string bankName = empty_string.c_str(); ///< one name for bank
286  // uint32_t numTables = 1; ///< number of wavetables in bank (up to 16)
287  // std::string tableNames[MODULE_STRINGS]; ///< names of wavetables
288  // int32_t tableIndexes[MODULE_STRINGS] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 }; ///< unique indexes for faster lookup
289  // StaticTableSource wavetables[MODULE_STRINGS];
290  //};
291 
292 } // namespace
293 
294 #endif /* defined(__synthDefs_h__) */
const char * pathToDLL
complete path to the DLL (component) without trailing backslash
Definition: synthstructures.h:152
const char * moduleStrings[MODULE_STRINGS]
up to 16
Definition: synthstructures.h:267
uint32_t midiData1
BYTE data 1 as UINT.
Definition: synthstructures.h:196
PluginInfo & operator=(const PluginInfo &data)
Definition: synthstructures.h:142
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
Structure to hold a dynamic LUT and its length.
Definition: synthstructures.h:109
Information about the selected core and the selected wavform within that core.
Definition: synthstructures.h:85
uint32_t midiNoteNumber
note number (saved for portamento and voice steal)
Definition: synthstructures.h:221
Definition: addosccore.cpp:4
const char * modKnobStrings[MOD_KNOBS]
up to 4
Definition: synthstructures.h:269
uint32_t midiChannel
BYTE channel as UINT.
Definition: synthstructures.h:195
Definition: synthstructures.h:235
uint32_t coreWaveIndex
selected waveform within core
Definition: synthstructures.h:92
const uint32_t MODULE_STRINGS
Definition: synthconstants.h:130
uint32_t coreIndex
selected core
Definition: synthstructures.h:91
bool crossfadeFinished
crossfade is done
Definition: synthstructures.h:48
uint32_t globalMIDIData[kNumMIDIGlobals]
the global MIDI INPUT table that is shared across the voices via the IMIDIData interface ...
Definition: synthstructures.h:69
double constPwrGain[2]
constant power coefficients
Definition: synthstructures.h:46
double midiPitch
pitch in Hz of the MIDI note that was played
Definition: synthstructures.h:220
const uint32_t MOD_KNOBS
Definition: synthconstants.h:135
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
Data about a crossfade operation.
Definition: synthstructures.h:42
double linearGain[2]
linear coefficients
Definition: synthstructures.h:45
MIDI output message and data information.
Definition: synthstructures.h:64
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.
uint32_t startMIDINote
starting MIDI note for the glide
Definition: synthstructures.h:243
uint32_t midiMessage
BYTE message as UINT.
Definition: synthstructures.h:194
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
Information about a MIDI event.
Definition: synthstructures.h:166
int32_t uniqueIndexes[MODULE_STRINGS]
up to 16
Definition: synthstructures.h:268
Contains the two sets of strings unique to each core: the module strings (waveforms for oscillators) ...
Definition: synthstructures.h:264
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:577
Information about a MIDI note event (note on or note off).
Definition: synthstructures.h:212