You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0KB

  1. #ifndef STK_SAMPLER_H
  2. #define STK_SAMPLER_H
  3. #include "Instrmnt.h"
  4. #include "ADSR.h"
  5. #include "FileLoop.h"
  6. #include "OnePole.h"
  7. namespace stk {
  8. /***************************************************/
  9. /*! \class Sampler
  10. \brief STK sampling synthesis abstract base class.
  11. This instrument provides an ADSR envelope, a one-pole filter, and
  12. structures for an arbitrary number of attack and looped files.
  13. by Perry R. Cook and Gary P. Scavone, 1995--2017.
  14. */
  15. /***************************************************/
  16. class Sampler : public Instrmnt
  17. {
  18. public:
  19. //! Default constructor.
  20. Sampler( void );
  21. //! Class destructor.
  22. virtual ~Sampler( void );
  23. //! Set instrument parameters for a particular frequency.
  24. virtual void setFrequency( StkFloat frequency ) = 0;
  25. //! Initiate the envelopes with a key-on event and reset the attack waves.
  26. void keyOn( void );
  27. //! Signal a key-off event to the envelopes.
  28. void keyOff( void );
  29. //! Stop a note with the given amplitude (speed of decay).
  30. virtual void noteOff( StkFloat amplitude );
  31. //! Perform the control change specified by \e number and \e value (0.0 - 128.0).
  32. virtual void controlChange( int number, StkFloat value ) = 0;
  33. //! Compute and return one output sample.
  34. virtual StkFloat tick( unsigned int channel = 0 ) = 0;
  35. //! Fill a channel of the StkFrames object with computed outputs.
  36. /*!
  37. The \c channel argument must be less than the number of
  38. channels in the StkFrames argument (the first channel is specified
  39. by 0). However, range checking is only performed if _STK_DEBUG_
  40. is defined during compilation, in which case an out-of-range value
  41. will trigger an StkError exception.
  42. */
  43. virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) = 0;
  44. protected:
  45. ADSR adsr_;
  46. std::vector<FileWvIn *> attacks_;
  47. std::vector<FileLoop *> loops_;
  48. OnePole filter_;
  49. StkFloat baseFrequency_;
  50. std::vector<StkFloat> attackRatios_;
  51. std::vector<StkFloat> loopRatios_;
  52. StkFloat attackGain_;
  53. StkFloat loopGain_;
  54. };
  55. } // stk namespace
  56. #endif