-
Notifications
You must be signed in to change notification settings - Fork 185
/
Modulate.cpp
49 lines (37 loc) · 1.05 KB
/
Modulate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/***************************************************/
/*! \class Modulate
\brief STK periodic/random modulator.
This class combines random and periodic
modulations to give a nice, natural human
modulation function.
by Perry R. Cook and Gary P. Scavone, 1995--2023.
*/
/***************************************************/
#include "Modulate.h"
namespace stk {
Modulate :: Modulate( void )
{
vibrato_.setFrequency( 6.0 );
vibratoGain_ = 0.04;
noiseRate_ = (unsigned int) ( 330.0 * Stk::sampleRate() / 22050.0 );
noiseCounter_ = noiseRate_;
randomGain_ = 0.05;
filter_.setPole( 0.999 );
filter_.setGain( randomGain_ );
Stk::addSampleRateAlert( this );
}
Modulate :: ~Modulate( void )
{
Stk::removeSampleRateAlert( this );
}
void Modulate :: sampleRateChanged( StkFloat newRate, StkFloat oldRate )
{
if ( !ignoreSampleRateChange_ )
noiseRate_ = (unsigned int ) ( newRate * noiseRate_ / oldRate );
}
void Modulate :: setRandomGain( StkFloat gain )
{
randomGain_ = gain;
filter_.setGain( randomGain_ );
}
} // stk namespace