mirror of
https://github.com/thestk/stk
synced 2026-01-13 13:01:52 +00:00
Version 2.01
This commit is contained in:
committed by
Stephen Sinclair
parent
6485746ee9
commit
ea749b71d2
54
Marimba.cpp
54
Marimba.cpp
@@ -9,33 +9,35 @@
|
||||
/*******************************************/
|
||||
|
||||
#include "Marimba.h"
|
||||
#include "SKINI11.msg"
|
||||
|
||||
Marimba :: Marimba() : Modal4()
|
||||
{
|
||||
wave = new RawWave("rawwaves/marmstk1.raw");
|
||||
wave->normalize();
|
||||
wave->setRate(0.5); /* normal stick */
|
||||
this->setRatioAndReson(0, 1.00,0.9996); /* Set all 132.0 */
|
||||
this->setRatioAndReson(1, 3.99,0.9994); /* of our 523.0 */
|
||||
this->setRatioAndReson(2,10.65,0.9994); /* default 1405.0 */
|
||||
this->setRatioAndReson(3,-18.50,0.999); /* resonances 2443.0 */
|
||||
this->setFiltGain(0,0.08); /* and */
|
||||
this->setFiltGain(1,0.02); /* gains */
|
||||
this->setFiltGain(2,0.02); /* for each */
|
||||
this->setFiltGain(3,0.015); /* resonance */
|
||||
directGain = 0.1;
|
||||
wave->setRate((MY_FLOAT) 0.5); /* normal stick */
|
||||
this->setRatioAndReson(0, (MY_FLOAT) 1.00,(MY_FLOAT) 0.9996); /* Set all 132.0 */
|
||||
this->setRatioAndReson(1, (MY_FLOAT) 3.99,(MY_FLOAT) 0.9994); /* of our 523.0 */
|
||||
this->setRatioAndReson(2,(MY_FLOAT) 10.65,(MY_FLOAT) 0.9994); /* default 1405.0 */
|
||||
this->setRatioAndReson(3,-(MY_FLOAT) 2443.0,(MY_FLOAT) 0.999); /* resonances 2443.0 */
|
||||
this->setFiltGain(0,(MY_FLOAT) 0.04); /* and */
|
||||
this->setFiltGain(1,(MY_FLOAT) 0.01); /* gains */
|
||||
this->setFiltGain(2,(MY_FLOAT) 0.01); /* for each */
|
||||
this->setFiltGain(3,(MY_FLOAT) 0.008); /* resonance */
|
||||
directGain = (MY_FLOAT) 0.1;
|
||||
multiStrike = 0;
|
||||
}
|
||||
|
||||
Marimba :: ~Marimba()
|
||||
{
|
||||
delete wave;
|
||||
}
|
||||
|
||||
void Marimba :: setStickHardness(MY_FLOAT hardness)
|
||||
{
|
||||
stickHardness = hardness;
|
||||
wave->setRate(0.25 * pow(4.0,stickHardness));
|
||||
masterGain = 0.1 + (1.8 * stickHardness);
|
||||
wave->setRate((MY_FLOAT) (0.25 * (MY_FLOAT) pow(4.0,stickHardness)));
|
||||
masterGain = (MY_FLOAT) 0.1 + ((MY_FLOAT) 1.8 * stickHardness);
|
||||
}
|
||||
|
||||
void Marimba :: setStrikePosition(MY_FLOAT position)
|
||||
@@ -43,12 +45,12 @@ void Marimba :: setStrikePosition(MY_FLOAT position)
|
||||
MY_FLOAT temp,temp2;
|
||||
temp2 = position * PI;
|
||||
strikePosition = position; /* Hack only first three modes */
|
||||
temp = sin(temp2);
|
||||
this->setFiltGain(0,0.12 * temp); /* 1st mode function of pos. */
|
||||
temp = sin(0.05 + (3.9 * temp2));
|
||||
this->setFiltGain(1,-0.03 * temp); /* 2nd mode function of pos. */
|
||||
temp = sin(-0.05 + (11 * temp2));
|
||||
this->setFiltGain(2,0.11 * temp); /* 3rd mode function of pos. */
|
||||
temp = (MY_FLOAT) sin(temp2);
|
||||
this->setFiltGain(0,(MY_FLOAT) 0.12 * temp); /* 1st mode function of pos. */
|
||||
temp = (MY_FLOAT) sin(0.05 + (3.9 * temp2));
|
||||
this->setFiltGain(1,(MY_FLOAT) -0.03 * temp); /* 2nd mode function of pos. */
|
||||
temp = (MY_FLOAT) sin(-0.05 + (11 * temp2));
|
||||
this->setFiltGain(2,(MY_FLOAT) 0.11 * temp); /* 3rd mode function of pos. */
|
||||
}
|
||||
|
||||
void Marimba :: setModulationSpeed(MY_FLOAT mSpeed)
|
||||
@@ -63,7 +65,7 @@ void Marimba :: setModulationDepth(MY_FLOAT mDepth)
|
||||
void Marimba :: strike(MY_FLOAT amplitude)
|
||||
{
|
||||
int temp;
|
||||
temp = random() >> 26;
|
||||
temp = rand() >> 10;
|
||||
if (temp < 2) {
|
||||
multiStrike = 1;
|
||||
#if defined(_debug_)
|
||||
@@ -85,15 +87,15 @@ void Marimba :: controlChange(int number, MY_FLOAT value)
|
||||
#if defined(_debug_)
|
||||
printf("Marimba : ControlChange: Number=%i Value=%f\n",number,value);
|
||||
#endif
|
||||
if (number == MIDI_control1)
|
||||
if (number == __SK_StickHardness_)
|
||||
this->setStickHardness(value * NORM_7);
|
||||
else if (number == MIDI_control2)
|
||||
else if (number == __SK_StrikePosition_)
|
||||
this->setStrikePosition(value * NORM_7);
|
||||
else if (number == MIDI_control3)
|
||||
vibr->setFreq((value * NORM_7 * 12.0));
|
||||
else if (number == MIDI_mod_wheel)
|
||||
vibrGain = (value * NORM_7);
|
||||
else if (number == MIDI_after_touch)
|
||||
else if (number == __SK_ModFrequency_)
|
||||
vibr->setFreq((value * NORM_7 * (MY_FLOAT) 12.0));
|
||||
else if (number == __SK_ModWheel_)
|
||||
vibrGain = (value * NORM_7);
|
||||
else if (number == __SK_AfterTouch_Cont_)
|
||||
this->strike(value * NORM_7);
|
||||
else {
|
||||
printf("Marimba : Undefined Control Number!!\n");
|
||||
|
||||
Reference in New Issue
Block a user