Version 4.2.0

This commit is contained in:
Gary Scavone
2009-03-24 23:02:14 -04:00
committed by Stephen Sinclair
parent cf06b7598b
commit a6381b9d38
281 changed files with 17152 additions and 12000 deletions

View File

@@ -9,9 +9,9 @@
Control Change Numbers:
- Stick Hardness = 2
- Stick Position = 4
- Vibrato Gain = 11
- Vibrato Frequency = 7
- Direct Stick Mix = 1
- Vibrato Gain = 1
- Vibrato Frequency = 11
- Direct Stick Mix = 8
- Volume = 128
- Modal Presets = 16
- Marimba = 0
@@ -24,7 +24,7 @@
- Two Fixed = 7
- Clump = 8
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
@@ -36,56 +36,60 @@ ModalBar :: ModalBar()
: Modal()
{
// Concatenate the STK rawwave path to the rawwave file
wave = new WvIn( (Stk::rawwavePath() + "marmstk1.raw").c_str(), TRUE );
wave->setRate((MY_FLOAT) 0.5 * 22050.0 / Stk::sampleRate() );
wave_ = new WvIn( (Stk::rawwavePath() + "marmstk1.raw").c_str(), true );
wave_->setRate( 0.5 * 22050.0 / Stk::sampleRate() );
// Set the resonances for preset 0 (marimba).
setPreset( 0 );
this->setPreset( 0 );
}
ModalBar :: ~ModalBar()
{
delete wave;
delete wave_;
}
void ModalBar :: setStickHardness(MY_FLOAT hardness)
void ModalBar :: setStickHardness(StkFloat hardness)
{
stickHardness = hardness;
stickHardness_ = hardness;
if ( hardness < 0.0 ) {
std::cerr << "ModalBar: setStickHardness parameter is less than zero!" << std::endl;
stickHardness = 0.0;
errorString_ << "ModalBar::setStickHardness: parameter is less than zero ... setting to 0.0!";
handleError( StkError::WARNING );
stickHardness_ = 0.0;
}
else if ( hardness > 1.0 ) {
std::cerr << "ModalBar: setStickHarness parameter is greater than 1.0!" << std::endl;
stickHardness = 1.0;
errorString_ << "ModalBar::setStickHarness: parameter is greater than one ... setting to 1.0!";
handleError( StkError::WARNING );
stickHardness_ = 1.0;
}
wave->setRate( (0.25 * (MY_FLOAT) pow(4.0, stickHardness)) );
masterGain = 0.1 + (1.8 * stickHardness);
wave_->setRate( (0.25 * pow(4.0, stickHardness_) ) );
masterGain_ = 0.1 + (1.8 * stickHardness_);
}
void ModalBar :: setStrikePosition(MY_FLOAT position)
void ModalBar :: setStrikePosition(StkFloat position)
{
strikePosition = position;
strikePosition_ = position;
if ( position < 0.0 ) {
std::cerr << "ModalBar: setStrikePositions parameter is less than zero!" << std::endl;
strikePosition = 0.0;
errorString_ << "ModalBar::setStrikePosition: parameter is less than zero ... setting to 0.0!";
handleError( StkError::WARNING );
strikePosition_ = 0.0;
}
else if ( position > 1.0 ) {
std::cerr << "ModalBar: setStrikePosition parameter is greater than 1.0!" << std::endl;
strikePosition = 1.0;
errorString_ << "ModalBar::setStrikePosition: parameter is greater than one ... setting to 1.0!";
handleError( StkError::WARNING );
strikePosition_ = 1.0;
}
// Hack only first three modes.
MY_FLOAT temp2 = position * PI;
MY_FLOAT temp = sin(temp2);
StkFloat temp2 = position * PI;
StkFloat temp = sin(temp2);
this->setModeGain(0, 0.12 * temp);
temp = sin(0.05 + (3.9 * temp2));
this->setModeGain(1,(MY_FLOAT) -0.03 * temp);
this->setModeGain(1, -0.03 * temp);
temp = (MY_FLOAT) sin(-0.05 + (11 * temp2));
this->setModeGain(2,(MY_FLOAT) 0.11 * temp);
temp = sin(-0.05 + (11 * temp2));
this->setModeGain(2, 0.11 * temp);
}
void ModalBar :: setPreset(int preset)
@@ -97,7 +101,7 @@ void ModalBar :: setPreset(int preset)
// Third line: mode volumes
// Fourth line: stickHardness, strikePosition, and direct stick
// gain (mixed directly into the output
static MY_FLOAT presets[9][4][4] = {
static StkFloat presets[9][4][4] = {
{{1.0, 3.99, 10.65, -2443}, // Marimba
{0.9996, 0.9994, 0.9994, 0.999},
{0.04, 0.01, 0.01, 0.008},
@@ -137,31 +141,33 @@ void ModalBar :: setPreset(int preset)
};
int temp = (preset % 9);
for (int i=0; i<nModes; i++) {
for (unsigned int i=0; i<nModes_; i++) {
this->setRatioAndRadius(i, presets[temp][0][i], presets[temp][1][i]);
this->setModeGain(i, presets[temp][2][i]);
}
this->setStickHardness(presets[temp][3][0]);
this->setStrikePosition(presets[temp][3][1]);
directGain = presets[temp][3][2];
directGain_ = presets[temp][3][2];
if (temp == 1) // vibraphone
vibratoGain = 0.2;
vibratoGain_ = 0.2;
else
vibratoGain = 0.0;
vibratoGain_ = 0.0;
}
void ModalBar :: controlChange(int number, MY_FLOAT value)
void ModalBar :: controlChange(int number, StkFloat value)
{
MY_FLOAT norm = value * ONE_OVER_128;
StkFloat norm = value * ONE_OVER_128;
if ( norm < 0 ) {
norm = 0.0;
std::cerr << "ModalBar: Control value less than zero!" << std::endl;
errorString_ << "ModalBar::controlChange: control value less than zero ... setting to zero!";
handleError( StkError::WARNING );
}
else if ( norm > 1.0 ) {
norm = 1.0;
std::cerr << "ModalBar: Control value greater than 128.0!" << std::endl;
errorString_ << "ModalBar::controlChange: control value greater than 128.0 ... setting to 128.0!";
handleError( StkError::WARNING );
}
if (number == __SK_StickHardness_) // 2
@@ -170,18 +176,21 @@ void ModalBar :: controlChange(int number, MY_FLOAT value)
this->setStrikePosition( norm );
else if (number == __SK_ProphesyRibbon_) // 16
this->setPreset((int) value);
else if (number == __SK_Balance_) // 8
directGain_ = norm;
else if (number == __SK_ModWheel_) // 1
directGain = norm;
else if (number == 11) // 11
vibratoGain = norm * 0.3;
else if (number == __SK_ModFrequency_) // 7
vibrato->setFrequency( norm * 12.0 );
vibratoGain_ = norm * 0.3;
else if (number == __SK_ModFrequency_) // 11
vibrato_->setFrequency( norm * 12.0 );
else if (number == __SK_AfterTouch_Cont_) // 128
envelope->setTarget( norm );
else
std::cerr << "ModalBar: Undefined Control Number (" << number << ")!!" << std::endl;
envelope_.setTarget( norm );
else {
errorString_ << "ModalBar::controlChange: undefined control number (" << number << ")!";
handleError( StkError::WARNING );
}
#if defined(_STK_DEBUG_)
std::cerr << "ModalBar: controlChange number = " << number << ", value = " << value << std::endl;
errorString_ << "ModalBar::controlChange: number = " << number << ", value = " << value << '.';
handleError( StkError::DEBUG_WARNING );
#endif
}