Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NodeMath.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2014, The Cinder Project
3 
4 This code is intended to be used with the Cinder C++ library, http://libcinder.org
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7 the following conditions are met:
8 
9 * Redistributions of source code must retain the above copyright notice, this list of conditions and
10 the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21 POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 #pragma once
25 
26 #include "cinder/audio/Node.h"
27 #include "cinder/audio/Param.h"
28 #include "cinder/CinderMath.h"
29 
30 namespace cinder { namespace audio {
31 
33 class MathNode : public Node {
34  public:
36  void setValue( float value ) { mParam.setValue( value ); }
38  float getValue() const { return mParam.getValue(); }
39 
41  Param* getParam() { return &mParam; }
42 
43  protected:
44  MathNode( float initialValue, const Format &format );
45 
47 };
48 
50 class AddNode : public MathNode {
51  public:
52  AddNode( const Format &format = Format() ) : MathNode( 0, format ) {}
53  AddNode( float initialValue, const Format &format = Format() ) : MathNode( initialValue, format ) {}
54 
55 protected:
56  void process( Buffer *buffer ) override;
57 };
58 
60 class SubtractNode : public MathNode {
61  public:
62  SubtractNode( const Format &format = Format() ) : MathNode( 0, format ) {}
63  SubtractNode( float initialValue, const Format &format = Format() ) : MathNode( initialValue, format ) {}
64 
65  protected:
66  void process( Buffer *buffer ) override;
67 };
68 
70 class MultiplyNode : public MathNode {
71  public:
72  MultiplyNode( const Format &format = Format() ) : MathNode( 0, format ) {}
73  MultiplyNode( float initialValue, const Format &format = Format() ) : MathNode( initialValue, format ) {}
74 
75  protected:
76  void process( Buffer *buffer ) override;
77 };
78 
80 class DivideNode : public MathNode {
81  public:
82  DivideNode( const Format &format = Format() ) : MathNode( 0, format ) {}
83  DivideNode( float initialValue, const Format &format = Format() ) : MathNode( initialValue, format ) {}
84 
85  protected:
86  void process( Buffer *buffer ) override;
87 };
88 
89 } } // namespace cinder::audio
float getValue() const
Returns the current value of the Param.
Definition: Param.h:109
void process(Buffer *buffer) override
Override to perform audio processing on buffer.
Definition: NodeMath.cpp:39
SubtractNode(float initialValue, const Format &format=Format())
Definition: NodeMath.h:63
AddNode(float initialValue, const Format &format=Format())
Definition: NodeMath.h:53
MathNode(float initialValue, const Format &format)
Definition: NodeMath.cpp:34
Base class for an arithmetic based Node.
Definition: NodeMath.h:33
Param mParam
Definition: NodeMath.h:46
DivideNode(const Format &format=Format())
Definition: NodeMath.h:82
void process(Buffer *buffer) override
Override to perform audio processing on buffer.
Definition: NodeMath.cpp:63
DivideNode(float initialValue, const Format &format=Format())
Definition: NodeMath.h:83
void setValue(float value)
Sets the current value to a constant value.
Definition: NodeMath.h:36
void setValue(float value)
Sets the value of the Param, blowing away any scheduled Event's or processing Node.
Definition: Param.cpp:73
GLuint buffer
Definition: GLee.h:2065
Node for performing a mulitplication operation on its input.
Definition: NodeMath.h:70
SubtractNode(const Format &format=Format())
Definition: NodeMath.h:62
Definition: Node.h:72
void process(Buffer *buffer) override
Override to perform audio processing on buffer.
Definition: NodeMath.cpp:75
MultiplyNode(float initialValue, const Format &format=Format())
Definition: NodeMath.h:73
Node for performing a division operation on its input.
Definition: NodeMath.h:80
Fundamental building block for creating an audio processing graph.
Definition: Node.h:59
GLsizei const GLfloat * value
Definition: GLee.h:2487
float getValue() const
Returns the current value.
Definition: NodeMath.h:38
MultiplyNode(const Format &format=Format())
Definition: NodeMath.h:72
GLenum GLsizei GLenum format
Definition: GLee.h:969
Allows an audio parameter to be controlled over time with sample accuracate curves.
Definition: Param.h:81
Node for performing an addition operation on its input.
Definition: NodeMath.h:50
AddNode(const Format &format=Format())
Definition: NodeMath.h:52
void process(Buffer *buffer) override
Override to perform audio processing on buffer.
Definition: NodeMath.cpp:51
Param * getParam()
Returns a pointer to the Param that can be used to animate the value.
Definition: NodeMath.h:41
Node for performing a subtration operation on its input.
Definition: NodeMath.h:60