15 : mInput(&input), mBufferSize(blockSize), mFramePointer(-1) {
31 unsigned numFrames = outBuffer.mNumFrames;
32 unsigned copiedSoFar = 0;
42 if (mFramePointer == -1) {
45 mInput->nextBuffer(mInputBuffer);
49 unsigned toCopy =
csl_min((mBufferSize - mFramePointer),
50 (numFrames - copiedSoFar));
52 for (
unsigned i = 0; i < outBuffer.mNumChannels; i++) {
53 unsigned whichIn =
csl_min(i, (mNumChannels - 1));
54 SampleBuffer src = mInputBuffer.buffer(whichIn) + mFramePointer;
56 memcpy (dest, src, toCopy *
sizeof(
sample));
60 mFramePointer += toCopy;
61 if (mFramePointer >= (
int) mBufferSize)
63 copiedSoFar += toCopy;
64 if (copiedSoFar >= numFrames)
sample * SampleBuffer
1-channel buffer data type, vector of (sample)
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
void freeBuffers()
fcn to free them
void setSize(unsigned numChannels, unsigned numFrames)
UnitGenerator * mInput
my input unit generator (pointer)
Buffer mInputBuffer
buffer used to pull input
virtual unsigned numChannels()
float sample
(could be changed to int, or double)
unsigned mNumChannels
my "expected" number of output channels
void nextBuffer(Buffer &outputBuffer)
the work-horse method calls the up-hill graph as needed
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
BlockResizer(UnitGenerator &input, unsigned blockSize)
ctor / dtor
void allocateBuffers()
fcn to malloc storage buffers
Base class of CSL exceptions (written upper-case). Has a string message.
unsigned mBufferSize
fixed buffer size of the up-hill graph