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 #ifndef MAINSYNTH 20 #define MAINSYNTH 21 22 #include <FL/Fl.H> 23 #include <FL/Fl_Window.H> 24 #include <FL/Fl_Group.H> 25 #include <FL/Fl_Button.H> 26 #include <sstream> 27 #include "GUI/OscillatorGUI.h" 28 #include "GUI/EnvelopeGUI.h" 29 #include "GUI/FilterGUI.h" 30 #include "GUI/MixerGUI.h" 31 #include "GUI/DelayGUI.h" 32 #include "GUI/SequencerGUI.h" 33 #include "GUI/OutputGUI.h" 34 #include "GUI/ScopeGUI.h" 35 #include "GUI/PatchBankGUI.h" 36 #include "GUI/RouteGUI.h" 37 #include "SpiralSound/Amp.h" 38 #include "SpiralSound/Midi.h" 39 #include "SpiralSound/SpiralInfo.h" 40 41 const int NUM_PATCHES=100; 42 const int PATCH_STRINGSIZE=1024; 43 44 class Synth 45 { 46 public: 47 Synth(); 48 ~Synth(); 49 50 Fl_Window *CreateWindow(); 51 short *DoIdle(); CloseMidi()52 void CloseMidi() {m_Midi.Close();} 53 54 Fl_Window *Window; 55 56 private: 57 58 void AllocMem(); 59 60 void Trigger(int octave, int note, int vol); 61 void UnTrigger(int octave, int note); 62 void PitchBend(int amount); 63 void ChangeParameter(int CC,int amount); 64 65 int m_Oct; 66 int m_CurrentVoice; 67 68 // list of keys currently pressed down 69 char *m_KeyVoice; 70 71 // list of notes being played by each voice 72 int *m_VoiceNote; 73 int *m_VoiceOctave; 74 75 // These buffers require malloc'ing 76 short *m_Databuf; 77 short *m_Databuf2; 78 short *m_Databuf3; 79 short *m_OscControlbuf1; 80 short *m_OscControlbuf2; 81 short *m_OscControlbuf3; 82 short *m_EnvControlbuf; 83 short *m_LFOControlbuf; 84 short *m_BothControlbuf; 85 86 // One per voice needed 87 short **m_XModbuf1; 88 short **m_XModbuf2; 89 90 Oscillator m_Osc1; 91 OscillatorGUI m_Osc1GUI; 92 Oscillator m_Osc2; 93 OscillatorGUI m_Osc2GUI; 94 Oscillator m_Osc3; 95 OscillatorGUI m_Osc3GUI; 96 Envelope m_Env1; 97 EnvelopeGUI m_Env1GUI; 98 Amp m_OscAmp1; 99 Envelope m_Env2; 100 EnvelopeGUI m_Env2GUI; 101 Amp m_OscAmp2; 102 Envelope m_Env3; 103 EnvelopeGUI m_Env3GUI; 104 Amp m_OscAmp3; 105 Filter m_Filter; 106 FilterGUI m_FilterGUI; 107 Mixer m_Mixer; 108 MixerGUI m_MixerGUI; 109 Mixer m_Mixer2; 110 MixerGUI m_Mixer2GUI; 111 Delay m_Delay; 112 DelayGUI m_DelayGUI; 113 Envelope m_FilterEnv; 114 EnvelopeGUI m_FilterEnvGUI; 115 Oscillator m_LFO; 116 LFOGUI m_LFOGUI; 117 RouteGUI m_LFORouteGUI; 118 RouteGUI m_EnvRouteGUI; 119 120 PatchBankGUI m_PatchBank; 121 122 //Sequencer m_Seq; 123 //SequencerGUI m_SeqGUI; 124 125 Output m_Out; 126 OutputGUI m_OutGUI; 127 128 ScopeGUI m_Scope; 129 130 MidiDevice m_Midi; 131 MidiEvent m_CurrentEvent; 132 133 int m_CurrentPatch; 134 135 void SavePatch(int n); 136 void LoadPatch(int n); 137 138 void WritePatch(int n, char *in); 139 int ReadPatch(int n, char *out); 140 141 void Randomise(); 142 143 void UpdateValues(); 144 145 void Route(); 146 147 friend istream &operator>>(istream &s, Synth &o); 148 friend ostream &operator<<(ostream &s, Synth &o); 149 150 151 }; 152 153 istream &operator>>(istream &s, Synth &o); 154 ostream &operator<<(ostream &s, Synth &o); 155 156 #endif 157