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. /***************************************************/
  2. /*! \class TubeBell
  3. \brief STK tubular bell (orchestral chime) FM
  4. synthesis instrument.
  5. This class implements two simple FM Pairs
  6. summed together, also referred to as algorithm
  7. 5 of the TX81Z.
  8. \code
  9. Algorithm 5 is : 4->3--\
  10. + --> Out
  11. 2->1--/
  12. \endcode
  13. Control Change Numbers:
  14. - Modulator Index One = 2
  15. - Crossfade of Outputs = 4
  16. - LFO Speed = 11
  17. - LFO Depth = 1
  18. - ADSR 2 & 4 Target = 128
  19. The basic Chowning/Stanford FM patent expired
  20. in 1995, but there exist follow-on patents,
  21. mostly assigned to Yamaha. If you are of the
  22. type who should worry about this (making
  23. money) worry away.
  24. by Perry R. Cook and Gary P. Scavone, 1995--2017.
  25. */
  26. /***************************************************/
  27. #include "TubeBell.h"
  28. namespace stk {
  29. TubeBell :: TubeBell( void )
  30. : FM()
  31. {
  32. // Concatenate the STK rawwave path to the rawwave files
  33. for ( unsigned int i=0; i<3; i++ )
  34. waves_[i] = new FileLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), true );
  35. waves_[3] = new FileLoop( (Stk::rawwavePath() + "fwavblnk.raw").c_str(), true );
  36. this->setRatio(0, 1.0 * 0.995);
  37. this->setRatio(1, 1.414 * 0.995);
  38. this->setRatio(2, 1.0 * 1.005);
  39. this->setRatio(3, 1.414 * 1.000);
  40. gains_[0] = fmGains_[94];
  41. gains_[1] = fmGains_[76];
  42. gains_[2] = fmGains_[99];
  43. gains_[3] = fmGains_[71];
  44. adsr_[0]->setAllTimes( 0.005, 4.0, 0.0, 0.04);
  45. adsr_[1]->setAllTimes( 0.005, 4.0, 0.0, 0.04);
  46. adsr_[2]->setAllTimes( 0.001, 2.0, 0.0, 0.04);
  47. adsr_[3]->setAllTimes( 0.004, 4.0, 0.0, 0.04);
  48. twozero_.setGain( 0.5 );
  49. vibrato_.setFrequency( 2.0 );
  50. }
  51. TubeBell :: ~TubeBell( void )
  52. {
  53. }
  54. void TubeBell :: noteOn( StkFloat frequency, StkFloat amplitude )
  55. {
  56. gains_[0] = amplitude * fmGains_[94];
  57. gains_[1] = amplitude * fmGains_[76];
  58. gains_[2] = amplitude * fmGains_[99];
  59. gains_[3] = amplitude * fmGains_[71];
  60. this->setFrequency( frequency );
  61. this->keyOn();
  62. }
  63. } // stk namespace