19 :
Sine(frequency), mTableSize(size) {
39 for (
unsigned i = 0; i < mTableSize/6; i++)
41 for (
unsigned i = mTableSize/6; i < 5*mTableSize/6; i++) {
45 for (
unsigned i = 5*mTableSize/6; i <
mTableSize; i++)
50 *sampPtr++ = val * val * val;
55 for (
unsigned i = 0; i < mTableSize/4; i++)
57 for (
unsigned i = mTableSize/4; i < 3*mTableSize/4; i++) {
61 for (
unsigned i = 3*mTableSize/4; i <
mTableSize; i++)
73 sample * buffer = outputBuffer.buffer(outBufNum);
74 unsigned numFrames = outputBuffer.mNumFrames;
76 sample *
function = mTransferFunction.buffer(0);
77 unsigned fcnLength = mTransferFunction.mNumFrames;
78 unsigned fcnLengthHalf = fcnLength / 2;
82 for (
unsigned i = 0; i < numFrames; i++) {
84 unsigned index = (samp + 1.0) * fcnLengthHalf;
85 if (index < 0) index = 0;
86 if (index >= fcnLength) index = fcnLength - 1;
88 samp =
function[index];
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
really compute the next buffer given an offset base channel; this is called by nextBuffer, possibly multiple times
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
virtual SampleBuffer buffer(unsigned bufNum)
convenience accessors for sample buffers
void setSize(unsigned numChannels, unsigned numFrames)
Buffer mTransferFunction
the wave-shaping look-up table (it's just a sample buffer)
float sample
(could be changed to int, or double)
void initWaveTable(unsigned sel=0)
function to initialize the default shaping table
Sine – oscillator class (this computes the sine fcn on the fly)
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
unsigned mTableSize
Table size in bytes.
void allocateBuffers()
fcn to malloc storage buffers
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
really compute the next buffer given an offset base channel; this is called by nextBuffer, possibly multiple times
Base class of CSL exceptions (written upper-case). Has a string message.