00001 // Linear.h 00002 // 00003 // Setter class that implements linear transform of its input value 00004 /// \author Mike McCauley (mikem@open.com.au) 00005 /// 00006 // Copyright (C) 2010 Mike McCauley 00007 // $Id: Linear.h,v 1.2 2010/06/28 00:56:10 mikem Exp $ 00008 00009 #ifndef Linear_h 00010 #define Linear_h 00011 00012 #include "Setter.h" 00013 00014 ///////////////////////////////////////////////////////////////////// 00015 /// \class Linear Linear.h <Linear.h> 00016 /// \brief Setter class that implements linear transform of its input value 00017 /// 00018 /// Linear implements a y = mx + x linear transform of the input value. 00019 /// The resulting output value is sent to the next Setter (the target) in the chain. 00020 /// 00021 class Linear : public Setter 00022 { 00023 public: 00024 /// Constructor. 00025 /// Output will be calculated according to out = (in * gain) + offset 00026 Linear(float gain, int offset); 00027 00028 /// Input the value to be transformed 00029 /// \param[in] value The input value 00030 virtual void input(int value); 00031 00032 protected: 00033 00034 private: 00035 00036 /// Offset added to the output value 00037 int _offset; 00038 00039 /// Gain multiplied by the input value 00040 float _gain; 00041 }; 00042 00043 #endif