BinaryOp.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef CSL_BINARYOP_H
00013 #define CSL_BINARYOP_H
00014
00015 #include "CSL_Core.h"
00016
00017 namespace csl {
00018
00024
00025 class BinaryOp : public Effect {
00026
00027 public:
00028 BinaryOp(UnitGenerator & op1, UnitGenerator & op2);
00030 BinaryOp(UnitGenerator & op1, float op2);
00032 BinaryOp(float op1, UnitGenerator & op2);
00033 virtual ~BinaryOp();
00034
00036 void dump();
00037
00038
00039 protected:
00041 virtual void nextBuffer(Buffer & outputBuffer, unsigned outBufNum) throw(CException) = 0;
00043 inline bool isFixed();
00044 inline bool inputIsFixed();
00046 inline bool operandIsFixed();
00048 inline sample operandFixedValue(Buffer & outputBuffer);
00049
00050 };
00051
00053
00054 #define DECLARE_OPERAND_CONTROLS \
00055 Port * opPort = mInputs[CSL_OPERAND]; \
00056 SampleBuffer inValue; \
00057 sample opValue
00058
00061
00062 #define LOAD_OPERAND_CONTROLS \
00063 Controllable::pullInput(opPort, numFrames); \
00064 Effect::pullInput(numFrames); \
00065 inValue = mInputPtr; \
00066 opValue = opPort->nextValue()
00067
00069
00070 #define UPDATE_OPERAND_CONTROLS \
00071 opValue = opPort->nextValue() ; \
00072 inValue++
00073
00077
00078 class AddOp : public BinaryOp {
00079
00080 public:
00081 AddOp(UnitGenerator & op1, UnitGenerator & op2);
00083 AddOp(UnitGenerator & op1, float op2);
00085 AddOp(float op1, UnitGenerator & op2);
00086
00087
00088
00089 protected:
00090 void nextBuffer(Buffer & outputBuffer, unsigned outBufNum) throw (CException) ;
00091 };
00092
00096
00097 class MulOp : public BinaryOp {
00098
00099 public:
00100 MulOp(UnitGenerator & op1, UnitGenerator & op2);
00102 MulOp(UnitGenerator & op1, float op2);
00103
00104 MulOp(float op2, UnitGenerator & op1);
00106
00107
00108 protected:
00109 void nextBuffer(Buffer & outputBuffer, unsigned outBufNum) throw (CException) ;
00110
00111 };
00112
00113 }
00114
00115 #endif // CSL_BINARYOP_H
00116