-
Notifications
You must be signed in to change notification settings - Fork 182
/
Sampler.cpp
53 lines (41 loc) · 1.07 KB
/
Sampler.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
50
51
52
53
/***************************************************/
/*! \class Sampler
\brief STK sampling synthesis abstract base class.
This instrument provides an ADSR envelope, a one-pole filter, and
structures for an arbitrary number of attack and looped files.
by Perry R. Cook and Gary P. Scavone, 1995--2023.
*/
/***************************************************/
#include "Sampler.h"
namespace stk {
Sampler :: Sampler( void )
{
// We don't make the waves here yet, because
// we don't know what they will be.
baseFrequency_ = 440.0;
attackGain_ = 0.25;
loopGain_ = 0.25;
}
Sampler :: ~Sampler( void )
{
unsigned int i;
for ( i=0; i<attacks_.size(); i++ ) delete attacks_[i];
for ( i=0; i<loops_.size(); i++ ) delete loops_[i];
}
void Sampler :: keyOn( void )
{
// Reset all attack waves.
for ( unsigned int i=0; i<attacks_.size(); i++ )
attacks_[i]->reset();
// Start the envelope.
adsr_.keyOn();
}
void Sampler :: keyOff( void )
{
adsr_.keyOff();
}
void Sampler :: noteOff( StkFloat amplitude )
{
this->keyOff();
}
} // stk namespace