Jamoma API  0.6.0.a19
TTZerocross.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspAnalysisLib
4  *
5  * @brief Jamoma DSP zero-crossing detector and counter.
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright Copyright © 2008, Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #ifndef __TT_ZEROCROSS_H__
18 #define __TT_ZEROCROSS_H__
19 
20 #include "TTDSP.h"
21 
22 
23 /** TTZerocross analyzes the incoming audio by looking for zero-crossings.
24  When a zero crossing occurs it both reports the crossing and also
25  keeps a count of the number of zero crossings per analysis period.
26  */
29 
30 protected:
31 
32  TTUInt32 mSize; ///< Attribute: size of the analysis buffer
33  TTFloat64 rSize; ///< reciprocal of the size attribute
34  TTBoolean lastSampleWasOverZero; ///< was the last sample over zero?
35  TTUInt32 counter; ///< counts zero-crossings
36  TTFloat64 finalCount;
37  TTUInt32 analysisLocation; ///< keep track of how many samples so far
38 
39  /** This method gets called when the inherited maxNumChannels attribute is changed.
40  @param oldMaxNumChannels The previous nuber of channels to process
41  @param Unused
42  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
43  */
44  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
45 
46 
47  /** This method gets called when the inherited sr attribute (sample rate) is changed.
48  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
49  */
50  TTErr updateSr();
51 
52 
53  /** Audio processing method.
54  @details WARNING: This unit requires 1 input and 2 outputs - it does not yet configure itself for other arrangements!
55 
56  @param in A pointer to a TTAudioSignal object that may contain any number of channels. This signal is considered the master, and thus it provides the vectorsize and number of channels should the two signals not be matched.
57  @param out A pointer to a TTAudioSignal object that has the output sample vectors.
58  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
59  */
61 
62 
63  /** Set the size attribute
64  @param value New value for the attribute
65  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
66  */
67  TTErr setSize(const TTValue& value);
68 
69 
70  /** Reset the history used in the analysis.
71  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
72  */
73  TTErr Clear();
74 
75 };
76 
77 
78 #endif // __TT_ZEROCROSS_H__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
TTUInt32 counter
counts zero-crossings
Definition: TTZerocross.h:35
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Audio processing method.
Definition: TTZerocross.cpp:74
TTErr setSize(const TTValue &value)
Set the size attribute.
Definition: TTZerocross.cpp:65
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTUInt32 analysisLocation
keep track of how many samples so far
Definition: TTZerocross.h:37
TTBoolean lastSampleWasOverZero
was the last sample over zero?
Definition: TTZerocross.h:34
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
This method gets called when the inherited maxNumChannels attribute is changed.
Definition: TTZerocross.cpp:49
TTErr Clear()
Reset the history used in the analysis.
Definition: TTZerocross.cpp:55
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTFloat64 rSize
reciprocal of the size attribute
Definition: TTZerocross.h:33
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...
Definition: TTBase.h:342
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
TTZerocross analyzes the incoming audio by looking for zero-crossings.
Definition: TTZerocross.h:27
TTUInt32 mSize
Attribute: size of the analysis buffer.
Definition: TTZerocross.h:32
TTErr updateSr()
This method gets called when the inherited sr attribute (sample rate) is changed. ...
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34