annotate src/Modules/Output/Graphics/Scale/Scale.cc @ 263:07dc1f7047f5

Debug output for audio_example and added a write function for aimc_data
author hamel.phil
date Thu, 06 Jan 2011 20:11:41 +0000
parents 2aa72aa8a0d4
children
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@230 19 namespace aimc {
tom@230 20
tom@229 21 Scale *Scale::Create(ScaleType iType,
tom@229 22 unsigned int min,
tom@229 23 unsigned int max,
tom@229 24 float density) {
tomwalters@228 25 switch(iType) {
tomwalters@228 26 case SCALE_LINEAR:
tomwalters@228 27 return static_cast<Scale*>(new ScaleLinear(min, max, density));
tomwalters@228 28 case SCALE_ERB:
tomwalters@228 29 return static_cast<Scale*>(new ScaleERB(min, max, density));
tomwalters@228 30 case SCALE_LOG:
tomwalters@228 31 return static_cast<Scale*>(new ScaleLog(min, max, density));
tomwalters@228 32 case SCALE_LOGSCALED:
tomwalters@228 33 return static_cast<Scale*>(new ScaleLogScaled(min, max, density));
tomwalters@228 34 default:
tom@230 35 AIM_ASSERT(0);
tomwalters@228 36 break;
tomwalters@228 37 }
tomwalters@228 38 // Unreachable code
tom@230 39 AIM_ASSERT(0);
tomwalters@228 40 return NULL;
tomwalters@116 41 }
tomwalters@116 42
tom@229 43 Scale *Scale::Create(ScaleType iType) {
tomwalters@228 44 return Create(iType, 0, 0, 0);
tomwalters@116 45 }
tomwalters@116 46
tom@229 47 Scale *Scale::Clone() {
tomwalters@228 48 Scale *pScale = Create(m_iType, m_iMin, m_iMax, m_fDensity);
tom@229 49 AIM_ASSERT(pScale);
tomwalters@228 50 pScale->m_fScaledCurHalfSum = m_fScaledCurHalfSum;
tomwalters@228 51 pScale->m_fScaledCurDiff = m_fScaledCurDiff;
tomwalters@228 52 return pScale;
tomwalters@116 53 }
tomwalters@116 54
tom@229 55 float Scale::FromLinearScaled(float fVal) {
tomwalters@228 56 /*! This function returns
tomwalters@228 57 * ( FromLinear(fVal) - (fMinScaled+fMaxScaled)/2 ) / (fMaxScaled-fMinScaled)
tomwalters@228 58 */
tomwalters@228 59 float fValScaled = FromLinear(fVal);
tomwalters@228 60 return (fValScaled - m_fScaledCurHalfSum) / m_fScaledCurDiff;
tomwalters@227 61 }
tom@229 62
tom@229 63 void Scale::FromLinearScaledExtrema(float fMin, float fMax) {
tomwalters@228 64 float fMinScaled = FromLinear(fMin);
tomwalters@228 65 float fMaxScaled = FromLinear(fMax);
tomwalters@228 66 m_fScaledCurHalfSum = (fMinScaled+fMaxScaled)/2;
tomwalters@228 67 m_fScaledCurDiff = fMaxScaled-fMinScaled;
tomwalters@228 68 m_fMin = fMin;
tomwalters@228 69 m_fMax = fMax;
tomwalters@227 70 }
tom@229 71
tom@229 72 void Scale::FromLinearScaledExtrema(Scale *pScale) {
tom@230 73 AIM_ASSERT(pScale);
tomwalters@228 74 FromLinearScaledExtrema(pScale->m_fMin, pScale->m_fMax);
tomwalters@116 75 }
tom@230 76 } // namespace aimc