Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related sampler.h00001 // 00002 // SYNTOPIA. See http://Syntopia.sourceforge.net for details and documentation. 00003 // 00004 // Author of this file: Mikael Hvidtfeldt Christensen (mikaelc@users.sourceforge.net) 00005 // 00006 00007 00008 // Visual C++ compiler warnings: 255 char limit on var names..... 00009 #pragma warning(disable: 4786) 00010 00011 #ifndef __sampler__ 00012 #define __sampler__ 00013 00014 #include "Modules.h" 00015 #include "input.h" 00016 #include "output.h" 00017 #include "sndutils.h" 00018 #include <string> 00019 00020 namespace SynthCore { 00021 00023 00024 class SampleMap { 00025 public: 00026 00027 00028 Sample * map[128]; 00029 00031 SampleMap() { 00032 for (int i=0;i<128; i++) { 00033 map[i]= 0; 00034 } 00035 }; 00036 00038 ~SampleMap() { 00039 clean(); 00040 }; 00041 00043 void clean() { 00044 for (int i=0;i<128; i++) { 00045 if (map[i]!=0) {delete map[i]; map[i]=0;} 00046 } 00047 } 00048 00050 float * getSamples(int Midikey) { 00051 if ((Midikey < 128) && (Midikey > 0)) 00052 { 00053 return map[Midikey]->samples; 00054 } 00055 return 0; 00056 } 00057 00058 00059 }; 00060 00062 00076 class Sampler : public Module { 00077 00078 public: // ---------------------------------------------------------------------- 00079 00081 enum {sine,triangle,sawtooth,square,wave1,wave2,wave3,wave4} waveformType ; 00082 00085 int factoryWaveform; 00086 00088 void loadXML(XMLNode * n, bool firstPass); 00089 00090 std::string getXML(int indent); 00091 00093 enum {none, linear, Lagrange, cubicHermite, spline5Point, sinc, sincWindow, pureSine}; 00094 00096 int interpolationType; 00097 00099 void newMidiEvent() ; 00100 00102 virtual std::string getName() {return "Sampler";} 00103 00104 // Mono Module 00105 Output * Output1; 00106 00108 static Module * newInstance(SynthVoice * S1) ; 00109 00110 // Constructor 00111 Sampler(SynthVoice * S1); 00112 00113 // Destructor; 00114 ~Sampler() ; 00115 00116 00119 virtual Module * sharedClone() ; 00120 00121 00123 void update() ; 00124 00126 void setMidiNote(int note); 00127 00129 void setTriangle(int length); 00130 00132 void setSquare(int length); 00133 00135 void setSawtooth(int length); 00136 00138 void setSine(int length); 00139 00140 // Extra waveforms. 00141 void setWave1(int length); 00142 void setWave2(int length); 00143 void setWave3(int length); 00144 void setWave4(int length); 00145 00146 00148 void resetPhase(); 00149 00150 private: // --------------------------------------------------------------------- 00151 00154 FreqTable * freqs; 00155 00157 float freq; 00158 00160 float pos; 00161 00163 float * sample; 00164 00166 SampleMap * mySampleMap; 00167 00168 // for debug 00169 float MAX; 00170 float MIN; 00171 00172 }; 00173 00174 }; // end of namespace: SynthCore 00175 00176 #endif Docs made by Doxygen. Email: Mikael Christensen |