forked from thestk/stk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingWave.cpp
More file actions
53 lines (42 loc) · 1.32 KB
/
SingWave.cpp
File metadata and controls
53 lines (42 loc) · 1.32 KB
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
50
51
52
53
/***************************************************/
/*! \class SingWave
\brief STK "singing" looped soundfile class.
This class loops a specified soundfile and modulates it both
periodically and randomly to produce a pitched musical sound, like
a simple voice or violin. In general, it is not be used alone
because of "munchkinification" effects from pitch shifting.
Within STK, it is used as an excitation source for other
instruments.
by Perry R. Cook and Gary P. Scavone, 1995--2021.
*/
/***************************************************/
#include "SingWave.h"
namespace stk {
SingWave :: SingWave( std::string fileName, bool raw )
{
// An exception could be thrown here.
wave_.openFile( fileName, raw );
rate_ = 1.0;
sweepRate_ = 0.001;
modulator_.setVibratoRate( 6.0 );
modulator_.setVibratoGain( 0.04 );
modulator_.setRandomGain( 0.005 );
this->setFrequency( 75.0 );
pitchEnvelope_.setRate( 1.0 );
this->tick();
this->tick();
pitchEnvelope_.setRate( sweepRate_ * rate_ );
}
SingWave :: ~SingWave()
{
}
void SingWave :: setFrequency( StkFloat frequency )
{
StkFloat temp = rate_;
rate_ = wave_.getSize() * frequency / Stk::sampleRate();
temp -= rate_;
if ( temp < 0) temp = -temp;
pitchEnvelope_.setTarget( rate_ );
pitchEnvelope_.setRate( sweepRate_ * temp );
}
} // stk namespace