36 logMsg(
"a KarplusString: %d Hz", 400);
62 unsigned numFrames = outputBuffer.mNumFrames;
63 sample *outPtr = outputBuffer.buffer(outBufNum);
64 sample *delayPtr = mDelayLine.buffer(0);
69 logMsg(
"Karplus Strong String nextBuffer");
73 for (
unsigned i = 0; i < numFrames; i++) {
74 samp = delayPtr[mIndex];
76 lastSample = delayPtr[mIndex - 1];
78 lastSample = delayPtr[mDelayLength - 1];
82 *outPtr++ = samp * scaleValue + offsetValue;
83 delayPtr[mIndex] = samp;
85 if (mIndex >= mDelayLength)
#define UPDATE_SCALABLE_CONTROLS
void logMsg(const char *format,...)
These are the public logging messages.
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
unsigned mIndex
current index in the delay line
Phased – a mix-in for objects with phase accumulators (local float) and frequency controls (an input...
void initDelayLine()
function to initialize the delay line
White noise – equal power per frequency.
void setSize(unsigned numChannels, unsigned numFrames)
void dump()
print debugging info.
void setFrequency(float frequency)
Scalable – mix-in class with scale and offset control inputs (may be constants or generators)...
unsigned mDelayLength
allocated size of the delay line
void trigger()
reset internal buffers to re-pluck the string.
float sample
(could be changed to int, or double)
static unsigned frameRate()
default frame rate
unsigned freqToKey(float frequency)
freqToKey – converts from frequency in Hz to MIDI key #
unsigned mEnergy
energy left in buffer
#define LOAD_SCALABLE_CONTROLS
Load the scale/offset-related values at the start.
void setFrequency(UnitGenerator &frequency)
Setter accessors.
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
void allocateBuffers()
fcn to malloc storage buffers
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
The mono_next_buffer method does all the work.
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
Destructor.
Buffer mDelayLine
the delay line (just a buffer, not a RingBuffer)
virtual void dump()
pretty-print the receiver's input/controls map
Base class of CSL exceptions (written upper-case). Has a string message.
#define DECLARE_SCALABLE_CONTROLS
Macros for all the Scalable UnitGenerators (note that these don't end with ";")