33 Cubic(
void ) : a1_(0.5), a2_(0.5), a3_(0.5), gain_(1.0), threshold_(1.0) {};
36 void setA1( StkFloat a1 ) { a1_ = a1; };
39 void setA2( StkFloat a2 ) { a2_ = a2; };
42 void setA3( StkFloat a3 ) { a3_ = a3; };
45 void setGain( StkFloat gain ) { gain_ = gain; };
48 void setThreshold( StkFloat threshold ) { threshold_ = threshold; };
51 StkFloat
tick( StkFloat input );
86 StkFloat inSquared = input * input;
87 StkFloat inCubed = inSquared * input;
89 lastFrame_[0] = gain_ * (a1_ * input + a2_ * inSquared + a3_ * inCubed);
92 if ( fabs( lastFrame_[0] ) > threshold_ ) {
93 lastFrame_[0] = ( lastFrame_[0] < 0 ? -threshold_ : threshold_ );
101 #if defined(_STK_DEBUG_)
102 if ( channel >= frames.
channels() ) {
103 oStream_ <<
"Cubic::tick(): channel and StkFrames arguments are incompatible!";
108 StkFloat *samples = &frames[channel];
109 unsigned int hop = frames.
channels();
110 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop )
111 *samples =
tick( *samples );
113 lastFrame_[0] = *(samples-hop);
119 #if defined(_STK_DEBUG_)
121 oStream_ <<
"Cubic::tick(): channel and StkFrames arguments are incompatible!";
126 StkFloat *iSamples = &iFrames[iChannel];
127 StkFloat *oSamples = &oFrames[oChannel];
129 for (
unsigned int i=0; i<iFrames.
frames(); i++, iSamples += iHop, oSamples += oHop )
130 *oSamples =
tick( *iSamples );
132 lastFrame_[0] = *(oSamples-oHop);