18 #define thisTTClass TTCrossfade
19 #define thisTTClassName "crossfade"
20 #define thisTTClassDescription "Multichannel crossfader"
21 #define thisTTClassTags "audio, processor, mixing"
24 static bool zeroed =
false;
44 TTErr setProcessPointers();
68 TT_AUDIO_CONSTRUCTOR_EXPORT(Crossfade)
79 addMessageProperty( Mode, description,
TT(
"Wether the crossfader is based on a 512-point lookup table or on a real-time weight computation."));
88 setAttributeValue(
TT(
"position"), 0.5);
89 setAttributeValue(
TT(
"shape"),
TT(
"equalPower"));
90 setAttributeValue(
TT(
"mode"),
TT(
"lookup"));
94 TTCrossfade::~TTCrossfade()
101 return setProcessPointers();
108 return setProcessPointers();
112 TTErr TTCrossfade::setProcessPointers()
116 if (mShape ==
TT(
"equalPower") && mMode ==
TT(
"lookup")) {
119 else if (mShape ==
TT(
"equalPower") && mMode ==
TT(
"calculate")) {
122 else if (mShape ==
TT(
"squareRoot") && mMode ==
TT(
"calculate")) {
125 else if (mShape ==
TT(
"squareRoot") && mMode ==
TT(
"lookup")) {
137 #pragma mark Interleaved Process Methods
154 numchannels = TTAudioSignal::getMaxChannelCount(in, in2, out);;
155 for (channel=0; channel<numchannels; channel++) {
159 if (channel < in.getNumChannelsAsInt())
162 inSampleA = zeroVector1;
164 if (channel < in2.getNumChannelsAsInt())
167 inSampleB = zeroVector2;
169 if (channel < out.getNumChannelsAsInt())
172 outSample = zeroVector3;
174 vs = in.getVectorSizeAsInt();
177 *outSample++ = (*inSampleB++ * mPosition) + (*inSampleA++ * (1.0 - mPosition));
182 if (in.getNumChannelsAsInt() != out.getNumChannelsAsInt()*2)
185 for (channel=0; channel<numchannels; channel++) {
189 vs = in.getVectorSizeAsInt();
192 *outSample++ = (*inSampleB++ * mPosition) + (*inSampleA++ * (1.0 - mPosition));
214 numchannels = TTAudioSignal::getMaxChannelCount(in, in2, out);;
215 for (channel=0; channel<numchannels; channel++) {
216 if (channel < in.getNumChannelsAsInt())
219 inSampleA = zeroVector1;
221 if (channel < in2.getNumChannelsAsInt())
224 inSampleB = zeroVector2;
226 if (channel < out.getNumChannelsAsInt())
229 outSample = zeroVector3;
231 vs = in.getVectorSizeAsInt();
234 index = (int)(mPosition * 511.0);
241 if (in.getNumChannelsAsInt() != out.getNumChannelsAsInt()*2)
244 for (channel=0; channel<numchannels; channel++) {
248 vs = in.getVectorSizeAsInt();
251 index = (int)(mPosition * 511.0);
274 numchannels = TTAudioSignal::getMaxChannelCount(in, in2, out);;
275 for (channel=0; channel<numchannels; channel++) {
276 if (channel < in.getNumChannelsAsInt())
279 inSampleA = zeroVector1;
281 if (channel < in2.getNumChannelsAsInt())
284 inSampleB = zeroVector2;
286 if (channel < out.getNumChannelsAsInt())
289 outSample = zeroVector3;
291 vs = in.getVectorSizeAsInt();
294 index = (int)(mPosition * 511.0);
301 if (in.getNumChannelsAsInt() != out.getNumChannelsAsInt()*2)
304 for (channel=0; channel<numchannels; channel++) {
308 vs = in.getVectorSizeAsInt();
311 index = (int)(mPosition * 511.0);
338 for (channel=0; channel<numchannels; channel++) {
342 vs = in.getVectorSizeAsInt();
347 *outSample++ = (*inSampleB++ * (sin(radPosition))) + (*inSampleA++ * (cos(radPosition)));
353 if (in.getNumChannelsAsInt() != out.getNumChannelsAsInt()*2)
356 for (channel=0; channel<numchannels; channel++) {
360 vs = in.getVectorSizeAsInt();
365 *outSample++ = (*inSampleB++ * (sin(radPosition))) + (*inSampleA++ * (cos(radPosition)));
387 for (channel=0; channel<numchannels; channel++) {
391 vs = in.getVectorSizeAsInt();
394 *outSample++ = (*inSampleB++ * (sqrt(mPosition))) + (*inSampleA++ * (sqrt(1 - mPosition)));
399 if (in.getNumChannelsAsInt() != out.getNumChannelsAsInt()*2)
402 for (channel=0; channel<numchannels; channel++) {
406 vs = in.getVectorSizeAsInt();
409 *outSample++ = (*inSampleB++ * (sqrt(mPosition))) + (*inSampleA++ * (sqrt(1 - mPosition)));
std::uint16_t TTUInt16
16 bit unsigned integer
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
Crossfade between two input signals.
An invalid number of audio channels for a given context was encountered.
double TTFloat64
64 bit floating point number
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
#define addAttributeProperty(attributeName, propertyName, initialValue)
A convenience macro to be used for registering properties of attributes.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
TTErr(TTAudioObjectBase::* TTProcessMethod)(TTAudioSignalArrayPtr in, TTAudioSignalArrayPtr out)
A type that can be used to store a pointer to a process method (which calculates a vector of samples)...
static TTChannelCount getMinChannelCount(const TTAudioSignal &signal1, const TTAudioSignal &signal2)
Use this class method to determine the least number of channels the two signals have in common...
The TTAudioSignal class represents N vectors of audio samples for M channels.
TTSampleValue ** mSampleVectors
An array of pointers to the first sample in each vector. Declared Public for fast access...
TTErr setProcess(TTProcessMethod processMethod)
Set the audio processing routine to point to a method that is defined as an arg to this function...
TTFOUNDATION_EXPORT const TTFloat32 kTTLookupEqualPower[]
Equal Power lookup table, 512 elements.
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
A simple container for an array of TTAudioSignal pointers.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
TTFOUNDATION_EXPORT const TTFloat64 kTTHalfPi
Pre-calculated value of pi/2.
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
TTFOUNDATION_EXPORT const TTFloat32 kTTLookupSquareRoot[]
Square Root lookup table, 512 elements.
TTFloat64 TTSampleValue
A value representing a single audio sample.
[doxygenAppendixC_copyExample]
TTChannelCount numAudioSignals
The number of audio signal pointers which are actually valid.
#define addMessageProperty(messageName, propertyName, initialValue)
A convenience macro to be used for registering properties of messages.