SUBnote.h (3663B)
1 /* 2 ZynAddSubFX - a software synthesizer 3 4 SUBnote.h - The subtractive synthesizer 5 Copyright (C) 2002-2005 Nasca Octavian Paul 6 Author: Nasca Octavian Paul 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 */ 13 14 #ifndef SUB_NOTE_H 15 #define SUB_NOTE_H 16 17 #include "SynthNote.h" 18 #include "../globals.h" 19 #include "WatchPoint.h" 20 21 namespace zyn { 22 23 class SUBnote:public SynthNote 24 { 25 public: 26 SUBnote(const SUBnoteParameters *parameters, const SynthParams &pars, 27 WatchManager *wm = 0, const char *prefix = 0); 28 ~SUBnote(); 29 30 SynthNote *cloneLegato(void); 31 void legatonote(const LegatoParams &pars); 32 VecWatchPoint watch_filter,watch_amp_int, watch_legato; 33 int noteout(float *outl, float *outr); //note output,return 0 if the note is finished 34 void releasekey(); 35 bool finished() const; 36 void entomb(void); 37 private: 38 39 void setup(float velocity, 40 Portamento *portamento_, 41 float note_log2_freq, 42 bool legato = false, WatchManager *wm = 0, const char *prefix = 0); 43 float setupFilters(float basefreq, int *pos, bool automation); 44 void computecurrentparameters(); 45 /* 46 * Initialize envelopes and global filter 47 * calls computercurrentparameters() 48 */ 49 void initparameters(float freq, WatchManager *wm, const char *prefix); 50 void KillNote(); 51 52 const SUBnoteParameters &pars; 53 54 //parameters 55 bool stereo; 56 int numstages; //number of stages of filters 57 int numharmonics; //number of harmonics (after the too higher hamonics are removed) 58 int firstnumharmonics; //To keep track of the first note's numharmonics value, useful in legato mode. 59 int start; //how the harmonics start 60 float note_log2_freq; 61 float BendAdjust; 62 float OffsetHz; 63 float panning; 64 Envelope *AmpEnvelope; 65 Envelope *FreqEnvelope; 66 Envelope *BandWidthEnvelope; 67 68 ModFilter *GlobalFilter; 69 Envelope *GlobalFilterEnvelope; 70 71 //internal values 72 bool NoteEnabled; 73 bool firsttick; 74 Portamento *portamento; 75 float volume, oldamplitude, newamplitude; 76 float oldreduceamp; 77 78 struct bpfilter { 79 float freq, bw, amp; //filter parameters 80 float a1, a2, b0, b2; //filter coefs. b1=0 81 float xn1, xn2, yn1, yn2; //filter internal values 82 }; 83 84 void chanOutput(float *out, bpfilter *bp, int buffer_size); 85 86 void initfilter(bpfilter &filter, 87 float freq, 88 float bw, 89 float amp, 90 float mag, 91 bool automation); 92 float computerolloff(float freq); 93 void computeallfiltercoefs(bpfilter *filters, float envfreq, float envbw, float gain); 94 void computefiltercoefs(bpfilter &filter, 95 float freq, 96 float bw, 97 float gain); 98 inline void filter(bpfilter &filter, float *smps); 99 100 bpfilter *lfilter, *rfilter; 101 102 float overtone_rolloff[MAX_SUB_HARMONICS]; 103 float overtone_freq[MAX_SUB_HARMONICS]; 104 105 int oldpitchwheel, oldbandwidth; 106 float velocity; 107 bool filterupdate; 108 }; 109 110 } 111 112 #endif