1 /* SpiralSynth 2 * Copyleft (C) 2000 David Griffiths <dave@pawfal.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 #include <math.h> 20 #include "NoteTable.h" 21 #include "SpiralInfo.h" 22 23 #ifndef ENV 24 #define ENV 25 26 27 class Envelope 28 { 29 public: 30 Envelope(); 31 ~Envelope(); 32 Trigger(int V)33 void Trigger(int V) {m_t[V]=0.0f; m_Trigger[V]=true;} UnTrigger(int V)34 void UnTrigger(int V) {m_Trigger[V]=false;} 35 void GetOutput(int V, short *data); 36 void Zero(short *data); SetAttack(float s)37 void SetAttack(float s) {m_Attack=s;} SetDecay(float s)38 void SetDecay(float s) {m_Decay=s;} SetSustain(float s)39 void SetSustain(float s) {m_Sustain=s;} SetRelease(float s)40 void SetRelease(float s) {m_Release=s;} SetVolume(float s)41 void SetVolume(float s) {m_Volume=s;} GetAttack()42 float GetAttack() {return m_Attack;} GetDecay()43 float GetDecay() {return m_Decay;} GetSustain()44 float GetSustain() {return m_Sustain;} GetRelease()45 float GetRelease() {return m_Release;} GetVolume()46 float GetVolume() {return m_Volume;} 47 void Randomise(); 48 49 private: 50 51 // Voice specific parameters 52 bool *m_Trigger; 53 double *m_t; 54 55 // Common voice parameters 56 float m_Attack; 57 float m_Decay; 58 float m_Sustain; 59 float m_Release; 60 float m_Volume; 61 double m_SampleTime; 62 63 friend istream &operator>>(istream &s, Envelope &o); 64 friend ostream &operator<<(ostream &s, Envelope &o); 65 }; 66 67 istream &operator>>(istream &s, Envelope &o); 68 ostream &operator<<(ostream &s, Envelope &o); 69 70 #endif 71