1 /***************************************************/
2 /*! \class Sampler
3     \brief STK sampling synthesis abstract base class.
4 
5     This instrument provides an ADSR envelope, a one-pole filter, and
6     structures for an arbitrary number of attack and looped files.
7 
8     by Perry R. Cook and Gary P. Scavone, 1995--2021.
9 */
10 /***************************************************/
11 
12 #include "Sampler.h"
13 
14 namespace stk {
15 
16 Sampler :: Sampler( void )
17 {
18   // We don't make the waves here yet, because
19   // we don't know what they will be.
20   baseFrequency_ = 440.0;
21   attackGain_ = 0.25;
22   loopGain_ = 0.25;
23 }
24 
25 Sampler :: ~Sampler( void )
26 {
27   unsigned int i;
28   for ( i=0; i<attacks_.size(); i++ ) delete attacks_[i];
29   for ( i=0; i<loops_.size(); i++ ) delete loops_[i];
30 }
31 
32 void Sampler :: keyOn( void )
33 {
34   // Reset all attack waves.
35   for ( unsigned int i=0; i<attacks_.size(); i++ )
36     attacks_[i]->reset();
37 
38   // Start the envelope.
39   adsr_.keyOn();
40 
41 }
42 
43 void Sampler :: keyOff( void )
44 {
45   adsr_.keyOff();
46 }
47 
48 void Sampler :: noteOff( StkFloat amplitude )
49 {
50   this->keyOff();
51 }
52 
53 } // stk namespace
54