1 /* 2 moog1.h: 3 4 Copyright (C) 1996, 1997 Perry Cook, John ffitch 5 6 This file is part of Csound. 7 8 The Csound Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 Csound is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with Csound; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 21 02110-1301 USA 22 */ 23 24 /******************************************/ 25 /* Moog1 Subclass of */ 26 /* Sampling Synthesizer Class */ 27 /* by Perry R. Cook, 1995-96 */ 28 /* */ 29 /* Controls: CONTROL1 = filterQ */ 30 /* CONTROL2 = filterRate */ 31 /* CONTROL3 = vibFreq */ 32 /* MOD_WHEEL= vibAmt */ 33 /******************************************/ 34 35 #if !defined(__Moog1_h) 36 #define __Moog1_h 37 38 #include "fm4op.h" 39 40 /*******************************************/ 41 /* Sweepable Formant (2-pole) */ 42 /* Filter Class, by Perry R. Cook, 1995-96*/ 43 /* See books on filters to understand */ 44 /* more about how this works. Nothing */ 45 /* out of the ordinary in this version. */ 46 /*******************************************/ 47 48 typedef struct FormSwep { 49 MYFLT gain; 50 MYFLT outputs[2]; 51 MYFLT poleCoeffs[2]; 52 MYFLT freq; 53 MYFLT reson; 54 int32_t 55 dirty; 56 MYFLT targetFreq; 57 MYFLT targetReson; 58 MYFLT targetGain; 59 MYFLT currentFreq; 60 MYFLT currentReson; 61 MYFLT currentGain; 62 MYFLT deltaFreq; 63 MYFLT deltaReson; 64 MYFLT deltaGain; 65 MYFLT sweepState; 66 MYFLT sweepRate; 67 } FormSwep; 68 69 #define FormSwep_setSweepRate(p,aRate) (p.sweepRate = aRate) 70 #define FormSwep_clear(p) (p.outputs[0]=p.outputs[1]=FL(0.0)) 71 void FormSwep_setTargets(FormSwep *, MYFLT, MYFLT, MYFLT); 72 MYFLT FormSwep_tick(CSOUND *, FormSwep *, MYFLT); 73 74 typedef struct Wave { 75 FUNC *wave; 76 MYFLT rate; 77 MYFLT time; 78 MYFLT phase; 79 } Wave; 80 81 /*******************************************/ 82 /* Master Class for Sampling Synthesizer */ 83 /* by Perry R. Cook, 1995-96 */ 84 /* This instrument contains up to 5 */ 85 /* attack waves, 5 looped waves, and */ 86 /* an ADSR envelope. */ 87 /*******************************************/ 88 89 typedef struct MOOG1 { 90 OPDS h; 91 MYFLT *ar; /* Output */ 92 MYFLT *amp, *frequency; 93 MYFLT *filterQ, *filterRate, *vibf, *vibAmt; 94 MYFLT *iatt, *ifn, *ivfn; 95 96 ADSR adsr; 97 Wave attk; /* Not looped */ 98 Wave loop; /* Looped */ 99 Wave vibr; /* Looped */ 100 OnePole filter; 101 MYFLT baseFreq; 102 MYFLT attackRatio; 103 MYFLT loopRatio; 104 MYFLT attackGain; 105 MYFLT loopGain; 106 MYFLT oldfilterQ; 107 MYFLT oldfilterRate; 108 FormSwep filters[2]; 109 TwoZero twozeroes[2]; 110 } MOOG1; 111 112 #endif 113 114