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