Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK guitar model class. More...
#include <Guitar.h>
Public Member Functions | |
Guitar (unsigned int nStrings=6, std::string bodyfile="") | |
Class constructor, specifying an arbitrary number of strings (default = 6). | |
void | clear (void) |
Reset and clear all internal state. | |
void | setBodyFile (std::string bodyfile="") |
Set the string excitation, using either a soundfile or computed noise. | |
void | setPluckPosition (StkFloat position, int string=-1) |
Set the pluck position for one or all strings. | |
void | setLoopGain (StkFloat gain, int string=-1) |
Set the loop gain for one or all strings. | |
void | setFrequency (StkFloat frequency, unsigned int string=0) |
Set instrument parameters for a particular frequency. | |
void | noteOn (StkFloat frequency, StkFloat amplitude, unsigned int string=0) |
Start a note with the given frequency and amplitude. | |
void | noteOff (StkFloat amplitude, unsigned int string=0) |
Stop a note with the given amplitude (speed of decay). | |
void | controlChange (int number, StkFloat value, int string=-1) |
Perform the control change specified by number and value (0.0 - 128.0). | |
StkFloat | lastOut (void) |
Return the last computed output value. | |
StkFloat | tick (StkFloat input=0.0) |
Take an optional input sample and compute one output sample. | |
StkFrames & | tick (StkFrames &frames, unsigned int channel=0) |
Take a channel of the iFrames object as inputs to the class and write outputs to the oFrames object. | |
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 outputs to the oFrames object. |
STK guitar model class.
This class implements a guitar model with an arbitrary number of strings (specified during instantiation). Each string is represented by an stk::Twang object. The model supports commuted synthesis, as discussed by Smith and Karjalainen. It also includes a basic body coupling model and supports feedback.
This class does not attempt voice management. Rather, most functions support a parameter to specify a particular string number and string (voice) management is assumed to occur externally. Note that this class does not inherit from stk::Instrmnt because of API inconsistencies.
This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.
Control Change Numbers:
by Gary P. Scavone, 2012.
void stk::Guitar::setBodyFile | ( | std::string | bodyfile = "" |
) |
Set the string excitation, using either a soundfile or computed noise.
If no argument is provided, the std::string is empty, or an error occurs reading the file data, an enveloped noise signal will be generated for use as the pluck excitation.
void stk::Guitar::setPluckPosition | ( | StkFloat | position, | |
int | string = -1 | |||
) |
Set the pluck position for one or all strings.
If the string
argument is < 0, the pluck position is set for all strings.
void stk::Guitar::setLoopGain | ( | StkFloat | gain, | |
int | string = -1 | |||
) |
Set the loop gain for one or all strings.
If the string
argument is < 0, the loop gain is set for all strings.
void stk::Guitar::noteOn | ( | StkFloat | frequency, | |
StkFloat | amplitude, | |||
unsigned int | string = 0 | |||
) |
Start a note with the given frequency and amplitude.
If the amplitude
parameter is less than 0.2, the string will be undamped but it will not be "plucked."
void stk::Guitar::controlChange | ( | int | number, | |
StkFloat | value, | |||
int | string = -1 | |||
) |
Perform the control change specified by number and value (0.0 - 128.0).
If the string
argument is < 0, then the control change is applied to all strings (if appropriate).
Take a channel of the iFrames
object as inputs to the class 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.
00163 { 00164 #if defined(_STK_DEBUG_) 00165 if ( channel >= frames.channels() ) { 00166 oStream_ << "Guitar::tick(): channel and StkFrames arguments are incompatible!"; 00167 handleError( StkError::FUNCTION_ARGUMENT ); 00168 } 00169 #endif 00170 00171 StkFloat *samples = &frames[channel]; 00172 unsigned int hop = frames.channels(); 00173 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) 00174 *samples = tick( *samples ); 00175 00176 return frames; 00177 }
StkFrames & stk::Guitar::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 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.
00180 { 00181 #if defined(_STK_DEBUG_) 00182 if ( iChannel >= iFrames.channels() || oChannel >= oFrames.channels() ) { 00183 oStream_ << "Guitar::tick(): channel and StkFrames arguments are incompatible!"; 00184 handleError( StkError::FUNCTION_ARGUMENT ); 00185 } 00186 #endif 00187 00188 StkFloat *iSamples = &iFrames[iChannel]; 00189 StkFloat *oSamples = &oFrames[oChannel]; 00190 unsigned int iHop = iFrames.channels(), oHop = oFrames.channels(); 00191 for ( unsigned int i=0; i<iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) 00192 *oSamples = tick( *iSamples ); 00193 00194 return iFrames; 00195 }
The Synthesis ToolKit in C++ (STK) |
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |