Mercurial > hg > aimc
comparison 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 |
comparison
equal
deleted
inserted
replaced
396:06a26f5cdad7 | 397:7a573750b186 |
---|---|
1 /*! | |
2 * \file | |
3 * \brief Logarithmic frequency scale for generating filter banks and their frequencies | |
4 * | |
5 * \author Willem van Engen <cnbh@willem.engen.nl> | |
6 * \date created 2006/09/28 | |
7 * \version \$Id: ScaleLog.h 459 2007-11-08 11:50:04Z tom $ | |
8 */ | |
9 /* (c) 2006, University of Cambridge, Medical Research Council | |
10 * http://www.pdn.cam.ac.uk/groups/cnbh/aimmanual | |
11 */ | |
12 #ifndef __MODULE_SCALE_LOG_H__ | |
13 #define __MODULE_SCALE_LOG_H__ | |
14 | |
15 #include <math.h> | |
16 | |
17 #include "Modules/Scale/Scale.h" | |
18 | |
19 /*! | |
20 * \class ScaleLog "Modules/Scale/ScaleLog.h" | |
21 * \brief Logarithmic frequency scale for generating filter banks and their frequencies | |
22 * | |
23 * It is very advisable to use Scale::Create() to an instance of this scale. | |
24 */ | |
25 class ScaleLog : public Scale { | |
26 public: | |
27 ScaleLog(unsigned int min, unsigned int max, float density) | |
28 : Scale(min, max, density) { m_iType = SCALE_LOG; m_sName="log"; }; | |
29 | |
30 /*! The log scale has a problem, because log(0)=inf, so all values below | |
31 * 1e-5 are truncated to 1e-5. */ | |
32 float FromLinear(float fFreq) { | |
33 if (fFreq<1e-5f) fFreq=1e-5f; | |
34 return log(fFreq); | |
35 }; | |
36 | |
37 float ToLinear(float fFreq) { | |
38 return exp(fFreq); | |
39 }; | |
40 }; | |
41 | |
42 #endif /* __MODULE_SCALE_LOG_H__ */ |