Mercurial > hg > svgui
changeset 904:e0f08e108064 cxx11
Move to using double rather than float for floating-point calculations (float only for storage); more build fixes
author | Chris Cannam |
---|---|
date | Mon, 09 Mar 2015 12:02:10 +0000 |
parents | 1757933ce5a7 |
children | b66fb15de477 |
files | layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/ColourDatabase.cpp layer/ColourMapper.cpp layer/FlexiNoteLayer.cpp layer/FlexiNoteLayer.h layer/Layer.cpp layer/Layer.h layer/LinearNumericalScale.cpp layer/LinearNumericalScale.h layer/LogNumericalScale.cpp layer/LogNumericalScale.h layer/PianoScale.cpp layer/PianoScale.h layer/VerticalScaleLayer.h view/View.cpp view/View.h widgets/ItemEditDialog.cpp widgets/ItemEditDialog.h |
diffstat | 19 files changed, 282 insertions(+), 284 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/Colour3DPlotLayer.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -543,13 +543,13 @@ } bool -Colour3DPlotLayer::getValueExtents(float &min, float &max, +Colour3DPlotLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; min = 0; - max = float(m_model->getHeight()); + max = double(m_model->getHeight()); logarithmic = false; unit = ""; @@ -558,14 +558,14 @@ } bool -Colour3DPlotLayer::getDisplayExtents(float &min, float &max) const +Colour3DPlotLayer::getDisplayExtents(double &min, double &max) const { if (!m_model) return false; - float hmax = float(m_model->getHeight()); + double hmax = double(m_model->getHeight()); - min = float(m_miny); - max = float(m_maxy); + min = m_miny; + max = m_maxy; if (max <= min) { min = 0; max = hmax; @@ -577,12 +577,12 @@ } bool -Colour3DPlotLayer::setDisplayExtents(float min, float max) +Colour3DPlotLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; - m_miny = int(lrintf(min)); - m_maxy = int(lrintf(max)); + m_miny = int(lrint(min)); + m_maxy = int(lrint(max)); emit layerParametersChanged(); return true; @@ -590,7 +590,7 @@ bool Colour3DPlotLayer::getYScaleValue(const View *, int, - float &, QString &) const + double &, QString &) const { return false;//!!! } @@ -610,9 +610,9 @@ { if (!m_model) return 0; - float min, max; + double min, max; getDisplayExtents(min, max); - return m_model->getHeight() - int(lrintf(max - min)); + return m_model->getHeight() - int(lrint(max - min)); } void @@ -624,8 +624,8 @@ int dist = m_model->getHeight() - step; if (dist < 1) dist = 1; - float centre = float(m_miny) + (float(m_maxy) - float(m_miny)) / 2.f; - m_miny = int(lrintf(centre - float(dist)/2)); + double centre = m_miny + (m_maxy - m_miny) / 2.0; + m_miny = int(lrint(centre - dist/2.0)); if (m_miny < 0) m_miny = 0; m_maxy = m_miny + dist; if (m_maxy > m_model->getHeight()) m_maxy = m_model->getHeight(); @@ -644,18 +644,18 @@ 0, m_model->getHeight(), ""); } -float -Colour3DPlotLayer::getYForBin(View *v, float bin) const +double +Colour3DPlotLayer::getYForBin(View *v, double bin) const { - float y = bin; + double y = bin; if (!m_model) return y; - float mn = 0, mx = float(m_model->getHeight()); + double mn = 0, mx = m_model->getHeight(); getDisplayExtents(mn, mx); - float h = float(v->height()); + double h = v->height(); if (m_binScale == LinearBinScale) { y = h - (((bin - mn) * h) / (mx - mn)); } else { - float logmin = mn + 1, logmax = mx + 1; + double logmin = mn + 1, logmax = mx + 1; LogRange::mapRange(logmin, logmax); y = h - (((LogRange::map(bin + 1) - logmin) * h) / (logmax - logmin)); } @@ -665,21 +665,21 @@ int Colour3DPlotLayer::getIYForBin(View *v, int bin) const { - return int(roundf(getYForBin(v, float(bin)))); + return int(round(getYForBin(v, bin))); } -float -Colour3DPlotLayer::getBinForY(View *v, float y) const +double +Colour3DPlotLayer::getBinForY(View *v, double y) const { - float bin = y; + double bin = y; if (!m_model) return bin; - float mn = 0, mx = float(m_model->getHeight()); + double mn = 0, mx = m_model->getHeight(); getDisplayExtents(mn, mx); - float h = float(v->height()); + double h = v->height(); if (m_binScale == LinearBinScale) { bin = mn + ((h - y) * (mx - mn)) / h; } else { - float logmin = mn + 1, logmax = mx + 1; + double logmin = mn + 1, logmax = mx + 1; LogRange::mapRange(logmin, logmax); bin = LogRange::unmap(logmin + ((h - y) * (logmax - logmin)) / h) - 1; } @@ -689,7 +689,7 @@ int Colour3DPlotLayer::getIBinForY(View *v, int y) const { - return int(floorf(getBinForY(v, float(y)))); + return int(floor(getBinForY(v, y))); } QString @@ -724,7 +724,7 @@ if (symin < 0) symin = 0; if (symax > sh) symax = sh; - // float binHeight = float(v->height()) / (symax - symin); + // double binHeight = double(v->height()) / (symax - symin); // int sy = int((v->height() - y) / binHeight) + symin; int sy = getIBinForY(v, y); @@ -795,11 +795,11 @@ int ch = h - 20; if (ch > 20 && m_cache) { - float min = m_model->getMinimumLevel(); - float max = m_model->getMaximumLevel(); + double min = m_model->getMinimumLevel(); + double max = m_model->getMaximumLevel(); - float mmin = min; - float mmax = max; + double mmin = min; + double mmax = max; if (m_colourScale == LogScale) { LogRange::mapRange(mmin, mmax); @@ -808,12 +808,12 @@ mmax = 1.f; } else if (m_colourScale == AbsoluteScale) { if (mmin < 0) { - if (fabsf(mmin) > fabsf(mmax)) mmax = fabsf(mmin); - else mmax = fabsf(mmax); + if (fabs(mmin) > fabs(mmax)) mmax = fabs(mmin); + else mmax = fabs(mmax); mmin = 0; } else { - mmin = fabsf(mmin); - mmax = fabsf(mmax); + mmin = fabs(mmin); + mmax = fabs(mmax); } } @@ -824,7 +824,7 @@ paint.drawRect(4, 10, cw - 8, ch+1); for (int y = 0; y < ch; ++y) { - float value = ((max - min) * (float(ch-y) - 1.f)) / float(ch) + min; + double value = ((max - min) * (double(ch-y) - 1.0)) / double(ch) + min; if (m_colourScale == LogScale) { value = LogRange::map(value); } @@ -934,8 +934,8 @@ while (values.size() < m_model->getHeight()) values.push_back(0.f); if (!m_normalizeColumns && !m_normalizeHybrid) return values; - float colMax = 0.f, colMin = 0.f; - float min = 0.f, max = 0.f; + double colMax = 0.f, colMin = 0.f; + double min = 0.f, max = 0.f; min = m_model->getMinimumLevel(); max = m_model->getMaximumLevel(); @@ -948,17 +948,17 @@ for (int y = 0; y < values.size(); ++y) { - float value = values.at(y); - float norm = (value - colMin) / (colMax - colMin); - float newvalue = min + (max - min) * norm; + double value = values.at(y); + double norm = (value - colMin) / (colMax - colMin); + double newvalue = min + (max - min) * norm; - if (value != newvalue) values[y] = newvalue; + if (value != newvalue) values[y] = float(newvalue); } if (m_normalizeHybrid && (colMax > 0.0)) { - float logmax = log10f(colMax); + double logmax = log10(colMax); for (int y = 0; y < values.size(); ++y) { - values[y] *= logmax; + values[y] = float(values[y] * logmax); } } @@ -1085,8 +1085,8 @@ DenseThreeDimensionalModel::Column values; - float min = m_model->getMinimumLevel(); - float max = m_model->getMaximumLevel(); + double min = m_model->getMinimumLevel(); + double max = m_model->getMaximumLevel(); if (m_colourScale == LogScale) { LogRange::mapRange(min, max); @@ -1095,12 +1095,12 @@ max = 1.f; } else if (m_colourScale == AbsoluteScale) { if (min < 0) { - if (fabsf(min) > fabsf(max)) max = fabsf(min); - else max = fabsf(max); + if (fabs(min) > fabs(max)) max = fabs(min); + else max = fabs(max); min = 0; } else { - min = fabsf(min); - max = fabsf(max); + min = fabs(min); + max = fabs(max); } } @@ -1118,7 +1118,7 @@ } } - float visibleMax = 0.f, visibleMin = 0.f; + double visibleMax = 0.f, visibleMin = 0.f; if (normalizeVisible) { @@ -1126,7 +1126,7 @@ values = getColumn(c); - float colMax = 0.f, colMin = 0.f; + double colMax = 0.f, colMin = 0.f; for (int y = 0; y < cacheHeight; ++y) { if (y >= values.size()) break; @@ -1144,12 +1144,12 @@ if (visibleMin > visibleMax) std::swap(visibleMin, visibleMax); } else if (m_colourScale == AbsoluteScale) { if (visibleMin < 0) { - if (fabsf(visibleMin) > fabsf(visibleMax)) visibleMax = fabsf(visibleMin); - else visibleMax = fabsf(visibleMax); + if (fabs(visibleMin) > fabs(visibleMax)) visibleMax = fabs(visibleMin); + else visibleMax = fabs(visibleMax); visibleMin = 0; } else { - visibleMin = fabsf(visibleMin); - visibleMax = fabsf(visibleMax); + visibleMin = fabs(visibleMin); + visibleMax = fabs(visibleMax); } } } @@ -1178,7 +1178,7 @@ for (int y = 0; y < cacheHeight; ++y) { - float value = min; + double value = min; if (y < values.size()) { value = values.at(y); } @@ -1188,11 +1188,11 @@ if (m_colourScale == LogScale) { value = LogRange::map(value); } else if (m_colourScale == AbsoluteScale) { - value = fabsf(value); + value = fabs(value); } if (normalizeVisible) { - float norm = (value - visibleMin) / (visibleMax - visibleMin); + double norm = (value - visibleMin) / (visibleMax - visibleMin); value = min + (max - min) * norm; } @@ -1410,7 +1410,7 @@ if (showLabel) { if (sx >= 0 && sx < m_cache->width() && sy >= 0 && sy < m_cache->height()) { - float value = m_model->getValueAt(sx, sy); + double value = m_model->getValueAt(sx, sy); snprintf(labelbuf, buflen, "%06f", value); QString text(labelbuf); paint.setPen(v->getBackground()); @@ -1509,7 +1509,7 @@ sxa[x*2 + 1] = sx1; } - float logmin = float(symin+1), logmax = float(symax+1); + double logmin = symin+1, logmax = symax+1; LogRange::mapRange(logmin, logmax); #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT @@ -1520,7 +1520,7 @@ for (int y = 0; y < h; ++y) { - double sy = getBinForY(v, float(y)) - 0.5; + double sy = getBinForY(v, y) - 0.5; int syi = int(sy + epsilon); if (syi < 0 || syi >= source->height()) continue; @@ -1590,14 +1590,14 @@ } } else { - float sy0 = getBinForY(v, 0); + double sy0 = getBinForY(v, 0); int psy0i = -1, psy1i = -1; for (int y = 0; y < h; ++y) { - float sy1 = sy0; - sy0 = getBinForY(v, float(y + 1)); + double sy1 = sy0; + sy0 = getBinForY(v, double(y + 1)); int sy0i = int(sy0 + epsilon); int sy1i = int(sy1); @@ -1655,7 +1655,7 @@ } bool -Colour3DPlotLayer::snapToFeatureFrame(View *v, int &frame, +Colour3DPlotLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -1664,8 +1664,8 @@ } resolution = m_model->getResolution(); - int left = (frame / resolution) * resolution; - int right = left + resolution; + sv_frame_t left = (frame / resolution) * resolution; + sv_frame_t right = left + resolution; switch (snap) { case SnapLeft: frame = left; break;
--- a/layer/Colour3DPlotLayer.h Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/Colour3DPlotLayer.h Mon Mar 09 12:02:10 2015 +0000 @@ -56,7 +56,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; @@ -145,14 +145,14 @@ void setSmooth(bool i); bool getSmooth() 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 setDisplayExtents(float min, float max); + virtual bool getDisplayExtents(double &min, double &max) const; + virtual bool setDisplayExtents(double min, double max); virtual bool getYScaleValue(const View *, int /* y */, - float &/* value */, QString &/* unit */) const; + double &/* value */, QString &/* unit */) const; virtual int getVerticalZoomSteps(int &defaultStep) const; virtual int getCurrentVerticalZoomStep() const; @@ -202,7 +202,7 @@ * and the vertical scale is the usual way up). Bin number may be * fractional, to obtain a position part-way through a bin. */ - float getYForBin(View *, float bin) const; + double getYForBin(View *, double bin) const; /** * As getYForBin, but rounding to integer values. @@ -215,7 +215,7 @@ * at which the bins "start" (i.e. the bottom of the visible bin, * if the vertical scale is the usual way up). */ - float getBinForY(View *, float y) const; + double getBinForY(View *, double y) const; /** * As getBinForY, but rounding to integer values.
--- a/layer/ColourDatabase.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/ColourDatabase.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -34,29 +34,28 @@ int ColourDatabase::getColourCount() const { - return m_colours.size(); + return int(m_colours.size()); } QString ColourDatabase::getColourName(int c) const { - if (c < 0 || size_t(c) >= m_colours.size()) return ""; + if (!in_range_for(m_colours, c)) return ""; return m_colours[c].name; } QColor ColourDatabase::getColour(int c) const { - if (c < 0 || size_t(c) >= m_colours.size()) return Qt::black; + if (!in_range_for(m_colours, c)) return Qt::black; return m_colours[c].colour; } QColor ColourDatabase::getColour(QString name) const { - for (ColourList::const_iterator i = m_colours.begin(); - i != m_colours.end(); ++i) { - if (i->name == name) return i->colour; + for (auto &c: m_colours) { + if (c.name == name) return c.colour; } return Qt::black; @@ -66,9 +65,8 @@ ColourDatabase::getColourIndex(QString name) const { int index = 0; - for (ColourList::const_iterator i = m_colours.begin(); - i != m_colours.end(); ++i) { - if (i->name == name) return index; + for (auto &c: m_colours) { + if (c.name == name) return index; ++index; } @@ -76,12 +74,11 @@ } int -ColourDatabase::getColourIndex(QColor c) const +ColourDatabase::getColourIndex(QColor col) const { int index = 0; - for (ColourList::const_iterator i = m_colours.begin(); - i != m_colours.end(); ++i) { - if (i->colour == c) return index; + for (auto &c: m_colours) { + if (c.colour == col) return index; ++index; } @@ -91,14 +88,14 @@ bool ColourDatabase::useDarkBackground(int c) const { - if (c < 0 || size_t(c) >= m_colours.size()) return false; + if (!in_range_for(m_colours, c)) return false; return m_colours[c].darkbg; } void ColourDatabase::setUseDarkBackground(int c, bool dark) { - if (c < 0 || size_t(c) >= m_colours.size()) return; + if (!in_range_for(m_colours, c)) return; if (m_colours[c].darkbg != dark) { m_colours[c].darkbg = dark; emit colourDatabaseChanged(); @@ -109,6 +106,7 @@ ColourDatabase::addColour(QColor c, QString name) { int index = 0; + for (ColourList::iterator i = m_colours.begin(); i != m_colours.end(); ++i) { if (i->name == name) { @@ -147,7 +145,7 @@ { colourName = ""; colourSpec = ""; - if (index < 0 || size_t(index) >= m_colours.size()) return; + if (!in_range_for(m_colours, index)) return; colourName = getColourName(index); QColor c = getColour(index);
--- a/layer/ColourMapper.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/ColourMapper.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -120,7 +120,7 @@ v = norm * 2.0; if (v > 1.0) { v = 1.0; - s = 1.0 - (sqrtf(norm) - 0.707) * 3.413; + s = 1.0 - (sqrt(norm) - 0.707) * 3.413; if (s < 0.0) s = 0.0; if (s > 1.0) s = 1.0; } @@ -188,7 +188,7 @@ if (norm <= 1.0 / 256.0) { norm = 0.0; } else { - norm = 0.1f + (powf(((norm - 0.5) * 2.0), 3.0) + 1.0) / 2.081; + norm = 0.1f + (pow(((norm - 0.5) * 2.0), 3.0) + 1.0) / 2.081; } // now as for Sunset r = (norm - 0.24) * 2.38;
--- a/layer/FlexiNoteLayer.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/FlexiNoteLayer.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -222,7 +222,7 @@ } bool -FlexiNoteLayer::getValueExtents(float &min, float &max, +FlexiNoteLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; @@ -231,8 +231,8 @@ if (shouldConvertMIDIToHz()) { unit = "Hz"; - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } else unit = getScaleUnits(); if (m_verticalScale == MIDIRangeScale || @@ -242,7 +242,7 @@ } bool -FlexiNoteLayer::getDisplayExtents(float &min, float &max) const +FlexiNoteLayer::getDisplayExtents(double &min, double &max) const { if (!m_model || shouldAutoAlign()) { // std::cerr << "No model or shouldAutoAlign()" << std::endl; @@ -264,8 +264,8 @@ } if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } #ifdef DEBUG_NOTE_LAYER @@ -276,7 +276,7 @@ } bool -FlexiNoteLayer::setDisplayExtents(float min, float max) +FlexiNoteLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; @@ -284,7 +284,7 @@ if (min == 0.f) { max = 1.f; } else { - max = min * 1.0001; + max = min * 1.0001f; } } @@ -318,7 +318,7 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return 0; - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); int nr = mapper->getPositionForValue(dmax - dmin); @@ -339,29 +339,29 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); - float newdist = mapper->getValueForPosition(100 - step); + double newdist = mapper->getValueForPosition(100 - step); - float newmin, newmax; + double newmin, newmax; if (logarithmic) { // see SpectrogramLayer::setVerticalZoomStep - newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; + newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2; newmin = newmax - newdist; // cerr << "newmin = " << newmin << ", newmax = " << newmax << endl; } else { - float dmid = (dmax + dmin) / 2; + double dmid = (dmax + dmin) / 2; newmin = dmid - newdist / 2; newmax = dmid + newdist / 2; } @@ -388,7 +388,7 @@ RangeMapper *mapper; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); @@ -409,7 +409,7 @@ { if (!m_model) return FlexiNoteModel::PointList(); - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); @@ -452,7 +452,7 @@ { if (!m_model) return false; - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return false; @@ -481,7 +481,7 @@ // GF: find the note that is closest to the cursor if (!m_model) return false; - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return false; @@ -552,9 +552,9 @@ if (shouldConvertMIDIToHz()) { - int mnote = lrintf(note.value); - int cents = lrintf((note.value - mnote) * 100); - float freq = Pitch::getFrequencyForPitch(mnote, cents); + int mnote = int(lrint(note.value)); + int cents = int(lrint((note.value - double(mnote)) * 100)); + double freq = Pitch::getFrequencyForPitch(mnote, cents); pitchText = tr("%1 (%2, %3 Hz)") .arg(Pitch::getPitchLabel(mnote, cents)) .arg(mnote) @@ -593,7 +593,7 @@ } bool -FlexiNoteLayer::snapToFeatureFrame(View *v, int &frame, +FlexiNoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -613,7 +613,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (FlexiNoteModel::PointList::const_iterator i = points.begin(); @@ -673,7 +673,7 @@ } void -FlexiNoteLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const +FlexiNoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -691,8 +691,8 @@ max = m_model->getValueMaximum(); if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } #ifdef DEBUG_NOTE_LAYER @@ -716,8 +716,8 @@ min = Pitch::getFrequencyForPitch(0); max = Pitch::getFrequencyForPitch(70); } else if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { @@ -730,9 +730,9 @@ } int -FlexiNoteLayer::getYForValue(View *v, float val) const +FlexiNoteLayer::getYForValue(View *v, double val) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); @@ -743,8 +743,8 @@ #endif if (shouldConvertMIDIToHz()) { - val = Pitch::getFrequencyForPitch(lrintf(val), - lrintf((val - lrintf(val)) * 100)); + val = Pitch::getFrequencyForPitch(int(lrint(val)), + int(lrint((val - floor(val)) * 100.0))); #ifdef DEBUG_NOTE_LAYER cerr << "shouldConvertMIDIToHz true, val now = " << val << endl; #endif @@ -764,19 +764,19 @@ return y; } -float +double FlexiNoteLayer::getValueForY(View *v, int y) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); getScaleExtents(v, min, max, logarithmic); - float val = min + (float(h - y) * float(max - min)) / h; + double val = min + (double(h - y) * double(max - min)) / h; if (logarithmic) { - val = powf(10.f, val); + val = pow(10.f, val); } if (shouldConvertMIDIToHz()) { @@ -798,13 +798,13 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; // Profiler profiler("FlexiNoteLayer::paint", true); int x1 = rect.right(); - int frame1 = v->getFrameForX(x1); + sv_frame_t frame1 = v->getFrameForX(x1); FlexiNoteModel::PointList points(m_model->getPoints(0, frame1)); if (points.empty()) return; @@ -817,8 +817,8 @@ // SVDEBUG << "FlexiNoteLayer::paint: resolution is " // << m_model->getResolution() << " frames" << endl; - float min = m_model->getValueMinimum(); - float max = m_model->getValueMaximum(); + double min = m_model->getValueMinimum(); + double max = m_model->getValueMaximum(); if (max == min) max = min + 1.0; QPoint localPos; @@ -923,7 +923,7 @@ if (!m_model || m_model->getPoints().empty()) return; QString unit; - float min, max; + double min, max; bool logarithmic; int w = getVerticalScaleWidth(v, false, paint); @@ -962,13 +962,13 @@ if (!m_model) return; - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); - m_editingPoint = FlexiNoteModel::Point(frame, value, 0, 0.8, tr("New Point")); + m_editingPoint = FlexiNoteModel::Point(frame, float(value), 0, 0.8f, tr("New Point")); m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); @@ -986,14 +986,14 @@ if (!m_model || !m_editing) return; - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float newValue = getValueForY(v, e->y()); + double newValue = getValueForY(v, e->y()); - int newFrame = m_editingPoint.frame; - int newDuration = frame - newFrame; + sv_frame_t newFrame = m_editingPoint.frame; + sv_frame_t newDuration = frame - newFrame; if (newDuration < 0) { newFrame = frame; newDuration = -newDuration; @@ -1003,7 +1003,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = newFrame; - m_editingPoint.value = newValue; + m_editingPoint.value = float(newValue); m_editingPoint.duration = newDuration; m_editingCommand->addPoint(m_editingPoint); } @@ -1085,8 +1085,8 @@ m_dragStartX = e->x(); m_dragStartY = e->y(); - int onset = m_originalPoint.frame; - int offset = m_originalPoint.frame + m_originalPoint.duration - 1; + sv_frame_t onset = m_originalPoint.frame; + sv_frame_t offset = m_originalPoint.frame + m_originalPoint.duration - 1; m_greatestLeftNeighbourFrame = -1; m_smallestRightNeighbourFrame = std::numeric_limits<int>::max(); @@ -1122,11 +1122,11 @@ int newx = m_dragPointX + xdist; int newy = m_dragPointY + ydist; - int dragFrame = v->getFrameForX(newx); + sv_frame_t dragFrame = v->getFrameForX(newx); if (dragFrame < 0) dragFrame = 0; dragFrame = dragFrame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, newy); + double value = getValueForY(v, newy); if (!m_editingCommand) { m_editingCommand = new FlexiNoteModel::EditCommand(m_model, @@ -1164,7 +1164,7 @@ dragFrame = m_smallestRightNeighbourFrame - m_originalPoint.duration; } m_editingPoint.frame = dragFrame; - m_editingPoint.value = value; + m_editingPoint.value = float(value); break; } case SplitNote: // nothing @@ -1244,19 +1244,19 @@ return; } - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); splitNotesAt(v, frame, e); } void -FlexiNoteLayer::splitNotesAt(View *v, int frame) +FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame) { splitNotesAt(v, frame, 0); } void -FlexiNoteLayer::splitNotesAt(View *v, int frame, QMouseEvent *e) +FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e) { FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return; @@ -1301,15 +1301,15 @@ std::cerr << "addNote" << std::endl; if (!m_model) return; - int duration = 10000; + sv_frame_t duration = 10000; - int frame = v->getFrameForX(e->x()); - float value = getValueForY(v, e->y()); + sv_frame_t frame = v->getFrameForX(e->x()); + double value = getValueForY(v, e->y()); FlexiNoteModel::PointList noteList = m_model->getPoints(); if (m_intelligentActions) { - int smallestRightNeighbourFrame = 0; + sv_frame_t smallestRightNeighbourFrame = 0; for (FlexiNoteModel::PointList::const_iterator i = noteList.begin(); i != noteList.end(); ++i) { FlexiNote currentNote = *i; @@ -1326,7 +1326,7 @@ if (!m_intelligentActions || (m_model->getPoints(frame).empty() && duration > 0)) { - FlexiNote newNote(frame, value, duration, 100, "new note"); + FlexiNote newNote(frame, float(value), duration, 100.f, "new note"); FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand (m_model, tr("Add Point")); command->addPoint(newNote); @@ -1454,7 +1454,7 @@ if (dataPoints.empty()) return false; - std::vector<float> pitchValues; + std::vector<double> pitchValues; for (SparseModel<TimeValuePoint>::PointList::const_iterator i = dataPoints.begin(); i != dataPoints.end(); ++i) { @@ -1467,7 +1467,7 @@ if (pitchValues.empty()) return false; sort(pitchValues.begin(), pitchValues.end()); - int size = pitchValues.size(); + int size = int(pitchValues.size()); double median; if (size % 2 == 0) { @@ -1476,7 +1476,7 @@ median = pitchValues[size/2]; } - note.value = median; + note.value = float(median); return true; } @@ -1626,13 +1626,13 @@ if (s.contains(i->frame)) { - double targetStart = i->frame; - targetStart = newSize.getStartFrame() + - double(targetStart - s.getStartFrame()) * ratio; + double targetStart = double(i->frame); + targetStart = double(newSize.getStartFrame()) + + targetStart - double(s.getStartFrame()) * ratio; - double targetEnd = i->frame + i->duration; - targetEnd = newSize.getStartFrame() + - double(targetEnd - s.getStartFrame()) * ratio; + double targetEnd = double(i->frame + i->duration); + targetEnd = double(newSize.getStartFrame()) + + targetEnd - double(s.getStartFrame()) * ratio; FlexiNoteModel::Point newPoint(*i); newPoint.frame = lrint(targetStart); @@ -1711,7 +1711,7 @@ } bool -FlexiNoteLayer::paste(View *v, const Clipboard &from, int /*frameOffset */, bool /* interactive */) +FlexiNoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -1743,7 +1743,7 @@ i != points.end(); ++i) { if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { @@ -1768,7 +1768,7 @@ if (i->haveLevel()) newPoint.level = i->getLevel(); if (i->haveDuration()) newPoint.duration = i->getDuration(); else { - int nextFrame = frame; + sv_frame_t nextFrame = frame; Clipboard::PointList::const_iterator j = i; for (; j != points.end(); ++j) { if (!j->haveFrame()) continue; @@ -1792,17 +1792,17 @@ } void -FlexiNoteLayer::addNoteOn(int frame, int pitch, int velocity) +FlexiNoteLayer::addNoteOn(sv_frame_t frame, int pitch, int velocity) { - m_pendingNoteOns.insert(FlexiNote(frame, pitch, 0, float(velocity) / 127.0, "")); + m_pendingNoteOns.insert(FlexiNote(frame, float(pitch), 0, float(velocity / 127.0), "")); } void -FlexiNoteLayer::addNoteOff(int frame, int pitch) +FlexiNoteLayer::addNoteOff(sv_frame_t frame, int pitch) { for (FlexiNoteSet::iterator i = m_pendingNoteOns.begin(); i != m_pendingNoteOns.end(); ++i) { - if (lrintf((*i).value) == pitch) { + if (lrint((*i).value) == pitch) { FlexiNote note(*i); m_pendingNoteOns.erase(i); note.duration = frame - note.frame; @@ -1853,16 +1853,16 @@ if (ok) setVerticalScale(scale); // bool alsoOk; -// float min = attributes.value("scaleMinimum").toFloat(&ok); -// float max = attributes.value("scaleMaximum").toFloat(&alsoOk); +// double min = attributes.value("scaleMinimum").toDouble(&ok); +// double max = attributes.value("scaleMaximum").toDouble(&alsoOk); // if (ok && alsoOk && min != max) setDisplayExtents(min, max); } void FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) { - float minf = std::numeric_limits<float>::max(); - float maxf = 0; + double minf = std::numeric_limits<double>::max(); + double maxf = 0; bool hasNotes = 0; for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); i != m_model->getPoints().end(); ++i) {
--- a/layer/FlexiNoteLayer.h Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/FlexiNoteLayer.h Mon Mar 09 12:02:10 2015 +0000 @@ -45,7 +45,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; @@ -76,10 +76,10 @@ virtual void deleteSelectionInclusive(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); - void splitNotesAt(View *v, int frame); + void splitNotesAt(View *v, sv_frame_t frame); void snapSelectedNotesToPitchTrack(View *v, Selection s); void mergeNotes(View *v, Selection s, bool inclusive); @@ -122,11 +122,11 @@ virtual int getCompletion(View *) const { return m_model->getCompletion(); } - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &log, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; - virtual bool setDisplayExtents(float min, float max); + virtual bool getDisplayExtents(double &min, double &max) const; + virtual bool setDisplayExtents(double min, double max); virtual int getVerticalZoomSteps(int &defaultStep) const; virtual int getCurrentVerticalZoomStep() const; @@ -138,13 +138,13 @@ * not be finally added to the layer until the corresponding * note-off. */ - void addNoteOn(int frame, int pitch, int velocity); + void addNoteOn(sv_frame_t frame, int pitch, int velocity); /** * Add a note-off. This will cause a note to appear, if and only * if there is a matching pending note-on. */ - void addNoteOff(int frame, int pitch); + void addNoteOff(sv_frame_t frame, int pitch); /** * Abandon all pending note-on events. @@ -159,12 +159,12 @@ void setVerticalRangeToNoteRange(View *v); /// VerticalScaleLayer methods - virtual int getYForValue(View *v, float value) const; - virtual float getValueForY(View *v, int y) const; + virtual int getYForValue(View *v, double value) const; + virtual double getValueForY(View *v, int y) const; virtual QString getScaleUnits() const; protected: - void getScaleExtents(View *, float &min, float &max, bool &log) const; + void getScaleExtents(View *, double &min, double &max, bool &log) const; bool shouldConvertMIDIToHz() const; virtual int getDefaultColourHint(bool dark, bool &impose); @@ -176,7 +176,7 @@ void getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const; SparseTimeValueModel *getAssociatedPitchModel(View *v) const; bool updateNoteValue(View *v, FlexiNoteModel::Point ¬e) const; - void splitNotesAt(View *v, int frame, QMouseEvent *e); + void splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e); FlexiNoteModel *m_model; bool m_editing; @@ -187,8 +187,8 @@ int m_dragStartY; FlexiNoteModel::Point m_originalPoint; FlexiNoteModel::Point m_editingPoint; - int m_greatestLeftNeighbourFrame; - int m_smallestRightNeighbourFrame; + sv_frame_t m_greatestLeftNeighbourFrame; + sv_frame_t m_smallestRightNeighbourFrame; FlexiNoteModel::EditCommand *m_editingCommand; VerticalScale m_verticalScale; EditMode m_editMode; @@ -196,8 +196,8 @@ typedef std::set<FlexiNoteModel::Point, FlexiNoteModel::Point::Comparator> FlexiNoteSet; FlexiNoteSet m_pendingNoteOns; - mutable float m_scaleMinimum; - mutable float m_scaleMaximum; + mutable double m_scaleMinimum; + mutable double m_scaleMaximum; bool shouldAutoAlign() const;
--- a/layer/Layer.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/Layer.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -139,34 +139,34 @@ } bool -Layer::getXScaleValue(const View *v, int x, float &value, QString &unit) const +Layer::getXScaleValue(const View *v, int x, double &value, QString &unit) const { if (!hasTimeXAxis()) return false; const Model *m = getModel(); if (!m) return false; - value = float(v->getFrameForX(x)) / m->getSampleRate(); + value = double(v->getFrameForX(x)) / m->getSampleRate(); unit = "s"; return true; } bool Layer::getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const + double &diff, QString &unit) const { - float v0, v1; + double v0, v1; if (!getYScaleValue(v, y0, v0, unit) || !getYScaleValue(v, y1, v1, unit)) { diff = 0.f; return false; } - diff = fabsf(v1 - v0); + diff = fabs(v1 - v0); return true; } -int -Layer::alignToReference(View *v, int frame) const +sv_frame_t +Layer::alignToReference(View *v, sv_frame_t frame) const { const Model *m = getModel(); SVDEBUG << "Layer::alignToReference(" << frame << "): model = " << m << ", alignment reference = " << (m ? m->getAlignmentReference() : 0) << endl; @@ -177,8 +177,8 @@ } } -int -Layer::alignFromReference(View *v, int frame) const +sv_frame_t +Layer::alignFromReference(View *v, sv_frame_t frame) const { const Model *m = getModel(); SVDEBUG << "Layer::alignFromReference(" << frame << "): model = " << m << ", alignment reference = " << (m ? m->getAlignmentReference() : 0) << endl; @@ -541,7 +541,7 @@ Layer::MeasureRectSet::const_iterator Layer::findFocusedMeasureRect(QPoint focusPoint) const { - float frDist = 0; + double frDist = 0; MeasureRectSet::const_iterator focusRectItr = m_measureRects.end(); for (MeasureRectSet::const_iterator i = m_measureRects.begin(); @@ -554,7 +554,7 @@ int xd = focusPoint.x() - cx; int yd = focusPoint.y() - cy; - float d = sqrt(float(xd * xd + yd * yd)); + double d = sqrt(double(xd * xd + yd * yd)); if (focusRectItr == m_measureRects.end() || d < frDist) { focusRectItr = i;
--- a/layer/Layer.h Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/Layer.h Mon Mar 09 12:02:10 2015 +0000 @@ -180,8 +180,8 @@ * (and leave frame unmodified). If returning true, also return * the resolution of the model in this layer in sample frames. */ - virtual bool snapToFeatureFrame(View * /* v */, - int & /* frame */, + virtual bool snapToFeatureFrame(View * /* v */, + sv_frame_t & /* frame */, int &resolution, SnapType /* snap */) const { resolution = 1; @@ -204,8 +204,8 @@ * (and leave frame unmodified). If returning true, also return * the resolution of the model in this layer in sample frames. */ - virtual bool snapToSimilarFeature(View * /* v */, - int & /* source frame */, + virtual bool snapToSimilarFeature(View * /* v */, + sv_frame_t & /* source frame */, int &resolution, SnapType /* snap */) const { resolution = 1; @@ -269,7 +269,7 @@ */ virtual bool paste(View *, const Clipboard & /* from */, - int /* frameOffset */, + sv_frame_t /* frameOffset */, bool /* interactive */) { return false; } // Text mode: @@ -423,7 +423,7 @@ * This function returns the "normal" extents for the layer, not * necessarily the extents actually in use in the display. */ - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const = 0; /** @@ -434,8 +434,8 @@ * extent (using the normal layer extents or deferring to whatever * is in use for the same units elsewhere in the view). */ - virtual bool getDisplayExtents(float & /* min */, - float & /* max */) const { + virtual bool getDisplayExtents(double & /* min */, + double & /* max */) const { return false; } @@ -446,8 +446,8 @@ * return false for getDisplayExtents should also return false for * this function. */ - virtual bool setDisplayExtents(float /* min */, - float /* max */) { + virtual bool setDisplayExtents(double /* min */, + double /* max */) { return false; } @@ -458,14 +458,14 @@ * if the layer hasTimeXAxis(). */ virtual bool getXScaleValue(const View *v, int x, - float &value, QString &unit) const; + double &value, QString &unit) const; /** * Return the value and unit at the given y coordinate in the * given view. */ virtual bool getYScaleValue(const View *, int /* y */, - float &/* value */, QString &/* unit */) const { + double &/* value */, QString &/* unit */) const { return false; } @@ -476,7 +476,7 @@ * returns the difference, with the same unit. */ virtual bool getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const; + double &diff, QString &unit) const; /** * Get the number of vertical zoom steps available for this layer. @@ -538,8 +538,8 @@ protected: void connectSignals(const Model *); - virtual int alignToReference(View *v, int frame) const; - virtual int alignFromReference(View *v, int frame) const; + virtual sv_frame_t alignToReference(View *v, sv_frame_t frame) const; + virtual sv_frame_t alignFromReference(View *v, sv_frame_t frame) const; bool clipboardHasDifferentAlignment(View *v, const Clipboard &clip) const; struct MeasureRect {
--- a/layer/LinearNumericalScale.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/LinearNumericalScale.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -34,20 +34,20 @@ const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minf, - float maxf) + double minf, + double maxf) { int n = 10; - float val = minf; - float inc = (maxf - val) / n; + double val = minf; + double inc = (maxf - val) / n; const int buflen = 40; char buffer[buflen]; int w = getWidth(v, paint) + x0; - float round = 1.f; + double round = 1.f; int dp = 0; if (inc > 0) { int prec = trunc(log10f(inc)); @@ -66,7 +66,7 @@ int y, ty; bool drawText = true; - float dispval = val; + double dispval = val; if (i == n-1 && v->height() < paint.fontMetrics().height() * (n*2)) {
--- a/layer/LinearNumericalScale.h Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/LinearNumericalScale.h Mon Mar 09 12:02:10 2015 +0000 @@ -29,7 +29,7 @@ void paintVertical (View *v, const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minf, float maxf); + double minf, double maxf); }; #endif
--- a/layer/LogNumericalScale.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/LogNumericalScale.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -38,18 +38,18 @@ const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minlog, - float maxlog) + double minlog, + double maxlog) { int w = getWidth(v, paint) + x0; int n = 10; - float val = minlog; - float inc = (maxlog - val) / n; // even increments of log scale + double val = minlog; + double inc = (maxlog - val) / n; // even increments of log scale // smallest increment as displayed - float minDispInc = LogRange::unmap(minlog + inc) - LogRange::unmap(minlog); + double minDispInc = LogRange::unmap(minlog + inc) - LogRange::unmap(minlog); #ifdef DEBUG_TIME_VALUE_LAYER cerr << "min = " << minlog << ", max = " << maxlog << ", inc = " << inc << ", minDispInc = " << minDispInc << endl; @@ -58,7 +58,7 @@ const int buflen = 40; char buffer[buflen]; - float round = 1.f; + double round = 1.f; int dp = 0; if (minDispInc > 0) { @@ -83,7 +83,7 @@ if (layer->getScaleUnits() != "") drawText = false; } - float dispval = LogRange::unmap(val); + double dispval = LogRange::unmap(val); dispval = floor(dispval / round) * round; #ifdef DEBUG_TIME_VALUE_LAYER
--- a/layer/LogNumericalScale.h Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/LogNumericalScale.h Mon Mar 09 12:02:10 2015 +0000 @@ -29,7 +29,7 @@ void paintVertical (View *v, const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minlog, float maxlog); + double minlog, double maxlog); }; #endif
--- a/layer/PianoScale.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/PianoScale.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -27,8 +27,8 @@ PianoScale::paintPianoVertical(View *v, QPainter &paint, QRect r, - float minf, - float maxf) + double minf, + double maxf) { int x0 = r.x(), y0 = r.y(), x1 = r.x() + r.width(), y1 = r.y() + r.height(); @@ -39,7 +39,7 @@ for (int i = 0; i < 128; ++i) { - float f = Pitch::getFrequencyForPitch(i); + double f = Pitch::getFrequencyForPitch(i); int y = lrintf(v->getYForFrequency(f, minf, maxf, true)); if (y < y0 - 2) break;
--- a/layer/PianoScale.h Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/PianoScale.h Mon Mar 09 12:02:10 2015 +0000 @@ -25,7 +25,7 @@ { public: void paintPianoVertical - (View *v, QPainter &paint, QRect rect, float minf, float maxf); + (View *v, QPainter &paint, QRect rect, double minf, double maxf); }; #endif
--- a/layer/VerticalScaleLayer.h Mon Mar 09 08:43:20 2015 +0000 +++ b/layer/VerticalScaleLayer.h Mon Mar 09 12:02:10 2015 +0000 @@ -19,8 +19,8 @@ class VerticalScaleLayer { public: - virtual int getYForValue(View *, float value) const = 0; - virtual float getValueForY(View *, int y) const = 0; + virtual int getYForValue(View *, double value) const = 0; + virtual double getValueForY(View *, int y) const = 0; virtual QString getScaleUnits() const = 0; };
--- a/view/View.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/view/View.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -182,7 +182,7 @@ } bool -View::getValueExtents(QString unit, float &min, float &max, bool &log) const +View::getValueExtents(QString unit, double &min, double &max, bool &log) const { bool have = false; @@ -190,8 +190,8 @@ i != m_layerStack.end(); ++i) { QString layerUnit; - float layerMin = 0.0, layerMax = 0.0; - float displayMin = 0.0, displayMax = 0.0; + double layerMin = 0.0, layerMax = 0.0; + double displayMin = 0.0, displayMax = 0.0; bool layerLog = false; if ((*i)->getValueExtents(layerMin, layerMax, layerLog, layerUnit) && @@ -373,10 +373,10 @@ return frame + x * z; } -float -View::getYForFrequency(float frequency, - float minf, - float maxf, +double +View::getYForFrequency(double frequency, + double minf, + double maxf, bool logarithmic) const { Profiler profiler("View::getYForFrequency"); @@ -385,8 +385,8 @@ if (logarithmic) { - static float lastminf = 0.0, lastmaxf = 0.0; - static float logminf = 0.0, logmaxf = 0.0; + static double lastminf = 0.0, lastmaxf = 0.0; + static double logminf = 0.0, logmaxf = 0.0; if (lastminf != minf) { lastminf = (minf == 0.0 ? 1.0 : minf); @@ -407,18 +407,18 @@ } } -float +double View::getFrequencyForY(int y, - float minf, - float maxf, + double minf, + double maxf, bool logarithmic) const { int h = height(); if (logarithmic) { - static float lastminf = 0.0, lastmaxf = 0.0; - static float logminf = 0.0, logmaxf = 0.0; + static double lastminf = 0.0, lastmaxf = 0.0; + static double logminf = 0.0, logmaxf = 0.0; if (lastminf != minf) { lastminf = (minf == 0.0 ? 1.0 : minf); @@ -2145,7 +2145,7 @@ int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); - float v0, v1; + double v0, v1; QString u0, u1; bool b0 = false, b1 = false; @@ -2217,7 +2217,7 @@ } bool bd = false; - float dy = 0.f; + double dy = 0.f; QString du; // dimension, height @@ -2228,7 +2228,7 @@ if (du != "") { if (du == "Hz") { int semis; - float cents; + double cents; semis = Pitch::getPitchForFrequencyDifference(v0, v1, ¢s); dys = QString("[%1 %2 (%3)]") .arg(dy).arg(du)
--- a/view/View.h Mon Mar 09 08:43:20 2015 +0000 +++ b/view/View.h Mon Mar 09 12:02:10 2015 +0000 @@ -112,7 +112,7 @@ * * Not thread-safe in logarithmic mode. Call only from GUI thread. */ - float getYForFrequency(float frequency, float minFreq, float maxFreq, + double getYForFrequency(double frequency, double minFreq, double maxFreq, bool logarithmic) const; /** @@ -121,7 +121,7 @@ * * Not thread-safe in logarithmic mode. Call only from GUI thread. */ - float getFrequencyForY(int y, float minFreq, float maxFreq, + double getFrequencyForY(int y, double minFreq, double maxFreq, bool logarithmic) const; /** @@ -302,7 +302,7 @@ virtual int getTextLabelHeight(const Layer *layer, QPainter &) const; - virtual bool getValueExtents(QString unit, float &min, float &max, + virtual bool getValueExtents(QString unit, double &min, double &max, bool &log) const; virtual void toXml(QTextStream &stream, QString indent = "",
--- a/widgets/ItemEditDialog.cpp Mon Mar 09 08:43:20 2015 +0000 +++ b/widgets/ItemEditDialog.cpp Mon Mar 09 12:02:10 2015 +0000 @@ -28,7 +28,7 @@ #include <float.h> // for FLT_MIN/MAX -ItemEditDialog::ItemEditDialog(int sampleRate, int options, +ItemEditDialog::ItemEditDialog(sv_samplerate_t sampleRate, int options, QString valueUnits, QWidget *parent) : QDialog(parent), m_sampleRate(sampleRate), @@ -76,7 +76,7 @@ m_frameTimeSpinBox->setSuffix(tr(" frames")); subgrid->addWidget(m_frameTimeSpinBox, subrow, 1, 1, 2); connect(m_frameTimeSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(frameTimeChanged(int))); + this, SLOT(frameTimeChanged(sv_frame_t))); ++subrow; @@ -107,7 +107,7 @@ m_frameDurationSpinBox->setSuffix(tr(" frames")); subgrid->addWidget(m_frameDurationSpinBox, subrow, 1, 1, 2); connect(m_frameDurationSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(frameDurationChanged(int))); + this, SLOT(frameDurationChanged(sv_frame_t))); ++subrow; @@ -193,7 +193,7 @@ } void -ItemEditDialog::setFrameTime(int frame) +ItemEditDialog::setFrameTime(sv_frame_t frame) { if (!m_frameTimeSpinBox) return; @@ -205,7 +205,7 @@ m_resetButton->setEnabled(false); } -int +sv_frame_t ItemEditDialog::getFrameTime() const { return m_frameTimeSpinBox->value(); @@ -224,7 +224,7 @@ } void -ItemEditDialog::setFrameDuration(int duration) +ItemEditDialog::setFrameDuration(sv_frame_t duration) { if (!m_frameDurationSpinBox) return; @@ -236,7 +236,7 @@ m_resetButton->setEnabled(false); } -int +sv_frame_t ItemEditDialog::getFrameDuration() const { return m_frameDurationSpinBox->value(); @@ -287,7 +287,7 @@ } void -ItemEditDialog::frameTimeChanged(int i) +ItemEditDialog::frameTimeChanged(sv_frame_t i) { m_realTimeSecsSpinBox->blockSignals(true); m_realTimeUSecsSpinBox->blockSignals(true); @@ -306,7 +306,7 @@ { RealTime rt = getRealTime(); rt.sec = i; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); m_frameTimeSpinBox->setValue(frame); m_resetButton->setEnabled(true); } @@ -316,13 +316,13 @@ { RealTime rt = getRealTime(); rt.nsec = i * 1000; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); m_frameTimeSpinBox->setValue(frame); m_resetButton->setEnabled(true); } void -ItemEditDialog::frameDurationChanged(int i) +ItemEditDialog::frameDurationChanged(sv_frame_t i) { m_realDurationSecsSpinBox->blockSignals(true); m_realDurationUSecsSpinBox->blockSignals(true); @@ -341,7 +341,7 @@ { RealTime rt = getRealDuration(); rt.sec = i; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); m_frameDurationSpinBox->setValue(frame); m_resetButton->setEnabled(true); } @@ -351,7 +351,7 @@ { RealTime rt = getRealDuration(); rt.nsec = i * 1000; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); m_frameDurationSpinBox->setValue(frame); m_resetButton->setEnabled(true); }
--- a/widgets/ItemEditDialog.h Mon Mar 09 08:43:20 2015 +0000 +++ b/widgets/ItemEditDialog.h Mon Mar 09 12:02:10 2015 +0000 @@ -37,17 +37,17 @@ ShowText = 1 << 3 }; - ItemEditDialog(int sampleRate, int options, QString valueUnits = "", + ItemEditDialog(sv_samplerate_t sampleRate, int options, QString valueUnits = "", QWidget *parent = 0); - void setFrameTime(int frame); - int getFrameTime() const; + void setFrameTime(sv_frame_t frame); + sv_frame_t getFrameTime() const; void setRealTime(RealTime rt); RealTime getRealTime() const; - void setFrameDuration(int frame); - int getFrameDuration() const; + void setFrameDuration(sv_frame_t frame); + sv_frame_t getFrameDuration() const; void setRealDuration(RealTime rt); RealTime getRealDuration() const; @@ -59,10 +59,10 @@ QString getText() const; protected slots: - void frameTimeChanged(int); + void frameTimeChanged(sv_frame_t); void realTimeSecsChanged(int); void realTimeUSecsChanged(int); - void frameDurationChanged(int); + void frameDurationChanged(sv_frame_t); void realDurationSecsChanged(int); void realDurationUSecsChanged(int); void valueChanged(double); @@ -70,9 +70,9 @@ void reset(); protected: - int m_sampleRate; - int m_defaultFrame; - int m_defaultDuration; + sv_samplerate_t m_sampleRate; + sv_frame_t m_defaultFrame; + sv_frame_t m_defaultDuration; float m_defaultValue; QString m_defaultText; QSpinBox *m_frameTimeSpinBox;