1 /***************************************************/
2 /*! \class HevyMetl
3     \brief STK heavy metal FM synthesis instrument.
4 
5     This class implements 3 cascade operators with
6     feedback modulation, also referred to as
7     algorithm 3 of the TX81Z.
8 
9     Algorithm 3 is :     4--\
10                     3-->2-- + -->1-->Out
11 
12     Control Change Numbers:
13        - Total Modulator Index = 2
14        - Modulator Crossfade = 4
15        - LFO Speed = 11
16        - LFO Depth = 1
17        - ADSR 2 & 4 Target = 128
18 
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 
25     by Perry R. Cook and Gary P. Scavone, 1995--2021.
26 */
27 /***************************************************/
28 
29 #include "HevyMetl.h"
30 
31 namespace stk {
32 
HevyMetl(void)33 HevyMetl :: HevyMetl( void )
34   : FM()
35 {
36   // Concatenate the STK rawwave path to the rawwave files
37   for ( unsigned int i=0; i<3; i++ )
38     waves_[i] = new FileLoop( (Stk::rawwavePath() + "sinewave.raw").c_str(), true );
39   waves_[3] = new FileLoop( (Stk::rawwavePath() + "fwavblnk.raw").c_str(), true );
40 
41   this->setRatio(0, 1.0 * 1.000);
42   this->setRatio(1, 4.0 * 0.999);
43   this->setRatio(2, 3.0 * 1.001);
44   this->setRatio(3, 0.5 * 1.002);
45 
46   gains_[0] = fmGains_[92];
47   gains_[1] = fmGains_[76];
48   gains_[2] = fmGains_[91];
49   gains_[3] = fmGains_[68];
50 
51   adsr_[0]->setAllTimes( 0.001, 0.001, 1.0, 0.01);
52   adsr_[1]->setAllTimes( 0.001, 0.010, 1.0, 0.50);
53   adsr_[2]->setAllTimes( 0.010, 0.005, 1.0, 0.20);
54   adsr_[3]->setAllTimes( 0.030, 0.010, 0.2, 0.20);
55 
56   twozero_.setGain( 2.0 );
57   vibrato_.setFrequency( 5.5 );
58   modDepth_ = 0.0;
59 }
60 
~HevyMetl(void)61 HevyMetl :: ~HevyMetl( void )
62 {
63 }
64 
noteOn(StkFloat frequency,StkFloat amplitude)65 void HevyMetl :: noteOn( StkFloat frequency, StkFloat amplitude )
66 {
67   gains_[0] = amplitude * fmGains_[92];
68   gains_[1] = amplitude * fmGains_[76];
69   gains_[2] = amplitude * fmGains_[91];
70   gains_[3] = amplitude * fmGains_[68];
71   this->setFrequency( frequency );
72   this->keyOn();
73 }
74 
75 } // stk namespace
76