31 sample * buffer = outputBuffer.buffer(outBufNum);
36 logMsg(
"SimpleSine nextBuffer");
39 for (
unsigned i = 0; i < outputBuffer.mNumFrames; i++) {
40 *buffer++ = sin(mPhase);
41 mPhase += phaseIncrement;
63 #ifdef NOT_THIS_WAY // This is the really verbose way; see below for how to use the macros to make this easier
66 sample * buffer = outputBuffer.buffer(outBufNum);
71 bool freqDyn = (freqUG != NULL);
76 this->pullInput(freqPort, outputBuffer);
82 for (
unsigned i = 0; i < outputBuffer.mNumFrames; i++) {
83 *buffer++ = sin(mPhase);
84 mPhase += (freqC * rateRecip);
101 sample * buffer = outputBuffer.buffer(outBufNum);
102 unsigned numFrames = outputBuffer.mNumFrames;
107 logMsg(
"SineAsPhased nextBuffer");
111 for (
unsigned i = 0; i < numFrames; i++) {
112 *buffer++ = sin(mPhase);
113 mPhase += (freqValue * rateRecip);
143 #ifdef NOT_THIS_WAY // This is the really verbose way; see below for how to use the macros to make this easier
146 sample * buffer = outputBuffer.buffer(outBufNum);
157 bool freqDyn = (freqUG != NULL);
158 bool scaleDyn = (scaleUG != NULL);
159 bool offsetDyn = (offsetUG != NULL);
164 float freqC, scaleC, offsetC
167 this->pullInput(freqPort, outputBuffer);
174 this->pullInput(scalePort, outputBuffer);
178 scaleC = scalePort->
mValue;
181 this->pullInput(offsetPort, outputBuffer);
185 offsetC = offsetPort->
mValue;
187 for (
unsigned i = 0; i < outputBuffer.mNumFrames; i++) {
188 *buffer++ = sin(mPhase);
189 mPhase += (freqC * rateRecip);
211 sample * buffer = outputBuffer.buffer(outBufNum);
213 unsigned numFrames = outputBuffer.mNumFrames;
217 logMsg(
"SineAsScaled nextBuffer");
222 for (
unsigned i = 0; i < numFrames; i++) {
223 *buffer++ = (sin(mPhase) * scaleValue) + offsetValue;
224 mPhase += (freqValue * rateRecip);
#define UPDATE_SCALABLE_CONTROLS
void logMsg(const char *format,...)
These are the public logging messages.
#define DECLARE_PHASED_CONTROLS
Macros for all the Phased UnitGenerators (note that these don't end with ";") These make some assumpt...
static unsigned mFrameRate
default sample rate (tested up to 96000)
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Phased – a mix-in for objects with phase accumulators (local float) and frequency controls (an input...
virtual SampleBuffer buffer(unsigned bufNum)
convenience accessors for sample buffers
SineAsPhased()
Constructors.
float mValue
my value (in case I'm fixed [mUGen == NULL])
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
the monoNextBuffer method is where the DSP takes place
void dump()
pretty-print the receiver
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
the monoNextBuffer method is where the DSP takes place
~SineAsScaled()
Destructor.
Scalable – mix-in class with scale and offset control inputs (may be constants or generators)...
float sample
(could be changed to int, or double)
#define UPDATE_PHASED_CONTROLS
Update the freq-related value in the loop.
SimpleSine()
Constructors.
void dump()
pretty-print the receiver
SineAsScaled()
Constructors.
#define LOAD_PHASED_CONTROLS
Load the freq-related values at the start of the callback; if the frequency is a dynamic UGen input...
#define LOAD_SCALABLE_CONTROLS
Load the scale/offset-related values at the start.
UnitGenerator * mUGen
my unit generator (pointer or NULL)
Buffer * mBuffer
the buffer used to hold my output
~SineAsPhased()
Destructor.
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Port – used to represent constant, control-rate or signal inputs and outputs in named maps; holds a ...
virtual void dump()
pretty-print the receiver's input/controls map
Base class of CSL exceptions (written upper-case). Has a string message.
void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
the monoNextBuffer method is where the DSP takes place
#define DECLARE_SCALABLE_CONTROLS
Macros for all the Scalable UnitGenerators (note that these don't end with ";")