annotate trunk/src/Modules/Output/Graphics/Scale/ScaleLog.h @ 397:7a573750b186

- First add of a lot of graphics code from the old version. Not working yet, not even compiling yet.
author tomwalters
date Fri, 15 Oct 2010 05:40:53 +0000
parents
children 3ee03a6b95a0
rev   line source
tomwalters@397 1 /*!
tomwalters@397 2 * \file
tomwalters@397 3 * \brief Logarithmic frequency scale for generating filter banks and their frequencies
tomwalters@397 4 *
tomwalters@397 5 * \author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@397 6 * \date created 2006/09/28
tomwalters@397 7 * \version \$Id: ScaleLog.h 459 2007-11-08 11:50:04Z tom $
tomwalters@397 8 */
tomwalters@397 9 /* (c) 2006, University of Cambridge, Medical Research Council
tomwalters@397 10 * http://www.pdn.cam.ac.uk/groups/cnbh/aimmanual
tomwalters@397 11 */
tomwalters@397 12 #ifndef __MODULE_SCALE_LOG_H__
tomwalters@397 13 #define __MODULE_SCALE_LOG_H__
tomwalters@397 14
tomwalters@397 15 #include <math.h>
tomwalters@397 16
tomwalters@397 17 #include "Modules/Scale/Scale.h"
tomwalters@397 18
tomwalters@397 19 /*!
tomwalters@397 20 * \class ScaleLog "Modules/Scale/ScaleLog.h"
tomwalters@397 21 * \brief Logarithmic frequency scale for generating filter banks and their frequencies
tomwalters@397 22 *
tomwalters@397 23 * It is very advisable to use Scale::Create() to an instance of this scale.
tomwalters@397 24 */
tomwalters@397 25 class ScaleLog : public Scale {
tomwalters@397 26 public:
tomwalters@397 27 ScaleLog(unsigned int min, unsigned int max, float density)
tomwalters@397 28 : Scale(min, max, density) { m_iType = SCALE_LOG; m_sName="log"; };
tomwalters@397 29
tomwalters@397 30 /*! The log scale has a problem, because log(0)=inf, so all values below
tomwalters@397 31 * 1e-5 are truncated to 1e-5. */
tomwalters@397 32 float FromLinear(float fFreq) {
tomwalters@397 33 if (fFreq<1e-5f) fFreq=1e-5f;
tomwalters@397 34 return log(fFreq);
tomwalters@397 35 };
tomwalters@397 36
tomwalters@397 37 float ToLinear(float fFreq) {
tomwalters@397 38 return exp(fFreq);
tomwalters@397 39 };
tomwalters@397 40 };
tomwalters@397 41
tomwalters@397 42 #endif /* __MODULE_SCALE_LOG_H__ */