Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
StkFloat
, the exact precision of which can be controlled via a typedef statement in Stk.h. By default, an StkFloat is a double-precision floating-point value. Thus, the ToolKit can use any normalization scheme desired. The base instruments and algorithms are implemented with a general audio sample dynamic maximum of +/-1.0.
In general, the computation and/or passing of values is performed on a "single-sample" basis. For example, the Noise class outputs random floating-point numbers in the range +/-1.0. The computation of such values occurs in the Noise::tick() function. The following program will generate 20 random floating-point (StkFloat
) values in the range -1.0 to +1.0:
#include "Noise.h" int main() { StkFloat output; Noise noise; for ( unsigned int i=0; i<20; i++ ) { output = noise.tick(); std::cout << "i = " << i << " : output = " << output << std::endl; } return 0; }
Nearly all STK classes implement tick()
functions that take and/or return sample values. Within the tick()
function, the fundamental sample calculations are performed for a given class. Most STK classes consume/generate a single sample per operation and their tick()
method takes/returns each sample "by value". In addition, every class implementing a tick()
function also provides one or more overloaded tick()
functions that can be used for vectorized computations, as shown in the next example.
#include "Noise.h" int main() { StkFrames output(20, 1); // initialize StkFrames to 20 frames and 1 channel (default: interleaved) Noise noise; noise.tick( output ); for ( unsigned int i=0; i<output.size(); i++ ) { std::cout << "i = " << i << " : output = " << output[i] << std::endl; } return 0; }
In this way, it might be possible to achieve improved processing efficiency using vectorized computations. The StkFrames class is a relatively new addition to the ToolKit to provide a general "mechanism" for handling and passing vectorized, multi-channel audio data. The StkFrames "type" provides functions to set and/or determine the number of audio channels and sample frames it holds, as well as the format (interleaved or non-interleaved) of its data. Further, the StkFrames class provides data interpolation and subscripting functionality by frame/channel values.
[Main tutorial page] [Next tutorial]
The Synthesis ToolKit in C++ (STK) |
©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |