Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related envelope.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 __envelope__ 00012 #define __envelope__ 00013 00014 00015 #include "math.h" 00016 #include <iostream> 00017 #include <vector> 00018 #include "modules.h" 00019 00020 // Helper classes for the envelope3 class ---------------------------------------------------------------------- 00021 00022 namespace SynthCore { 00023 00025 class coord { 00026 public: 00027 float x; 00028 float y; 00029 coord() {x = 0; y = 0;}; 00030 coord(float mx, float my) {x = mx; y = my;}; 00031 }; 00032 00034 typedef std::vector<coord *>::const_iterator pointsIter ; 00035 00037 00047 class EnvData { 00048 public: 00050 bool endOfEnvelope ; 00051 00053 std::vector<coord *> points; 00054 00056 float * envdata; 00057 00059 float sampleLength; 00060 00062 int envsize; 00063 00065 void clearEnvelope() ; 00066 00068 void setADSR(float A, float D, float S, float R) ; 00069 00071 int beginLP; 00073 int endLP; 00074 00076 int loopStart; 00078 int loopEnd; 00079 00081 enum loopStateEnum {dontLoop, sustainedLoop, alwaysLoop}; 00082 00084 loopStateEnum loopState; 00085 00087 int choosen; 00088 void setChoosen(int j) {choosen = j;} 00089 int getChoosen() {return choosen;} 00090 00091 void getLimits(float &x0, float &y0, float &x1, float &y1); 00092 00093 void interpolateLinear(); 00094 00096 void interpolateSpline(); 00097 00099 void interpolate() { interpolateSpline(); } 00100 00101 void removePoint(int p); 00102 void addPoint(float x, float y) ; 00103 00106 float getValue(long &time, bool loop); 00107 00108 00109 00110 std::string getXML(int indent ); 00111 00112 EnvData() ; 00113 ~EnvData() ; 00114 }; 00115 00116 00117 00119 00129 class Envelope3 : public Module { 00130 00131 00132 public: // ----------------------------------------------------------------- 00133 00138 bool killVoice; 00139 00140 00141 00143 EnvData * myData; 00144 00146 virtual std::string getName() {return "Envelope3";} 00147 00149 Output * Output1; 00151 Input * Input1; 00152 00154 void setDuration(int calls) ; 00155 00157 static Module * newInstance(SynthVoice * s) { return new Envelope3(s); } 00158 00159 00162 virtual Module * sharedClone() ; 00163 00164 00166 Envelope3(SynthVoice * s); 00167 00169 ~Envelope3(); 00170 00172 void update() ; 00173 00175 void loadXML(XMLNode * n, bool firstPass); 00176 00177 std::string getXML(int indent ); 00178 00179 private: // ---------------------------------------------------------------- 00180 00182 bool OldNoteOn; 00183 float amp; 00184 long time; 00185 00186 }; 00187 00188 }; // end of namespace: SynthCore 00189 00190 #endif 00191 Docs made by Doxygen. Email: Mikael Christensen |