Audio plugin host https://kx.studio/carla
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.

79 lines
2.1KB

  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-2011.
  14. */
  15. /***************************************************/
  16. class Sampler : public Instrmnt
  17. {
  18. public:
  19. //! Default constructor.
  20. Sampler( void );
  21. //! Class destructor.
  22. virtual ~Sampler( void );
  23. //! Reset and clear all internal state.
  24. void clear( void );
  25. //! Set instrument parameters for a particular frequency.
  26. virtual void setFrequency( StkFloat frequency ) = 0;
  27. //! Initiate the envelopes with a key-on event and reset the attack waves.
  28. void keyOn( void );
  29. //! Signal a key-off event to the envelopes.
  30. void keyOff( void );
  31. //! Stop a note with the given amplitude (speed of decay).
  32. virtual void noteOff( StkFloat amplitude );
  33. //! Perform the control change specified by \e number and \e value (0.0 - 128.0).
  34. virtual void controlChange( int number, StkFloat value ) = 0;
  35. //! Compute and return one output sample.
  36. virtual StkFloat tick( unsigned int channel = 0 ) = 0;
  37. //! Fill a channel of the StkFrames object with computed outputs.
  38. /*!
  39. The \c channel argument must be less than the number of
  40. channels in the StkFrames argument (the first channel is specified
  41. by 0). However, range checking is only performed if _STK_DEBUG_
  42. is defined during compilation, in which case an out-of-range value
  43. will trigger an StkError exception.
  44. */
  45. virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) = 0;
  46. protected:
  47. ADSR adsr_;
  48. std::vector<FileWvIn *> attacks_;
  49. std::vector<FileLoop *> loops_;
  50. OnePole filter_;
  51. StkFloat baseFrequency_;
  52. std::vector<StkFloat> attackRatios_;
  53. std::vector<StkFloat> loopRatios_;
  54. StkFloat attackGain_;
  55. StkFloat loopGain_;
  56. };
  57. } // stk namespace
  58. #endif