Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK reed table class. More...
#include <ReedTable.h>
Public Member Functions | |
ReedTable (void) | |
Default constructor. | |
void | setOffset (StkFloat offset) |
Set the table offset value. | |
void | setSlope (StkFloat slope) |
Set the table slope value. | |
StkFloat | tick (StkFloat input) |
Take one sample input and map to one sample of output. | |
StkFrames & | tick (StkFrames &frames, unsigned int channel=0) |
Take a channel of the StkFrames object as inputs to the table 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 table and write outputs to the oFrames object. |
STK reed table class.
This class implements a simple one breakpoint, non-linear reed function, as described by Smith (1986). This function is based on a memoryless non-linear spring model of the reed (the reed mass is ignored) which saturates when the reed collides with the mouthpiece facing.
See McIntyre, Schumacher, & Woodhouse (1983), Smith (1986), Hirschman, Cook, Scavone, and others for more information.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
void stk::ReedTable::setOffset | ( | StkFloat | offset | ) | [inline] |
void stk::ReedTable::setSlope | ( | StkFloat | slope | ) | [inline] |
Take a channel of the StkFrames object as inputs to the table 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.
00099 { 00100 #if defined(_STK_DEBUG_) 00101 if ( channel >= frames.channels() ) { 00102 oStream_ << "ReedTable::tick(): channel and StkFrames arguments are incompatible!"; 00103 handleError( StkError::FUNCTION_ARGUMENT ); 00104 } 00105 #endif 00106 00107 StkFloat *samples = &frames[channel]; 00108 unsigned int hop = frames.channels(); 00109 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) { 00110 *samples = offset_ + (slope_ * *samples); 00111 if ( *samples > 1.0) *samples = 1.0; 00112 if ( *samples < -1.0) *samples = -1.0; 00113 } 00114 00115 lastFrame_[0] = *(samples-hop); 00116 return frames; 00117 }
StkFrames & stk::ReedTable::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 table 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.
00120 { 00121 #if defined(_STK_DEBUG_) 00122 if ( iChannel >= iFrames.channels() || oChannel >= oFrames.channels() ) { 00123 oStream_ << "ReedTable::tick(): channel and StkFrames arguments are incompatible!"; 00124 handleError( StkError::FUNCTION_ARGUMENT ); 00125 } 00126 #endif 00127 00128 StkFloat *iSamples = &iFrames[iChannel]; 00129 StkFloat *oSamples = &oFrames[oChannel]; 00130 unsigned int iHop = iFrames.channels(), oHop = oFrames.channels(); 00131 for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) { 00132 *oSamples = offset_ + (slope_ * *iSamples); 00133 if ( *oSamples > 1.0) *oSamples = 1.0; 00134 if ( *oSamples < -1.0) *oSamples = -1.0; 00135 } 00136 00137 lastFrame_[0] = *(oSamples-oHop); 00138 return iFrames; 00139 }
The Synthesis ToolKit in C++ (STK) |
©1995-2011 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |