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.

57 lines
1.4KB

  1. /***************************************************/
  2. /*! \class Chorus
  3. \brief STK chorus effect class.
  4. This class implements a chorus effect. It takes a monophonic
  5. input signal and produces a stereo output signal.
  6. by Perry R. Cook and Gary P. Scavone, 1995--2017.
  7. */
  8. /***************************************************/
  9. #include "Chorus.h"
  10. namespace stk {
  11. Chorus :: Chorus( StkFloat baseDelay )
  12. {
  13. lastFrame_.resize( 1, 2, 0.0 ); // resize lastFrame_ for stereo output
  14. delayLine_[0].setMaximumDelay( (unsigned long) (baseDelay * 1.414) + 2);
  15. delayLine_[0].setDelay( baseDelay );
  16. delayLine_[1].setMaximumDelay( (unsigned long) (baseDelay * 1.414) + 2);
  17. delayLine_[1].setDelay( baseDelay );
  18. baseLength_ = baseDelay;
  19. mods_[0].setFrequency( 0.2 );
  20. mods_[1].setFrequency( 0.222222 );
  21. modDepth_ = 0.05;
  22. effectMix_ = 0.5;
  23. this->clear();
  24. }
  25. void Chorus :: clear( void )
  26. {
  27. delayLine_[0].clear();
  28. delayLine_[1].clear();
  29. lastFrame_[0] = 0.0;
  30. lastFrame_[1] = 0.0;
  31. }
  32. void Chorus :: setModDepth( StkFloat depth )
  33. {
  34. if ( depth < 0.0 || depth > 1.0 ) {
  35. oStream_ << "Chorus::setModDepth(): depth argument must be between 0.0 - 1.0!";
  36. handleError( StkError::WARNING ); return;
  37. }
  38. modDepth_ = depth;
  39. };
  40. void Chorus :: setModFrequency( StkFloat frequency )
  41. {
  42. mods_[0].setFrequency( frequency );
  43. mods_[1].setFrequency( frequency * 1.1111 );
  44. }
  45. } // stk namespace