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 OSC 24 #define OSC 25 26 27 class Oscillator 28 { 29 public: 30 Oscillator(); 31 ~Oscillator(); 32 33 enum Type{NONE,SQUARE,SAW,NOISE}; 34 35 void GetOutput(int V,short *data); ModulateFreq(short * data)36 void ModulateFreq(short *data) {m_FreqModBuf=data;} ModulatePulseWidth(short * data)37 void ModulatePulseWidth(short *data) {m_PulseWidthModBuf=data;} ModulateSHLen(short * data)38 void ModulateSHLen(short *data) {m_SHModBuf=data;} 39 40 void NoteTrigger(int V,int octave,int s,int v); SetOctave(int o)41 void SetOctave(int o) {m_Octave=o;} SetFineFreq(float f)42 void SetFineFreq(float f) {m_FineFreq=f;} SetPulseWidth(float p)43 void SetPulseWidth(float p) {m_PulseWidth=p;} SetType(Type t)44 void SetType(Type t) {m_Type=t;} SetSHLen(float s)45 void SetSHLen(float s) {m_SHLen=s;} SetModAmount(float s)46 void SetModAmount(float s) {m_ModAmount=s;} SetPortmento(float s)47 void SetPortmento(float s) {m_PortmentoSpeed=s;} SetVolume(int V,int s)48 void SetVolume(int V, int s) {m_Volume[V]=s;} GetOctave()49 int GetOctave() {return m_Octave;} GetFineFreq()50 float GetFineFreq() {return m_FineFreq;} GetPulseWidth()51 float GetPulseWidth() {return m_PulseWidth;} GetType()52 Type GetType() {return m_Type;} GetSHLen()53 float GetSHLen() {return m_SHLen;} GetModAmount()54 float GetModAmount() {return m_ModAmount;} GetPortmento()55 float GetPortmento() {return m_PortmentoSpeed;} GetVolume(int V)56 int GetVolume(int V) {return m_Volume[V];} 57 void Randomise(); 58 59 private: 60 61 // Voice specific parameters 62 int *m_InOctave; 63 int *m_Note; 64 int *m_CyclePos; 65 float *m_LastFreq; 66 char *m_Volume; 67 68 // Common voice parameters 69 Type m_Type; 70 int m_Octave; 71 float m_FineFreq; 72 float m_PulseWidth; 73 float m_PortmentoSpeed; 74 float m_DesiredFreq; 75 float m_SHLen; 76 float m_ModAmount; 77 short *m_FreqModBuf; 78 short *m_PulseWidthModBuf; 79 short *m_SHModBuf; 80 81 friend istream &operator>>(istream &s, Oscillator &o); 82 friend ostream &operator<<(ostream &s, Oscillator &o); 83 84 }; 85 86 istream &operator>>(istream &s, Oscillator &o); 87 ostream &operator<<(ostream &s, Oscillator &o); 88 89 #endif 90