Jamoma API  0.6.0.a19
TTClipper.cpp
1 /*
2  * Clipper
3  * Extension Class for Jamoma DSP
4  * Copyright © 2008, Timothy Place
5  *
6  *
7  * This is the simplest possible example of an extention, and can be used as a template for creating new extentions.
8  *
9  * License: This code is licensed under the terms of the "New BSD License"
10  * http://creativecommons.org/licenses/BSD/
11  */
12 
13 #include "TTDSP.h"
14 
15 #define thisTTClass TTClipper
16 #define thisTTClassName "clipper"
17 #define thisTTClassDescription "Limits the amplitude of signals."
18 #define thisTTClassTags "audio, processor"
19 
20 
21 /** Hard-clip signals to a low and high bound. */
22 
25 
26  TTFloat64 mLowBound; ///< Attribute: low bound for clipping
27  TTFloat64 mHighBound; ///< Attribute: high bound for clipping
28 
29  TTErr calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel)
30  {
31  y = x;
32  TTLimit(y, mLowBound, mHighBound);
33  return kTTErrNone;
34  }
35 
36  /** Audio Processing Method */
37  TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
38  {
39  TT_WRAP_CALCULATE_METHOD(calculateValue);
40  }
41 };
42 
43 TT_AUDIO_CONSTRUCTOR_EXPORT(Clipper)
44 {
45  addAttribute( LowBound, kTypeFloat64);
46  addMessageProperty( LowBound, description, TT("Sets the minimum amplitude."));
47 
48  addAttribute( HighBound, kTypeFloat64);
49  addMessageProperty( HighBound, description, TT("Sets the maximum amplitude."));
50 
51  setAttributeValue(TT("lowBound"), -1.0);
52  setAttributeValue(TT("highBound"), 1.0);
53  setProcessMethod(processAudio);
54 }
55 
56 
57 TTClipper::~TTClipper()
58 {;}
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
Definition: TTAttribute.h:29
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
64-bit floating point
Definition: TTBase.h:272
A simple container for an array of TTAudioSignal pointers.
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
No Error.
Definition: TTBase.h:343
Hard-clip signals to a low and high bound.
Definition: TTClipper.cpp:23
#define addMessageProperty(messageName, propertyName, initialValue)
A convenience macro to be used for registering properties of messages.
Definition: TTMessage.h:37