1
/*******************************************/
3
ModalBar SubClass of Modal4 Instrument
4
by Perry R. Cook, 1999-2000
6
Controls: CONTROL1 = stickHardness
7
CONTROL2 = strikePosition
8
CONTROL3 = Mode Presets
10
/*******************************************/
13
#include "SKINI11.msg"
15
ModalBar :: ModalBar() : Modal4()
17
// Concatenate the STK RAWWAVE_PATH to the rawwave file
19
strcpy(file, RAWWAVE_PATH);
20
wave = new RawWvIn(strcat(file,"rawwaves/marmstk1.raw"),"oneshot");
21
wave->setRate((MY_FLOAT) 0.5); /* normal stick */
23
this->setRatioAndReson(0, (MY_FLOAT) 1.00,(MY_FLOAT) 0.9996); /* Set all 132.0 */
24
this->setRatioAndReson(1, (MY_FLOAT) 3.99,(MY_FLOAT) 0.9994); /* of our 523.0 */
25
this->setRatioAndReson(2,(MY_FLOAT) 10.65,(MY_FLOAT) 0.9994); /* default 1405.0 */
26
this->setRatioAndReson(3,-(MY_FLOAT) 2443.0,(MY_FLOAT) 0.999); /* resonances 2443.0 */
27
this->setFiltGain(0,(MY_FLOAT) 0.04); /* and */
28
this->setFiltGain(1,(MY_FLOAT) 0.01); /* gains */
29
this->setFiltGain(2,(MY_FLOAT) 0.01); /* for each */
30
this->setFiltGain(3,(MY_FLOAT) 0.008); /* resonance */
31
directGain = (MY_FLOAT) 0.1;
34
ModalBar :: ~ModalBar()
39
void ModalBar :: setStickHardness(MY_FLOAT hardness)
41
stickHardness = hardness;
42
wave->setRate((MY_FLOAT) (0.25 * (MY_FLOAT) pow(4.0,stickHardness)));
43
masterGain = (MY_FLOAT) 0.1 + ((MY_FLOAT) 1.8 * stickHardness);
46
void ModalBar :: setStrikePosition(MY_FLOAT position)
49
temp2 = position * PI;
50
strikePosition = position; /* Hack only first three modes */
51
temp = (MY_FLOAT) sin(temp2);
52
this->setFiltGain(0,(MY_FLOAT) 0.12 * temp); /* 1st mode function of pos. */
53
temp = (MY_FLOAT) sin(0.05 + (3.9 * temp2));
54
this->setFiltGain(1,(MY_FLOAT) -0.03 * temp); /* 2nd mode function of pos. */
55
temp = (MY_FLOAT) sin(-0.05 + (11 * temp2));
56
this->setFiltGain(2,(MY_FLOAT) 0.11 * temp); /* 3rd mode function of pos. */
59
void ModalBar :: setModalPreset(int which)
62
* first line: relative modal frequencies (negative number is
63
* a fixed mode that doesn't scale with frequency
64
* second line: resonances of the modes
65
* third line: mode volumes
66
* fourth line: stickHardness, strikePosition, and direct stick
67
* gain (mixed directly into the output
70
MY_FLOAT presets[9][4][4] = {
71
{{1.0, 3.99, 10.65, -2443}, // Marimba
72
{0.9996, 0.9994, 0.9994, 0.999},
73
{0.04, 0.01, 0.01, 0.008},
74
{0.429688, 0.445312, 0.093750}},
75
{{1.0, 2.01, 3.9, 14.37}, // Vibraphone
76
{0.99995, 0.99991, 0.99992, 0.9999},
77
{0.025, 0.015, 0.015, 0.015 },
78
{0.390625,0.570312,0.078125}},
79
{{1.0, 4.08, 6.669, -3725.0}, // Agogo
80
{0.999, 0.999, 0.999, 0.999},
81
{0.06, 0.05, 0.03, 0.02},
82
{0.609375,0.359375,0.140625}},
83
{{1.0, 2.777, 7.378, 15.377}, // Wood1
84
{0.996, 0.994, 0.994, 0.99},
85
{0.04, 0.01, 0.01, 0.008},
86
{0.460938,0.375000,0.046875}},
87
{{1.0, 2.777, 7.378, 15.377}, // Reso
88
{0.99996, 0.99994, 0.99994, 0.9999},
89
{0.02, 0.005, 0.005, 0.004},
90
{0.453125,0.250000,0.101562}},
91
{{1.0, 1.777, 2.378, 3.377}, // Wood2
92
{0.996, 0.994, 0.994, 0.99},
93
{0.04, 0.01, 0.01, 0.008},
94
{0.312500,0.445312,0.109375}},
95
{{1.0, 1.004, 1.013, 2.377}, // Beats
96
{0.9999, 0.9999, 0.9999, 0.999},
97
{0.02, 0.005, 0.005, 0.004},
98
{0.398438,0.296875,0.070312}},
99
{{1.0, 4.0, -1320.0, -3960.0}, // 2Fix
100
{0.9996, 0.999, 0.9994, 0.999},
101
{0.04, 0.01, 0.01, 0.008},
102
{0.453125,0.453125,0.070312}},
103
{{1.0, 1.217, 1.475, 1.729}, // Clump
104
{0.999, 0.999, 0.999, 0.999},
105
{0.03, 0.03, 0.03, 0.03 },
106
{0.390625,0.570312,0.078125}},
110
for (i=0; i<4; i++) {
111
this->setRatioAndReson(i, presets[temp][0][i], presets[temp][1][i]);
112
this->setFiltGain(i,presets[temp][2][i]);
114
this->setStickHardness(presets[temp][3][0]);
115
this->setStrikePosition(presets[temp][3][1]);
116
directGain = presets[temp][3][2];
118
if (temp == 1) // vibraphone
124
void ModalBar :: controlChange(int number, MY_FLOAT value)
127
printf("ModalBar : ControlChange: Number=%i Value=%f\n",number,value);
129
if (number == __SK_StickHardness_)
130
this->setStickHardness(value * NORM_7);
131
else if (number == __SK_StrikePosition_)
132
this->setStrikePosition(value * NORM_7);
133
else if (number == __SK_ProphesyRibbon_)
134
this->setModalPreset((int) value);
135
else if (number == __SK_ModWheel_)
136
directGain = value * NORM_7;
137
else if (number == __SK_AfterTouch_Cont_)
138
envelope->setTarget(value * NORM_7);
139
else if (number == __SK_ModFrequency_)
140
vibr->setFreq(value * NORM_7 * 12.0);
141
else if (number == 1024) { // HACKED Poop message
142
printf("StickHard=%f StrikePos=%f directGain=%f\n",
143
stickHardness, strikePosition, directGain);
146
printf("ModalBar : Undefined Control Number!!\n");