tomwalters@116: /*! tomwalters@116: * \file tomwalters@116: * \brief Logarithmic frequency scale for generating filter banks and their frequencies tomwalters@116: * tomwalters@116: * \author Willem van Engen tomwalters@116: * \date created 2006/09/28 tomwalters@116: * \version \$Id: ScaleLog.h 459 2007-11-08 11:50:04Z tom $ tomwalters@116: */ tomwalters@116: /* (c) 2006, University of Cambridge, Medical Research Council tomwalters@116: * http://www.pdn.cam.ac.uk/groups/cnbh/aimmanual tomwalters@116: */ tomwalters@116: #ifndef __MODULE_SCALE_LOG_H__ tomwalters@116: #define __MODULE_SCALE_LOG_H__ tomwalters@116: tomwalters@116: #include tomwalters@116: tom@230: #include "Modules/Output/Graphics/Scale/Scale.h" tom@230: tom@230: namespace aimc { tomwalters@116: tomwalters@116: /*! tomwalters@116: * \class ScaleLog "Modules/Scale/ScaleLog.h" tomwalters@116: * \brief Logarithmic frequency scale for generating filter banks and their frequencies tomwalters@116: * tomwalters@116: * It is very advisable to use Scale::Create() to an instance of this scale. tomwalters@116: */ tomwalters@116: class ScaleLog : public Scale { tomwalters@116: public: tomwalters@228: ScaleLog(unsigned int min, unsigned int max, float density) tomwalters@228: : Scale(min, max, density) { m_iType = SCALE_LOG; m_sName="log"; }; tomwalters@116: tomwalters@228: /*! The log scale has a problem, because log(0)=inf, so all values below tomwalters@228: * 1e-5 are truncated to 1e-5. */ tomwalters@228: float FromLinear(float fFreq) { tomwalters@228: if (fFreq<1e-5f) fFreq=1e-5f; tomwalters@228: return log(fFreq); tomwalters@228: }; tomwalters@116: tomwalters@228: float ToLinear(float fFreq) { tomwalters@228: return exp(fFreq); tomwalters@228: }; tomwalters@116: }; tom@230: } // namespace aimc tomwalters@116: #endif /* __MODULE_SCALE_LOG_H__ */