4 const unsigned long TABLE_SIZE = 2048;
41 void setRate( StkFloat rate ) { rate_ = rate; };
71 StkFloat
lastOut(
void )
const {
return lastFrame_[0]; };
74 StkFloat
tick(
void );
88 void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
93 StkFloat phaseOffset_;
103 while ( time_ < 0.0 )
105 while ( time_ >= TABLE_SIZE )
108 iIndex_ = (
unsigned int) time_;
109 alpha_ = time_ - iIndex_;
110 StkFloat tmp = table_[ iIndex_ ];
111 tmp += ( alpha_ * ( table_[ iIndex_ + 1 ] - tmp ) );
117 return lastFrame_[0];
122 #if defined(_STK_DEBUG_)
123 if ( channel >= frames.
channels() ) {
124 oStream_ <<
"SineWave::tick(): channel and StkFrames arguments are incompatible!";
129 StkFloat *samples = &frames[channel];
132 unsigned int hop = frames.
channels();
133 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
137 while ( time_ < 0.0 )
139 while ( time_ >= TABLE_SIZE )
142 iIndex_ = (
unsigned int) time_;
143 alpha_ = time_ - iIndex_;
144 tmp = table_[ iIndex_ ];
145 tmp += ( alpha_ * ( table_[ iIndex_ + 1 ] - tmp ) );
STK abstract unit generator parent class.
Definition: Generator.h:21
STK sinusoid oscillator class.
Definition: SineWave.h:26
void setFrequency(StkFloat frequency)
Set the data interpolation rate based on a looping frequency.
StkFloat tick(void)
Compute and return one output sample.
Definition: SineWave.h:99
StkFloat lastOut(void) const
Return the last computed output value.
Definition: SineWave.h:71
void addPhase(StkFloat phase)
Increment the read pointer by a normalized phase value.
void reset(void)
Clear output and reset time pointer to zero.
void addPhaseOffset(StkFloat phaseOffset)
Add a normalized phase offset to the read pointer.
SineWave(void)
Default constructor.
void addTime(StkFloat time)
Increment the read pointer by time in samples, modulo the table size.
~SineWave(void)
Class destructor.
void setRate(StkFloat rate)
Set the data read rate in samples. The rate can be negative.
Definition: SineWave.h:41
An STK class to handle vectorized audio data.
Definition: Stk.h:287
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:415
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:418
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
The STK namespace.
Definition: ADSR.h:8