Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK chorus effect class. More...
#include <Chorus.h>
Public Member Functions | |
Chorus (StkFloat baseDelay=6000) | |
Class constructor, taking the median desired delay length. | |
void | clear (void) |
Reset and clear all internal state. | |
void | setModDepth (StkFloat depth) |
Set modulation depth in range 0.0 - 1.0. | |
void | setModFrequency (StkFloat frequency) |
Set modulation frequency. | |
StkFloat | lastOut (unsigned int channel=0) |
Return the specified channel value of the last computed stereo frame. | |
StkFloat | tick (StkFloat input, unsigned int channel=0) |
Input one sample to the effect and return the specified channel value of the computed stereo frame. | |
StkFrames & | tick (StkFrames &frames, unsigned int channel=0) |
Take a channel of the StkFrames object as inputs to the effect and replace with stereo 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 effect and write stereo outputs to the oFrames object. |
STK chorus effect class.
This class implements a chorus effect. It takes a monophonic input signal and produces a stereo output signal.
by Perry R. Cook and Gary P. Scavone, 1995-2012.
stk::Chorus::Chorus | ( | StkFloat | baseDelay = 6000 |
) |
Class constructor, taking the median desired delay length.
An StkError can be thrown if the rawwave path is incorrect.
StkFloat stk::Chorus::lastOut | ( | unsigned int | channel = 0 |
) | [inline] |
Return the specified channel value of the last computed stereo frame.
Use the lastFrame() function to get both values of the last computed stereo frame. The channel
argument must be 0 or 1 (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.
00094 { 00095 #if defined(_STK_DEBUG_) 00096 if ( channel > 1 ) { 00097 oStream_ << "Chorus::lastOut(): channel argument must be less than 2!"; 00098 handleError( StkError::FUNCTION_ARGUMENT ); 00099 } 00100 #endif 00101 00102 return lastFrame_[channel]; 00103 }
StkFloat stk::Chorus::tick | ( | StkFloat | input, | |
unsigned int | channel = 0 | |||
) | [inline] |
Input one sample to the effect and return the specified channel
value of the computed stereo frame.
Use the lastFrame() function to get both values of the computed stereo output frame. The channel
argument must be 0 or 1 (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.
00106 { 00107 #if defined(_STK_DEBUG_) 00108 if ( channel > 1 ) { 00109 oStream_ << "Chorus::tick(): channel argument must be less than 2!"; 00110 handleError( StkError::FUNCTION_ARGUMENT ); 00111 } 00112 #endif 00113 00114 delayLine_[0].setDelay( baseLength_ * 0.707 * ( 1.0 + modDepth_ * mods_[0].tick() ) ); 00115 delayLine_[1].setDelay( baseLength_ * 0.5 * ( 1.0 - modDepth_ * mods_[1].tick() ) ); 00116 lastFrame_[0] = effectMix_ * ( delayLine_[0].tick( input ) - input ) + input; 00117 lastFrame_[1] = effectMix_ * ( delayLine_[1].tick( input ) - input ) + input; 00118 return lastFrame_[channel]; 00119 }
Take a channel of the StkFrames object as inputs to the effect and replace with stereo outputs.
The StkFrames argument reference is returned. The stereo outputs are written to the StkFrames argument starting at the specified channel
. Therefore, the channel
argument must be less than ( channels() - 1 ) of 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.
00122 { 00123 #if defined(_STK_DEBUG_) 00124 if ( channel >= frames.channels() - 1 ) { 00125 oStream_ << "Chorus::tick(): channel and StkFrames arguments are incompatible!"; 00126 handleError( StkError::FUNCTION_ARGUMENT ); 00127 } 00128 #endif 00129 00130 StkFloat *samples = &frames[channel]; 00131 unsigned int hop = frames.channels() - 1; 00132 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) { 00133 delayLine_[0].setDelay( baseLength_ * 0.707 * ( 1.0 + modDepth_ * mods_[0].tick() ) ); 00134 delayLine_[1].setDelay( baseLength_ * 0.5 * ( 1.0 - modDepth_ * mods_[1].tick() ) ); 00135 *samples = effectMix_ * ( delayLine_[0].tick( *samples ) - *samples ) + *samples; 00136 samples++; 00137 *samples = effectMix_ * ( delayLine_[1].tick( *samples ) - *samples ) + *samples; 00138 } 00139 00140 lastFrame_[0] = *(samples-hop); 00141 lastFrame_[1] = *(samples-hop+1); 00142 return frames; 00143 }
StkFrames & stk::Chorus::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 effect and write stereo outputs to the oFrames
object.
The iFrames
object reference is returned. The iChannel
argument must be less than the number of channels in the iFrames
argument (the first channel is specified by 0). The oChannel
argument must be less than ( channels() - 1 ) of the oFrames
argument. 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.
00146 { 00147 #if defined(_STK_DEBUG_) 00148 if ( iChannel >= iFrames.channels() || oChannel >= oFrames.channels() - 1 ) { 00149 oStream_ << "Chorus::tick(): channel and StkFrames arguments are incompatible!"; 00150 handleError( StkError::FUNCTION_ARGUMENT ); 00151 } 00152 #endif 00153 00154 StkFloat *iSamples = &iFrames[iChannel]; 00155 StkFloat *oSamples = &oFrames[oChannel]; 00156 unsigned int iHop = iFrames.channels(), oHop = oFrames.channels(); 00157 for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) { 00158 delayLine_[0].setDelay( baseLength_ * 0.707 * ( 1.0 + modDepth_ * mods_[0].tick() ) ); 00159 delayLine_[1].setDelay( baseLength_ * 0.5 * ( 1.0 - modDepth_ * mods_[1].tick() ) ); 00160 *oSamples = effectMix_ * ( delayLine_[0].tick( *iSamples ) - *iSamples ) + *iSamples; 00161 *(oSamples+1) = effectMix_ * ( delayLine_[1].tick( *iSamples ) - *iSamples ) + *iSamples; 00162 } 00163 00164 lastFrame_[0] = *(oSamples-oHop); 00165 lastFrame_[1] = *(oSamples-oHop+1); 00166 return iFrames; 00167 }
The Synthesis ToolKit in C++ (STK) |
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |