-
Notifications
You must be signed in to change notification settings - Fork 3
/
Generator.cpp
54 lines (45 loc) · 1.3 KB
/
Generator.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
54
/***************************************************/
/*! \class Generator
\brief STK abstract unit generator parent class.
This class provides common functionality for
STK unit generator sample-source subclasses.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
#include "Generator.h"
Generator :: Generator() : Stk()
{
lastOutput_ = 0.0;
}
Generator :: ~Generator()
{
}
StkFloat Generator :: tick( void )
{
return computeSample();
}
StkFrames& Generator :: tick( StkFrames& frames, unsigned int channel )
{
if ( channel >= frames.channels() ) {
errorString_ << "Generator::tick(): channel and StkFrames arguments are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
if ( frames.channels() == 1 ) {
for ( unsigned int i=0; i<frames.frames(); i++ )
frames[i] = computeSample();
}
else if ( frames.interleaved() ) {
unsigned int hop = frames.channels();
unsigned int index = channel;
for ( unsigned int i=0; i<frames.frames(); i++ ) {
frames[index] = computeSample();
index += hop;
}
}
else {
unsigned int iStart = channel * frames.frames();
for ( unsigned int i=0; i<frames.frames(); i++, iStart++ )
frames[iStart] = computeSample();
}
return frames;
}