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