Jamoma API  0.6.0.a19
TTDelay.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspLibrary
4  *
5  * @brief Basic audio delay unit with 4 interpolation options.
6  *
7  * @authors Timothy Place & Nathan Wolek
8  *
9  * @copyright Copyright © 2003-2012, Timothy Place & Nathan Wolek @n
10  * This code is licensed under the terms of the "New BSD License" @n
11  * http://creativecommons.org/licenses/BSD/
12  */
13 
14 #ifndef __TT_DELAY_H__
15 #define __TT_DELAY_H__
16 
17 #include "TTDSP.h"
18 #include "TTDelayBuffer.h"
19 
20 
21 /** Delay a signal. */
22 class TTDSP_EXPORT TTDelay : public TTAudioObjectBase {
24 
25 protected:
26 
27  TTFloat64 mDelay;
28  TTFloat64 mDelayInSamples; ///< mIntegralDelay + mFractionalDelay
29  TTFloat64 mDelayMax;
30  TTUInt64 mDelayMaxInSamples;
31  TTSymbol mInterpolation;
32  TTFloat64 mFractionalDelay; ///< mDelayInSamples - mFractionalDelay. Used in interpolated dsp loops, to approximate the distance between two samples. If zero then the delay increment is precisely on a sample boundary.
33  TTUInt64 mIntegralDelay; ///< mDelayInSamples - mFractionalDelay. Used to set the TTDelayBuffer->mReadPointer.
34 
35  TTDelayBufferVector mBuffers;
36 
37 
38  /** This method gets called when the inherited maxNumChannels attribute is changed. */
39  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
40 
41  /** Receives notifications when there are changes to the inherited sr attribute. */
42  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
43 
44  // internal - set up the buffer memory
45  TTErr init(TTUInt64 newDelayMaxInSamples);
46 
47  // internal - position the buffer pointers
48  void reset();
49 
50  /** Zero out the delay's buffer. */
51  TTErr clear();
52 
53  /** Attribute Accessor */
54  TTErr setDelay(const TTValue& newValue);
55 
56  /** Attribute Accessor */
57  TTErr setDelayInSamples(const TTValue& newValue);
58 
59  /** Attribute Accessor */
60  TTErr setDelayMax(const TTValue& newValue);
61 
62  /** Attribute Accessor */
63  TTErr setDelayMaxInSamples(const TTValue& newValue);
64 
65  /** Attribute Accessor */
66  TTErr setInterpolation(const TTValue& newValue);
67 
68  // Process with a constant delay time
69  TTErr calculateNoInterpolation(const TTFloat64& x, TTFloat64& y, TTDelayBufferPtr data);
70  TTErr processAudioNoInterpolation(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
71 
72  TTErr calculateLinearInterpolation(const TTFloat64& x, TTFloat64& y, TTDelayBufferPtr data);
73  TTErr processAudioLinearInterpolation(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
74 
75  TTErr calculateCosineInterpolation(const TTFloat64& x, TTFloat64& y, TTDelayBufferPtr data);
76  TTErr processAudioCosineInterpolation(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
77 
78  TTErr calculateCubicInterpolation(const TTFloat64& x, TTFloat64& y, TTDelayBufferPtr data);
79  TTErr processAudioCubicInterpolation(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
80 
81  /** Unit Tests */
82  virtual TTErr test(TTValue& returnedTestInfo);
83 
84  // Process with a delay time set by a signal
85 // TTErr processAudioNoInterpolationWithDelaySignal(TTAudioSignal& in, TTAudioSignal& delayIn, TTAudioSignal& out, TTAudioSignal&);
86 // TTErr processAudioLinearInterpolationWithDelaySignal(TTAudioSignal& in, TTAudioSignal& delayIn, TTAudioSignal& out, TTAudioSignal&);
87 // TTErr processAudioCubicInterpolationWithDelaySignal(TTAudioSignal& in, TTAudioSignal& delayIn, TTAudioSignal& out, TTAudioSignal&);
88 
89 public:
90 
91  TTErr calculateNoInterpolation(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
92  TTErr calculateLinearInterpolation(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
93  TTErr calculateCosineInterpolation(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
94  TTErr calculateCubicInterpolation(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
95 
96 };
97 
98 
99 #endif // __TT_DELAY_H__
std::uint64_t TTUInt64
64 bit unsigned integer
Definition: TTBase.h:180
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
Jamoma DSP Library.
TTFloat64 mDelayInSamples
mIntegralDelay + mFractionalDelay
Definition: TTDelay.h:28
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
Audio delay buffer object.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTUInt64 mIntegralDelay
mDelayInSamples - mFractionalDelay. Used to set the TTDelayBuffer->mReadPointer.
Definition: TTDelay.h:33
A simple container for an array of TTAudioSignal pointers.
Delay a signal.
Definition: TTDelay.h:22
long TTPtrSizedInt
An integer that is the same size as a pointer.
Definition: TTBase.h:240
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
virtual TTErr test(TTValue &)
Default (empty) template for unit tests.
TTFloat64 mFractionalDelay
mDelayInSamples - mFractionalDelay. Used in interpolated dsp loops, to approximate the distance betwe...
Definition: TTDelay.h:32
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTDelayBuffer is a container object that holds some audio in a chunk of memory, with accessors for us...
Definition: TTDelayBuffer.h:27