1 /***************************************************/ 2 /*! \class Modal 3 \brief STK resonance model instrument. 4 5 This class contains an excitation wavetable, 6 an envelope, an oscillator, and N resonances 7 (non-sweeping BiQuad filters), where N is set 8 during instantiation. 9 10 by Perry R. Cook and Gary P. Scavone, 1995 - 2005. 11 */ 12 /***************************************************/ 13 14 #ifndef STK_MODAL_H 15 #define STK_MODAL_H 16 17 #include "Instrmnt.h" 18 #include "Envelope.h" 19 #include "WaveLoop.h" 20 #include "SineWave.h" 21 #include "BiQuad.h" 22 #include "OnePole.h" 23 24 namespace Nyq 25 { 26 27 class Modal : public Instrmnt 28 { 29 public: 30 //! Class constructor, taking the desired number of modes to create. 31 /*! 32 An StkError will be thrown if the rawwave path is incorrectly set. 33 */ 34 Modal( unsigned int modes = 4 ); 35 36 //! Class destructor. 37 virtual ~Modal(); 38 39 //! Reset and clear all internal state. 40 void clear(); 41 42 //! Set instrument parameters for a particular frequency. 43 virtual void setFrequency(StkFloat frequency); 44 45 //! Set the ratio and radius for a specified mode filter. 46 void setRatioAndRadius(unsigned int modeIndex, StkFloat ratio, StkFloat radius); 47 48 //! Set the master gain. 49 void setMasterGain(StkFloat aGain); 50 51 //! Set the direct gain. 52 void setDirectGain(StkFloat aGain); 53 54 //! Set the gain for a specified mode filter. 55 void setModeGain(unsigned int modeIndex, StkFloat gain); 56 57 //! Initiate a strike with the given amplitude (0.0 - 1.0). 58 virtual void strike(StkFloat amplitude); 59 60 //! Damp modes with a given decay factor (0.0 - 1.0). 61 void damp(StkFloat amplitude); 62 63 //! Start a note with the given frequency and amplitude. 64 void noteOn(StkFloat frequency, StkFloat amplitude); 65 66 //! Stop a note with the given amplitude (speed of decay). 67 void noteOff(StkFloat amplitude); 68 69 //! Perform the control change specified by \e number and \e value (0.0 - 128.0). 70 virtual void controlChange(int number, StkFloat value) = 0; 71 72 protected: 73 74 StkFloat computeSample( void ); 75 76 Envelope envelope_; 77 FileWvIn *wave_; 78 BiQuad **filters_; 79 OnePole onepole_; 80 SineWave vibrato_; 81 82 unsigned int nModes_; 83 std::vector<StkFloat> ratios_; 84 std::vector<StkFloat> radii_; 85 86 StkFloat vibratoGain_; 87 StkFloat masterGain_; 88 StkFloat directGain_; 89 StkFloat stickHardness_; 90 StkFloat strikePosition_; 91 StkFloat baseFrequency_; 92 }; 93 94 } // namespace Nyq 95 96 #endif 97