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.

54 lines
1.1KB

  1. /***************************************************/
  2. /*! \class Sampler
  3. \brief STK sampling synthesis abstract base class.
  4. This instrument provides an ADSR envelope, a one-pole filter, and
  5. structures for an arbitrary number of attack and looped files.
  6. by Perry R. Cook and Gary P. Scavone, 1995--2017.
  7. */
  8. /***************************************************/
  9. #include "Sampler.h"
  10. namespace stk {
  11. Sampler :: Sampler( void )
  12. {
  13. // We don't make the waves here yet, because
  14. // we don't know what they will be.
  15. baseFrequency_ = 440.0;
  16. attackGain_ = 0.25;
  17. loopGain_ = 0.25;
  18. }
  19. Sampler :: ~Sampler( void )
  20. {
  21. unsigned int i;
  22. for ( i=0; i<attacks_.size(); i++ ) delete attacks_[i];
  23. for ( i=0; i<loops_.size(); i++ ) delete loops_[i];
  24. }
  25. void Sampler :: keyOn( void )
  26. {
  27. // Reset all attack waves.
  28. for ( unsigned int i=0; i<attacks_.size(); i++ )
  29. attacks_[i]->reset();
  30. // Start the envelope.
  31. adsr_.keyOn();
  32. }
  33. void Sampler :: keyOff( void )
  34. {
  35. adsr_.keyOff();
  36. }
  37. void Sampler :: noteOff( StkFloat amplitude )
  38. {
  39. this->keyOff();
  40. }
  41. } // stk namespace