SynthLab SDK
wavetabledata.h
1 #ifndef __wavetableData_h__
2 #define __wavetableData_h__
3 
4 // --- includes
5 #include "synthbase.h"
6 
7 // --- wavetable objects and structs
8 #include "wavetablebank.h"
9 
10 // --- .h file examples
11 //#include "wavetables\AKWF_0.h"
12 //#include "wavetables\Found_0.h"
13 //#include "wavetables\MorphWave_0.h"
14 
15 namespace SynthLab
16 {
17  // --- stores MAX_BANKS_PER_PLUGIN sets of IWaveBanks (128)
18  // BANK Source
19  // --------- -------------------
20  // 0 - 63 Factory Reserved
21  // 64 - 127 User banks
22  //
23  // NOTE: this is the ONE AND ONLY wavetable datasource for the entire synth
24  // So, initialize everything here.
25  class WaveTableData : public IWaveData
26  {
27  public:
29  {
30  // --- create wave banks here --- all construction is in this function
31  WaveTableBank* bank_0 = new WaveTableBank;
32  bank_0->setWaveBankName("Sik Tables");
33 
34  // --- init from bank; must #include the .h file with these variables inside; they will be different for each table in the bank
35  // bank_0->initializeWithHiResWTBank(AKWF_0_BankDescriptor);
36 
37  // --- add the bank to the container
38  waveBanks.push_back(bank_0);
39 
40  WaveTableBank* bank_1 = new WaveTableBank;
41  bank_1->setWaveBankName("Found Tables");
42 
43  // --- init from bank; must #include the .h file with these variables inside; they will be different for each table in the bank
44  //bank_1->initializeWithHiResWTBank(Found_0_BankDescriptor);
45 
46  // --- add the bank to the container
47  waveBanks.push_back(bank_1);
48 
50  //WaveTableBank* bank_2 = new WaveTableBank;
51  //bank_2->setWaveBankName("MorphMetalic");
52  //bank_2->setIsMorphingBank();
53 
55  //bank_2->initializeWithHiResMorphingWTBank(MorphWave_0_BankDescriptor);
56 
57  // --- add the bank to the container
58  // waveBanks.push_back(bank_2);
59 
60 
61 
62  // --- now we load up the rest of the array with EMPTY wavetable banks
63  int count = waveBanks.size();
64  for (int i = count; i < MAX_BANKS_PER_OSCILLATOR; i++)
65  {
66  // --- create disabled, but instantiated, banks
67  WaveTableBank* emptyBank = new WaveTableBank;
68  // emptyBank->setEnabled(false);
69  if (i <= FACTORY_BANK_END)
70  emptyBank->setWaveBankName("Factory Reserved");
71  else
72  emptyBank->setWaveBankName("User Reserved");
73 
74  waveBanks.push_back(emptyBank);
75  }
76 
77  }
78 
79  ~WaveTableData()
80  {
81  for (int i = 0; i < waveBanks.size(); i++)
82  {
83  WaveTableBank* wtBank = waveBanks[i];
84  if (wtBank) delete wtBank;
85  }
86  waveBanks.clear();
87  }
88 
89  virtual bool resetWaveBanks(double sampleRate)
90  {
91  uint32_t bankCount = getNumWaveBanks();
92 
93  for (int i = 0; i < bankCount; i++) {
94  WaveTableBank* wtBank = waveBanks[i];
95  if (wtBank) wtBank->resetWaveTables(sampleRate);
96  }
97 
98  return (bool)bankCount;
99  }
100 
101  virtual IWaveBank* getInterface(uint32_t waveBankIndex)
102  {
103  if (waveBankIndex >= waveBanks.size() - 1)
104  waveBankIndex = waveBanks.size() - 1;
105 
106  if (waveBankIndex < 0)
107  return nullptr; // should never happen; will crash
108 
109  return waveBanks[waveBankIndex];
110  }
111 
112  // --- get the number of banks for this datasource
113  virtual uint32_t getNumWaveBanks() { return waveBanks.size(); }
114 
115  // --- returns the names of the waveforms, which are identical to the indexes of waveform selection on the GUI
116  // If there is no waveform, returns "" for that
117  virtual std::vector<std::string> getWaveBankNames(uint32_t bankSet = 0)
118  {
119  // --- load up a vector of strings
120  std::vector<std::string> stringList;
121  uint32_t bankCount = getNumWaveBanks();
122  uint32_t start = bankSet*MAX_BANKS_PER_OSCILLATOR;
123 
124  for (int i = start; i < MAX_BANKS_PER_OSCILLATOR; i++)
125  {
126  if (i < bankCount)
127  stringList.push_back(waveBanks[i]->getWaveBankName());
128  else
129  stringList.push_back("-- empty --");
130  }
131 
132  return stringList;
133  }
134 
135  private:
136  // --- vector of wavetables
137  std::vector<WaveTableBank*> waveBanks;
138  };
139 
140 
141 }
142 
143 #endif /* defined(__wavetableData_h__) */
Definition: analogegcore.cpp:4
Definition: wavetablebank.h:61
Definition: wavetabledata.h:25
Definition: synthbase.h:1896
Definition: synthbase.h:1876