diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/Modules/Output/Graphics/Scale/ScaleLog.h	Fri Oct 15 05:40:53 2010 +0000
@@ -0,0 +1,42 @@
+/*!
+ * \file
+ * \brief Logarithmic frequency scale for generating filter banks and their frequencies
+ *
+ * \author Willem van Engen <cnbh@willem.engen.nl>
+ * \date created 2006/09/28
+ * \version \$Id: ScaleLog.h 459 2007-11-08 11:50:04Z tom $
+ */
+/* (c) 2006, University of Cambridge, Medical Research Council
+ * http://www.pdn.cam.ac.uk/groups/cnbh/aimmanual
+ */
+#ifndef __MODULE_SCALE_LOG_H__
+#define __MODULE_SCALE_LOG_H__
+
+#include <math.h>
+
+#include "Modules/Scale/Scale.h"
+
+/*!
+ * \class ScaleLog "Modules/Scale/ScaleLog.h"
+ * \brief Logarithmic frequency scale for generating filter banks and their frequencies
+ *
+ * It is very advisable to use Scale::Create() to an instance of this scale.
+ */
+class ScaleLog : public Scale {
+public:
+	ScaleLog(unsigned int min, unsigned int max, float density)
+		: Scale(min, max, density) { m_iType = SCALE_LOG; m_sName="log"; };
+
+	/*! The log scale has a problem, because log(0)=inf, so all values below
+	 *  1e-5 are truncated to 1e-5. */
+	float FromLinear(float fFreq) {
+		if (fFreq<1e-5f) fFreq=1e-5f;
+		return log(fFreq);
+	};
+
+	float ToLinear(float fFreq) {
+		return exp(fFreq);
+	};
+};
+
+#endif /* __MODULE_SCALE_LOG_H__ */