Mercurial > hg > svgui
diff layer/SpectrogramLayer.h @ 905:b66fb15de477 cxx11
Working through the float/double and int/sv_frame_t fixes
author | Chris Cannam |
---|---|
date | Mon, 09 Mar 2015 14:35:21 +0000 |
parents | 4c8ca536b54f |
children | 12ab113ca2b1 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.h Mon Mar 09 12:02:10 2015 +0000 +++ b/layer/SpectrogramLayer.h Mon Mar 09 14:35:21 2015 +0000 @@ -69,7 +69,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -210,20 +210,20 @@ return ColourHasMeaningfulValue; } - float getYForFrequency(const View *v, float frequency) const; - float getFrequencyForY(const View *v, int y) const; + double getYForFrequency(const View *v, double frequency) const; + double getFrequencyForY(const View *v, int y) const; virtual int getCompletion(View *v) const; virtual QString getError(View *v) const; - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; + virtual bool getDisplayExtents(double &min, double &max) const; - virtual bool setDisplayExtents(float min, float max); + virtual bool setDisplayExtents(double min, double max); - virtual bool getYScaleValue(const View *, int, float &, QString &) const; + virtual bool getYScaleValue(const View *, int, double &, QString &) const; virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const; @@ -340,8 +340,8 @@ void illuminateLocalFeatures(View *v, QPainter &painter) const; - float getEffectiveMinFrequency() const; - float getEffectiveMaxFrequency() const; + double getEffectiveMinFrequency() const; + double getEffectiveMaxFrequency() const; struct LayerRange { int startFrame; @@ -356,17 +356,17 @@ // position, if the spectrogram has oversampling smoothing. Use // getSmoothedYBinRange to obtain that. - bool getXBinRange(View *v, int x, float &windowMin, float &windowMax) const; - bool getYBinRange(View *v, int y, float &freqBinMin, float &freqBinMax) const; - bool getSmoothedYBinRange(View *v, int y, float &freqBinMin, float &freqBinMax) const; + bool getXBinRange(View *v, int x, double &windowMin, double &windowMax) const; + bool getYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const; + bool getSmoothedYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const; - bool getYBinSourceRange(View *v, int y, float &freqMin, float &freqMax) const; + bool getYBinSourceRange(View *v, int y, double &freqMin, double &freqMax) const; bool getAdjustedYBinSourceRange(View *v, int x, int y, - float &freqMin, float &freqMax, - float &adjFreqMin, float &adjFreqMax) const; + double &freqMin, double &freqMax, + double &adjFreqMin, double &adjFreqMax) const; bool getXBinSourceRange(View *v, int x, RealTime &timeMin, RealTime &timeMax) const; - bool getXYBinSourceRange(View *v, int x, int y, float &min, float &max, - float &phaseMin, float &phaseMax) const; + bool getXYBinSourceRange(View *v, int x, int y, double &min, double &max, + double &phaseMin, double &phaseMax) const; int getWindowIncrement() const { if (m_windowHopLevel == 0) return m_windowSize; @@ -393,20 +393,19 @@ bool operator==(const MagnitudeRange &r) { return r.m_min == m_min && r.m_max == m_max; } - bool isSet() const { return (m_min != 0 || m_max != 0); } + bool isSet() const { return (m_min != 0.f || m_max != 0.f); } void set(float min, float max) { - m_min = convert(min); - m_max = convert(max); + m_min = min; + m_max = max; if (m_max < m_min) m_max = m_min; } bool sample(float f) { - unsigned int ui = convert(f); bool changed = false; if (isSet()) { - if (ui < m_min) { m_min = ui; changed = true; } - if (ui > m_max) { m_max = ui; changed = true; } + if (f < m_min) { m_min = f; changed = true; } + if (f > m_max) { m_max = f; changed = true; } } else { - m_max = m_min = ui; + m_max = m_min = f; changed = true; } return changed; @@ -423,16 +422,11 @@ } return changed; } - float getMin() const { return float(m_min) / UINT_MAX; } - float getMax() const { return float(m_max) / UINT_MAX; } + float getMin() const { return m_min; } + float getMax() const { return m_max; } private: - unsigned int m_min; - unsigned int m_max; - unsigned int convert(float f) { - if (f < 0.f) f = 0.f; - if (f > 1.f) f = 1.f; - return (unsigned int)(f * UINT_MAX); - } + float m_min; + float m_max; }; typedef std::map<const View *, MagnitudeRange> ViewMagMap; @@ -441,7 +435,7 @@ void invalidateMagnitudes(); bool updateViewMagnitudes(View *v) const; bool paintDrawBuffer(View *v, int w, int h, - int *binforx, float *binfory, + int *binforx, double *binfory, bool usePeaksCache, MagnitudeRange &overallMag, bool &overallMagChanged) const; @@ -449,8 +443,8 @@ int *binforx, int minbin, int maxbin, - float displayMinFreq, - float displayMaxFreq, + double displayMinFreq, + double displayMaxFreq, bool logarithmic, MagnitudeRange &overallMag, bool &overallMagChanged) const;