comparison src/Modules/Output/Graphics/Scale/Scale.h @ 228:82e0dc3dfd16

- All \t to two spaces (style guide compliance)
author tomwalters
date Fri, 15 Oct 2010 05:46:53 +0000
parents 73c6d61440ad
children ddf35dd82d63
comparison
equal deleted inserted replaced
227:73c6d61440ad 228:82e0dc3dfd16
26 * FromLinear(). See existing scales like ScaleERB for example: 26 * FromLinear(). See existing scales like ScaleERB for example:
27 */ 27 */
28 class Scale; 28 class Scale;
29 class Scale { 29 class Scale {
30 public: 30 public:
31 //! \brief A list of possible scales 31 //! \brief A list of possible scales
32 enum ScaleType { 32 enum ScaleType {
33 SCALE_LINEAR, SCALE_ERB, SCALE_LOG, SCALE_LOGSCALED 33 SCALE_LINEAR, SCALE_ERB, SCALE_LOG, SCALE_LOGSCALED
34 }; 34 };
35 /*! \brief Create a new scale based on type 35 /*! \brief Create a new scale based on type
36 * \param iType Scale type to create 36 * \param iType Scale type to create
37 * \param min Bottom frequency 37 * \param min Bottom frequency
38 * \param max Top frequency 38 * \param max Top frequency
39 * \param density Density of distribution on the scale (scale-dependent) 39 * \param density Density of distribution on the scale (scale-dependent)
40 * \return Newly created scale, to be freed by the caller. 40 * \return Newly created scale, to be freed by the caller.
41 * 41 *
42 * This is on purpose no virtual function, always use it Scale::Create(). 42 * This is on purpose no virtual function, always use it Scale::Create().
43 * \todo Split into scaling and filterbank creation parts. 43 * \todo Split into scaling and filterbank creation parts.
44 * Maybe even a separate ScaleMaker that implements Create(). 44 * Maybe even a separate ScaleMaker that implements Create().
45 */ 45 */
46 static Scale *Create(ScaleType iType, unsigned int min, unsigned int max, float density); 46 static Scale *Create(ScaleType iType, unsigned int min, unsigned int max, float density);
47 47
48 /*! \overload 48 /*! \overload
49 * This function is for scaling-only Scales, you must not create a SignalBank 49 * This function is for scaling-only Scales, you must not create a SignalBank
50 * with the returned Scale. 50 * with the returned Scale.
51 */ 51 */
52 static Scale *Create(ScaleType iType); 52 static Scale *Create(ScaleType iType);
53 53
54 /*! \brief Create a new Scale 54 /*! \brief Create a new Scale
55 * \param min Bottom frequency 55 * \param min Bottom frequency
56 * \param max Top frequency 56 * \param max Top frequency
57 * \param density Density of distribution on the scale (scale-dependent) 57 * \param density Density of distribution on the scale (scale-dependent)
58 */ 58 */
59 Scale(unsigned int min, unsigned int max, float density) { 59 Scale(unsigned int min, unsigned int max, float density) {
60 m_iMin = min; 60 m_iMin = min;
61 m_iMax = max; 61 m_iMax = max;
62 m_fDensity = density; 62 m_fDensity = density;
63 m_sName = NULL; 63 m_sName = NULL;
64 }; 64 };
65 65
66 virtual ~Scale() { }; 66 virtual ~Scale() { };
67 67
68 /*! \brief Create an exact copy of this Scale 68 /*! \brief Create an exact copy of this Scale
69 * \return A newly created Scale, to be freed by the caller. 69 * \return A newly created Scale, to be freed by the caller.
70 */ 70 */
71 virtual Scale *Clone(); 71 virtual Scale *Clone();
72 72
73 //! \return this Signal's ScaleType 73 //! \return this Signal's ScaleType
74 ScaleType getType() { return m_iType; }; 74 ScaleType getType() { return m_iType; };
75 //! \return this Signal's name 75 //! \return this Signal's name
76 const char *getName() { return m_sName; }; 76 const char *getName() { return m_sName; };
77 77
78 /*! \brief Scale a frequency from linear to this scale 78 /*! \brief Scale a frequency from linear to this scale
79 * \param fFreq Frequency to scale 79 * \param fFreq Frequency to scale
80 * \return Scaled frequency 80 * \return Scaled frequency
81 */ 81 */
82 virtual float FromLinear(float fFreq) = 0; 82 virtual float FromLinear(float fFreq) = 0;
83 83
84 /*! \brief Scale a frequency from this scale to linear 84 /*! \brief Scale a frequency from this scale to linear
85 * \param fFreq Scaled frequency to scale back 85 * \param fFreq Scaled frequency to scale back
86 * \return Linear frequency 86 * \return Linear frequency
87 */ 87 */
88 virtual float ToLinear(float fFreq) = 0; 88 virtual float ToLinear(float fFreq) = 0;
89 89
90 /*! \brief Scale from [fMin..fMax] to [-0.5..0.5] 90 /*! \brief Scale from [fMin..fMax] to [-0.5..0.5]
91 * \param fVal Value to scale, must be within [fMin..fMax] 91 * \param fVal Value to scale, must be within [fMin..fMax]
92 * \return Float in [-0.5..0.5] according to this scale 92 * \return Float in [-0.5..0.5] according to this scale
93 * \sa FromLinearScaledExtrema 93 * \sa FromLinearScaledExtrema
94 * 94 *
95 * This is mainly for displaying any value on a scale and to make sure 95 * This is mainly for displaying any value on a scale and to make sure
96 * that it fits in on screen. Don't use this for any real maths! 96 * that it fits in on screen. Don't use this for any real maths!
97 * 97 *
98 * The default implementation assumes that the scale is monotonic, so the 98 * The default implementation assumes that the scale is monotonic, so the
99 * FromLinear(fMin) and FromLinear(fMax) are scale's output boundaries. 99 * FromLinear(fMin) and FromLinear(fMax) are scale's output boundaries.
100 * 100 *
101 * fMin and fMax are set by FromLinearScaledExtrema. Do not use this before 101 * fMin and fMax are set by FromLinearScaledExtrema. Do not use this before
102 * calling that. 102 * calling that.
103 */ 103 */
104 float FromLinearScaled(float fVal); 104 float FromLinearScaled(float fVal);
105 /*! \brief Update the FromLinearScaled min/max values 105 /*! \brief Update the FromLinearScaled min/max values
106 * \param fMin Minimum value to be input 106 * \param fMin Minimum value to be input
107 * \param fMax Maxmimum value to be input 107 * \param fMax Maxmimum value to be input
108 * \sa FromLinearScaled 108 * \sa FromLinearScaled
109 */ 109 */
110 void FromLinearScaledExtrema(float fMin, float fMax); 110 void FromLinearScaledExtrema(float fMin, float fMax);
111 /*! \overload 111 /*! \overload
112 * \brief Copy min/max values from another Scale 112 * \brief Copy min/max values from another Scale
113 * \param pScale Scale from which to copy min/max values, must not be NULL 113 * \param pScale Scale from which to copy min/max values, must not be NULL
114 */ 114 */
115 void FromLinearScaledExtrema(Scale *pScale); 115 void FromLinearScaledExtrema(Scale *pScale);
116 116
117 /*! \brief Create a new signal bank 117 /*! \brief Create a new signal bank
118 * \param iChannels Number of audio channels 118 * \param iChannels Number of audio channels
119 * \param iBufferlength Length of the buffer in frames 119 * \param iBufferlength Length of the buffer in frames
120 * \param iSamplerate Samplerate in Hz 120 * \param iSamplerate Samplerate in Hz
121 * Note that the caller must free the signal bank again. 121 * Note that the caller must free the signal bank again.
122 */ 122 */
123 virtual SignalBank* CreateSignalBank(unsigned int iChannels, unsigned int iBufferlength, unsigned int iSamplerate); 123 virtual SignalBank* CreateSignalBank(unsigned int iChannels, unsigned int iBufferlength, unsigned int iSamplerate);
124 124
125 /*! \overload 125 /*! \overload
126 * \brief Create a signal bank based on a Signal's parameters 126 * \brief Create a signal bank based on a Signal's parameters
127 * \param pSig Signal to get parameters from 127 * \param pSig Signal to get parameters from
128 * pSig is only used to look at parameters like samplerate, nothing is done 128 * pSig is only used to look at parameters like samplerate, nothing is done
129 * with its contents. 129 * with its contents.
130 * Note that the caller must free the signal bank again. 130 * Note that the caller must free the signal bank again.
131 */ 131 */
132 virtual SignalBank* CreateSignalBank(/*! \todo const*/ Signal* pSig); 132 virtual SignalBank* CreateSignalBank(/*! \todo const*/ Signal* pSig);
133 133
134 134
135 protected: 135 protected:
136 //! \brief Bottom frequency 136 //! \brief Bottom frequency
137 unsigned int m_iMin; 137 unsigned int m_iMin;
138 //! \brief Top frequency 138 //! \brief Top frequency
139 unsigned int m_iMax; 139 unsigned int m_iMax;
140 //! \brief Density of distribution on the scale (scale-dependent) 140 //! \brief Density of distribution on the scale (scale-dependent)
141 float m_fDensity; 141 float m_fDensity;
142 //! \brief The type of this scale, used by Clone(); set this in children. 142 //! \brief The type of this scale, used by Clone(); set this in children.
143 ScaleType m_iType; 143 ScaleType m_iType;
144 //! \brief The name of this scale; set this in children. 144 //! \brief The name of this scale; set this in children.
145 const char *m_sName; 145 const char *m_sName;
146 146
147 /*! \brief Minimum value for scaling as input 147 /*! \brief Minimum value for scaling as input
148 * \sa FromLinearScaled(), FromLinearScaledExtrema() */ 148 * \sa FromLinearScaled(), FromLinearScaledExtrema() */
149 float m_fMin; 149 float m_fMin;
150 /*! \brief Maximum value for scaling as input 150 /*! \brief Maximum value for scaling as input
151 * \sa FromLinearScaled(), FromLinearScaledExtrema() */ 151 * \sa FromLinearScaled(), FromLinearScaledExtrema() */
152 float m_fMax; 152 float m_fMax;
153 //! \brief Value used in FromLinearScaled 153 //! \brief Value used in FromLinearScaled
154 float m_fScaledCurHalfSum; 154 float m_fScaledCurHalfSum;
155 //! \brief Value used in FromLinearScaled 155 //! \brief Value used in FromLinearScaled
156 float m_fScaledCurDiff; 156 float m_fScaledCurDiff;
157 }; 157 };
158 158
159 #endif /* __MODULE_SCALE_H__ */ 159 #endif /* __MODULE_SCALE_H__ */