20 #include "TTUnitTest.h"
22 #define thisTTClass TTAudioObjectBase
28 inputArray(kTTSym_audiosignalarray,2),
29 outputArray(kTTSym_audiosignalarray,2),
30 startProcessingTime(0.0),
31 accumulatedProcessingTime(0.0),
32 accumulatedProcessingCalls(0.0)
69 if (newNumChannels < 1)
76 sendMessage(
"updateMaxNumChannels", oldMaxNumChannels, kTTValNONE);
89 sendMessage(
"updateSampleRate", oldSampleRate, kTTValNONE);
99 if (i<inputs->numAudioSignals) {
121 (outputs->getSignal(i)).clear();
274 out.setSampleRate(
sr);
298 out.setSampleRate(
sr);
325 out1.setSampleRate(
sr);
326 out2.setSampleRate(
sr);
352 out.setSampleRate(
sr);
373 outputs->setAllSampleRates(
sr);
406 #pragma mark Utilities
442 delay = delay * 0.001;
443 if (decay_time < 0) {
444 fb = delay / -decay_time;
446 fb = pow(10., (fb / 20.));
450 fb = delay / decay_time;
452 fb = pow(10., (fb / 20.));
463 decay_time = 20. * (log10(feedback));
464 decay_time = -60.0 / decay_time;
465 decay_time = decay_time * (delay);
467 else if (feedback < 0) {
468 decay_time = 20. * (log10(fabs(feedback)));
469 decay_time = -60.0 / decay_time;
470 decay_time = decay_time * (-delay);
TTErr sendMessage(const TTSymbol name)
TODO: Document this function.
TTErr setMaxNumChannels(const TTValue &newValue)
Setter for the maxNumChannels attribute.
TTErr setSr(const TTValue &newValue)
Setter for the sample-rate attribute.
TTErr(TTObjectBase::* TTSetterMethod)(const TTAttribute &attribute, const TTValue &value)
A type that can be used to store a pointer to a message for an object.
TTErr unlock()
Unlock the object when thread-safe processing is no longer required.
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
TTCalculateMethod currentCalculateMethod
This function pointer always points to the current calculate routine.
TTFloat64 accumulatedProcessingCalls
The number of times the process method has been called (for benchmarking)
TTFloat64 degreesToRadians(const TTFloat64 degrees)
Degrees-to-radians conversion.
TTFOUNDATION_EXPORT TTEnvironment * ttEnvironment
The environment object has one instance, which is global in scope.
TTObject inputArray
If the process method is passed a signal, rather than an array of signals, we wrap the signal in this...
TTChannelCount mMaxNumChannels
This is the maximum number of channels that can be guaranteed to work.
TTFloat64 decayToFeedback(const TTFloat64 decay_time, TTFloat64 delay)
Decay Time (seconds) to feedback coefficient conversion.
TTProcessMethod processMethod
This function pointer points to the active (non-bypass) processing routine.
size_type size() const noexcept
Return the number of elements.
TTErr calculate(const TTFloat64 &x, TTFloat64 &y)
Calculate a single sample of output for a single sample of input.
TTFOUNDATION_EXPORT const TTFloat64 kTTTwoPi
Pre-calculated value of pi * 2.
TTFloat64 startProcessingTime
The time at which this object's process method was last invoked (for benchmarking) ...
TTAudioObjectBase is the Jamoma DSP Audio Object Base Class
TTErr setBypass(const TTValue &value)
Bypass the audio processing routine and copy all input samples to the output unchanged.
TTBoolean mBenchmarking
Attribute: Enable benchmarking in TTAudioObject and TTDataObject ?
Base class for all first-class Jamoma objects.
TTProcessMethod currentProcessMethod
This function pointer always points to the current processing routine.
TTErr(TTObjectBase::* TTMethod)(const TTSymbol methodName, const TTValue &anInputValue, TTValue &anOutputValue)
A type that can be used to store a pointer to a message for an object.
TTFloat64 radiansToHertz(const TTFloat64 radians)
Convert radians into Hertz.
TTBoolean attrBypass
Are we bypassing the processMethod?
TTFloat64 accumulatedProcessingTime
The amount of time spent in this object's process method (for benchmarking)
TTErr registerAttribute(const TTSymbol name, const TTDataType type, void *address)
Register an attribute.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
double TTFloat64
64 bit floating point number
TTErr muteProcess(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A muted audio processing method, which simply copies zeroes to the output.
TTBoolean valid
If the object isn't completely built, or is in the process of freeing, this will be false...
TTObject outputArray
If the process method is passed a signal, rather than an array of signals, we wrap the signal in this...
TTErr registerMessage(const TTSymbol name, TTMethod method)
Register a message with this object.
TTFloat64 TTGetTimeInMicroseconds()
Return the current system time in microseconds.
16-bit unsigned integer, range is 0 through 65,535.
TTErr resetBenchmarking()
Reset the benchmarking accumulation used to calculate the results of getProcessingBenchmark().
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
void * TTPtr
A generic pointer.
TTErr bypassCalculate(const TTFloat64 &x, TTFloat64 &y, TTPtr data)
Produces a result for calls to calculate when the unit is bypassed.
TTAudioObjectBase(const TTValue &arguments)
Constructor.
TTFOUNDATION_EXPORT const TTFloat64 kTTRadiansToDegrees
Factor constant for converting radians to degrees.
TTErr defaultCalculateMethod(const TTFloat64 &x, TTFloat64 &y, TTPtr data)
A default calculate method, which simply calls the process method with 1 channel signals that are 1 s...
TTErr clear()
Zero out all of the sample values in the audio signal.
TTBoolean attrMute
Mute the processMethod.
TTCalculateMethod calculateMethod
This function pointer points to the active (non-bypass) calculate routine.
#define addAttributeProperty(attributeName, propertyName, initialValue)
A convenience macro to be used for registering properties of attributes.
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)...
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
TTFloat64 hertzToRadians(const TTFloat64 hz)
Convert Hertz to radians.
Boolean (1/0) or (true/false) flag.
TTErr calculateMessage(TTValueConstRef input, TTValueRef output)
TTErr(TTAudioObjectBase::* TTCalculateMethod)(const TTFloat64 &x, TTFloat64 &y, TTPtr data)
A type that can be used to store a pointer to a calculate method (which calculates a single sample)...
TTErr setCalculate(TTCalculateMethod newCalculateMethod)
Set the sample calculate routine to point to a method that is defined as an arg to this function...
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 process(TTAudioSignal &in, TTAudioSignal &out)
Process the input signal, resulting in an output signal.
TTErr setProcess(TTProcessMethod processMethod)
Set the audio processing routine to point to a method that is defined as an arg to this function...
TTErr bypassProcess(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
The default audio processing method, which simply copies a signal through with no modifications...
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
virtual ~TTAudioObjectBase()
Destructor.
TTFloat64 radiansToDegrees(const TTFloat64 radians)
Radians-to-degrees conversion.
A simple container for an array of TTAudioSignal pointers.
void clear()
Clear all values from the vector, leaving with size of 0.
TTEnvironment is a global object providing information on the environemt.
TTErr setMute(const TTValue &value)
Mute the audio processing routine and zero all output.
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
TTFloat64 feedbackToDecay(const TTFloat64 feedback, const TTFloat64 delay)
Return the decay time based on the feedback coefficient.
std::uint32_t TTUInt32
32 bit unsigned integer
TTFOUNDATION_EXPORT const TTFloat64 kTTDegreesToRadians
Factor constant for converting degrees to radians.
TTUInt32 mSampleRate
Current sample rate as understood by the environment as a whole.
TTFloat64 srMill
1/1000 of the current sample rate (samples per millisecond)
TTErr getProcessingBenchmark(TTValueConstRef, TTValueRef v)
Return the average time spent by this object processing audio since the last reset.
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
32-bit unsigned integer, range is 0 through 4,294,967,295.
TTFloat64 srInv
1.0 over the current sample rate (inverse)
TTObjectBase * instance() const
Return a direct pointer to the internal instance.
virtual TTErr test(TTValue &)
Default (empty) template for unit tests.
static TTErr copy(const TTAudioSignal &source, TTAudioSignal &dest, TTChannelCount channelOffset=0)
Copy the audio from one signal into another.
Set this flag if the method you are binding to this message is prototyped to accept no arguments...
TTErr allocWithVectorSize(const TTUInt16 newVectorSize)
Allocate memory for all channels at the specified vectorsize, if the vectorsize is different from the...
TTErr lock()
Lock the object in order to ensure thread-safe processing.
[doxygenAppendixC_copyExample]
TTChannelCount numAudioSignals
The number of audio signal pointers which are actually valid.
TTUInt32 sr
Current sample rate being used by this object.