annotate src/Modules/Output/Graphics/Scale/Scale.cc @ 229:ddf35dd82d63

- A few changes to get graphics working. In progress.
author tom@acousticscale.org
date Sat, 16 Oct 2010 22:27:03 +0000
parents 82e0dc3dfd16
children 2aa72aa8a0d4
rev   line source
tomwalters@116 1 /*!
tomwalters@116 2 * \file
tomwalters@116 3 * \brief Frequency scale for generating filter banks and their frequencies
tomwalters@116 4 *
tomwalters@116 5 * \author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@116 6 * \date created 2006/09/28
tomwalters@116 7 * \version \$Id: Scale.cpp 459 2007-11-08 11:50:04Z tom $
tomwalters@116 8 */
tomwalters@116 9 /* (c) 2006, University of Cambridge, Medical Research Council
tomwalters@116 10 * http://www.pdn.cam.ac.uk/groups/cnbh/aimmanual
tomwalters@116 11 */
tom@229 12 #include "Support/Common.h"
tom@229 13 #include "Modules/Output/Graphics/Scale/Scale.h"
tom@229 14 #include "Modules/Output/Graphics/Scale/ScaleLinear.h"
tom@229 15 #include "Modules/Output/Graphics/Scale/ScaleERB.h"
tom@229 16 #include "Modules/Output/Graphics/Scale/ScaleLog.h"
tom@229 17 #include "Modules/Output/Graphics/Scale/ScaleLogScaled.h"
tomwalters@116 18
tom@229 19 Scale *Scale::Create(ScaleType iType,
tom@229 20 unsigned int min,
tom@229 21 unsigned int max,
tom@229 22 float density) {
tomwalters@228 23 switch(iType) {
tomwalters@228 24 case SCALE_LINEAR:
tomwalters@228 25 return static_cast<Scale*>(new ScaleLinear(min, max, density));
tomwalters@228 26 case SCALE_ERB:
tomwalters@228 27 return static_cast<Scale*>(new ScaleERB(min, max, density));
tomwalters@228 28 case SCALE_LOG:
tomwalters@228 29 return static_cast<Scale*>(new ScaleLog(min, max, density));
tomwalters@228 30 case SCALE_LOGSCALED:
tomwalters@228 31 return static_cast<Scale*>(new ScaleLogScaled(min, max, density));
tomwalters@228 32 default:
tomwalters@228 33 aimASSERT(0);
tomwalters@228 34 break;
tomwalters@228 35 }
tomwalters@228 36 // Unreachable code
tomwalters@228 37 aimASSERT(0);
tomwalters@228 38 return NULL;
tomwalters@116 39 }
tomwalters@116 40
tom@229 41 Scale *Scale::Create(ScaleType iType) {
tomwalters@228 42 return Create(iType, 0, 0, 0);
tomwalters@116 43 }
tomwalters@116 44
tom@229 45 Scale *Scale::Clone() {
tomwalters@228 46 Scale *pScale = Create(m_iType, m_iMin, m_iMax, m_fDensity);
tom@229 47 AIM_ASSERT(pScale);
tomwalters@228 48 pScale->m_fScaledCurHalfSum = m_fScaledCurHalfSum;
tomwalters@228 49 pScale->m_fScaledCurDiff = m_fScaledCurDiff;
tomwalters@228 50 return pScale;
tomwalters@116 51 }
tomwalters@116 52
tom@229 53 float Scale::FromLinearScaled(float fVal) {
tomwalters@228 54 /*! This function returns
tomwalters@228 55 * ( FromLinear(fVal) - (fMinScaled+fMaxScaled)/2 ) / (fMaxScaled-fMinScaled)
tomwalters@228 56 */
tomwalters@228 57 float fValScaled = FromLinear(fVal);
tomwalters@228 58 return (fValScaled - m_fScaledCurHalfSum) / m_fScaledCurDiff;
tomwalters@227 59 }
tom@229 60
tom@229 61 void Scale::FromLinearScaledExtrema(float fMin, float fMax) {
tomwalters@228 62 float fMinScaled = FromLinear(fMin);
tomwalters@228 63 float fMaxScaled = FromLinear(fMax);
tomwalters@228 64 m_fScaledCurHalfSum = (fMinScaled+fMaxScaled)/2;
tomwalters@228 65 m_fScaledCurDiff = fMaxScaled-fMinScaled;
tomwalters@228 66 m_fMin = fMin;
tomwalters@228 67 m_fMax = fMax;
tomwalters@227 68 }
tom@229 69
tom@229 70 void Scale::FromLinearScaledExtrema(Scale *pScale) {
tomwalters@228 71 aimASSERT(pScale);
tomwalters@228 72 FromLinearScaledExtrema(pScale->m_fMin, pScale->m_fMax);
tomwalters@116 73 }