Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK cubic non-linearity class. More...
#include <Cubic.h>
Public Member Functions | |
Cubic (void) | |
Default constructor. | |
void | setA1 (StkFloat a1) |
Set the a1 coefficient value. | |
void | setA2 (StkFloat a2) |
Set the a2 coefficient value. | |
void | setA3 (StkFloat a3) |
Set the a3 coefficient value. | |
void | setGain (StkFloat gain) |
Set the gain value. | |
void | setThreshold (StkFloat threshold) |
Set the threshold value. | |
StkFloat | tick (StkFloat input) |
Input one sample to the function and return one output. | |
StkFrames & | tick (StkFrames &frames, unsigned int channel=0) |
Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs. | |
StkFrames & | tick (StkFrames &iFrames, StkFrames &oFrames, unsigned int iChannel=0, unsigned int oChannel=0) |
Take a channel of the iFrames object as inputs to the function and write outputs to the oFrames object. |
STK cubic non-linearity class.
This class implements the cubic non-linearity that was used in SynthBuilder.
The formula implemented is:
output = gain * (a1 * input + a2 * input^2 + a3 * input^3)
followed by a limiter for values outside +-threshold.
Ported to STK by Nick Porcaro, 2007. Updated for inclusion in STK distribution by Gary Scavone, 2011.
Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
The StkFrames argument reference is returned. The channel
argument must be less than the number of channels in the StkFrames argument (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.
00100 { 00101 #if defined(_STK_DEBUG_) 00102 if ( channel >= frames.channels() ) { 00103 oStream_ << "Cubic::tick(): channel and StkFrames arguments are incompatible!"; 00104 handleError( StkError::FUNCTION_ARGUMENT ); 00105 } 00106 #endif 00107 00108 StkFloat *samples = &frames[channel]; 00109 unsigned int hop = frames.channels(); 00110 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) 00111 *samples = tick( *samples ); 00112 00113 lastFrame_[0] = *(samples-hop); 00114 return frames; 00115 }
StkFrames & stk::Cubic::tick | ( | StkFrames & | iFrames, | |
StkFrames & | oFrames, | |||
unsigned int | iChannel = 0 , |
|||
unsigned int | oChannel = 0 | |||
) | [inline] |
Take a channel of the iFrames
object as inputs to the function and write outputs to the oFrames
object.
The iFrames
object reference is returned. Each channel argument must be less than the number of channels in the corresponding StkFrames argument (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an StkError exception.
00118 { 00119 #if defined(_STK_DEBUG_) 00120 if ( iChannel >= iFrames.channels() || oChannel >= oFrames.channels() ) { 00121 oStream_ << "Cubic::tick(): channel and StkFrames arguments are incompatible!"; 00122 handleError( StkError::FUNCTION_ARGUMENT ); 00123 } 00124 #endif 00125 00126 StkFloat *iSamples = &iFrames[iChannel]; 00127 StkFloat *oSamples = &oFrames[oChannel]; 00128 unsigned int iHop = iFrames.channels(), oHop = oFrames.channels(); 00129 for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) 00130 *oSamples = tick( *iSamples ); 00131 00132 lastFrame_[0] = *(oSamples-oHop); 00133 return iFrames; 00134 }
The Synthesis ToolKit in C++ (STK) |
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |