# HG changeset patch # User Chris Cannam # Date 1425993730 0 # Node ID 4a578a360011e1bca3a5885e15835564e398a200 # Parent 28d05ae8741c1fc5eea59f0a023817aa48326223 More type fixes diff -r 28d05ae8741c -r 4a578a360011 layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/Colour3DPlotLayer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -80,8 +80,8 @@ connectSignals(m_model); connect(m_model, SIGNAL(modelChanged()), this, SLOT(modelChanged())); - connect(m_model, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(modelChangedWithin(int, int))); + connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); m_peakResolution = 256; if (model->getResolution() > 512) { @@ -109,13 +109,13 @@ } void -Colour3DPlotLayer::cacheInvalid(int startFrame, int endFrame) +Colour3DPlotLayer::cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame) { if (!m_cache || !m_model) return; int modelResolution = m_model->getResolution(); - int start = startFrame / modelResolution; - int end = endFrame / modelResolution + 1; + int start = int(startFrame / modelResolution); + int end = int(endFrame / modelResolution + 1); if (m_cacheValidStart < end) m_cacheValidStart = end; if (m_cacheValidEnd > start) m_cacheValidEnd = start; if (m_cacheValidStart > m_cacheValidEnd) m_cacheValidEnd = m_cacheValidStart; @@ -137,7 +137,7 @@ } void -Colour3DPlotLayer::modelChangedWithin(int startFrame, int endFrame) +Colour3DPlotLayer::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { if (!m_colourScaleSet && m_colourScale == LinearScale) { if (m_model && m_model->getWidth() > 50) { diff -r 28d05ae8741c -r 4a578a360011 layer/Colour3DPlotLayer.h --- a/layer/Colour3DPlotLayer.h Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/Colour3DPlotLayer.h Tue Mar 10 13:22:10 2015 +0000 @@ -166,9 +166,9 @@ protected slots: void cacheInvalid(); - void cacheInvalid(int startFrame, int endFrame); + void cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame); void modelChanged(); - void modelChangedWithin(int, int); + void modelChangedWithin(sv_frame_t, sv_frame_t); protected: const DenseThreeDimensionalModel *m_model; // I do not own this diff -r 28d05ae8741c -r 4a578a360011 layer/Layer.cpp --- a/layer/Layer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/Layer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -51,8 +51,8 @@ connect(model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); - connect(model, SIGNAL(modelChangedWithin(int, int)), - this, SIGNAL(modelChangedWithin(int, int))); + connect(model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); connect(model, SIGNAL(completionChanged()), this, SIGNAL(modelCompletionChanged())); diff -r 28d05ae8741c -r 4a578a360011 layer/SpectrumLayer.cpp --- a/layer/SpectrumLayer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/SpectrumLayer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -301,42 +301,42 @@ } bool -SpectrumLayer::getValueExtents(float &, float &, bool &, QString &) const +SpectrumLayer::getValueExtents(double &, double &, bool &, QString &) const { return false; } -float -SpectrumLayer::getXForBin(int bin, int totalBins, float w) const +double +SpectrumLayer::getXForBin(int bin, int totalBins, double w) const { if (!m_sliceableModel) return SliceLayer::getXForBin(bin, totalBins, w); - float sampleRate = m_sliceableModel->getSampleRate(); - float binfreq = (sampleRate * bin) / (totalBins * 2); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); + double binfreq = (sampleRate * bin) / (totalBins * 2); return getXForFrequency(binfreq, w); } int -SpectrumLayer::getBinForX(float x, int totalBins, float w) const +SpectrumLayer::getBinForX(double x, int totalBins, double w) const { if (!m_sliceableModel) return SliceLayer::getBinForX(x, totalBins, w); - float sampleRate = m_sliceableModel->getSampleRate(); - float binfreq = getFrequencyForX(x, w); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); + double binfreq = getFrequencyForX(x, w); return int((binfreq * totalBins * 2) / sampleRate); } -float -SpectrumLayer::getFrequencyForX(float x, float w) const +double +SpectrumLayer::getFrequencyForX(double x, double w) const { - float freq = 0; + double freq = 0; if (!m_sliceableModel) return 0; - int sampleRate = m_sliceableModel->getSampleRate(); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); - float maxfreq = float(sampleRate) / 2; + double maxfreq = double(sampleRate) / 2; switch (m_binScale) { @@ -345,26 +345,26 @@ break; case LogBins: - freq = powf(10.f, (x * log10f(maxfreq)) / w); + freq = pow(10.0, (x * log10(maxfreq)) / w); break; case InvertedLogBins: - freq = maxfreq - powf(10.f, ((w - x) * log10f(maxfreq)) / w); + freq = maxfreq - pow(10.0, ((w - x) * log10(maxfreq)) / w); break; } return freq; } -float -SpectrumLayer::getXForFrequency(float freq, float w) const +double +SpectrumLayer::getXForFrequency(double freq, double w) const { - float x = 0; + double x = 0; if (!m_sliceableModel) return x; - int sampleRate = m_sliceableModel->getSampleRate(); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); - float maxfreq = float(sampleRate) / 2; + double maxfreq = double(sampleRate) / 2; switch (m_binScale) { @@ -373,12 +373,12 @@ break; case LogBins: - x = (log10f(freq) * w) / log10f(maxfreq); + x = (log10(freq) * w) / log10(maxfreq); break; case InvertedLogBins: if (maxfreq == freq) x = w; - else x = w - (log10f(maxfreq - freq) * w) / log10f(maxfreq); + else x = w - (log10(maxfreq - freq) * w) / log10(maxfreq); break; } @@ -387,7 +387,7 @@ bool SpectrumLayer::getXScaleValue(const View *v, int x, - float &value, QString &unit) const + double &value, QString &unit) const { if (m_xorigins.find(v) == m_xorigins.end()) return false; int xorigin = m_xorigins.find(v)->second; @@ -398,14 +398,14 @@ bool SpectrumLayer::getYScaleValue(const View *v, int y, - float &value, QString &unit) const + double &value, QString &unit) const { value = getValueForY(y, v); if (m_energyScale == dBScale || m_energyScale == MeterScale) { - if (value > 0.f) { - value = 10.f * log10f(value); + if (value > 0.0) { + value = 10.0 * log10(value); if (value < m_threshold) value = m_threshold; } else value = m_threshold; @@ -420,7 +420,7 @@ bool SpectrumLayer::getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const + double &diff, QString &unit) const { bool rv = SliceLayer::getYScaleDifference(v, y0, y1, diff, unit); if (rv && (unit == "dBV")) unit = "dB"; @@ -492,7 +492,7 @@ paint.drawLine(xorigin, cursorPos.y(), v->width(), cursorPos.y()); paint.drawLine(cursorPos.x(), cursorPos.y(), cursorPos.x(), v->height()); - float fundamental = getFrequencyForX(cursorPos.x() - xorigin, w); + double fundamental = getFrequencyForX(cursorPos.x() - xorigin, w); int hoffset = 2; if (m_binScale == LogBins) hoffset = 13; @@ -512,10 +512,10 @@ View::OutlinedText); } - float value = getValueForY(cursorPos.y(), v); - float thresh = m_threshold; - float db = thresh; - if (value > 0.f) db = 10.f * log10f(value); + double value = getValueForY(cursorPos.y(), v); + double thresh = m_threshold; + double db = thresh; + if (value > 0.0) db = 10.0 * log10(value); if (db < thresh) db = thresh; v->drawVisibleText(paint, @@ -534,7 +534,7 @@ while (harmonic < 100) { - float hx = lrintf(getXForFrequency(fundamental * harmonic, w)); + int hx = int(lrint(getXForFrequency(fundamental * harmonic, w))); hx += xorigin; if (hx < xorigin || hx > v->width()) break; @@ -549,9 +549,9 @@ } } - paint.drawLine(int(hx), + paint.drawLine(hx, cursorPos.y(), - int(hx), + hx, cursorPos.y() + len); ++harmonic; @@ -571,21 +571,21 @@ if (genericDesc == "") return ""; - float minvalue = 0.f; + double minvalue = 0.f; if (minbin < int(m_values.size())) minvalue = m_values[minbin]; - float maxvalue = minvalue; + double maxvalue = minvalue; if (maxbin < int(m_values.size())) maxvalue = m_values[maxbin]; if (minvalue > maxvalue) std::swap(minvalue, maxvalue); QString binstr; QString hzstr; - int minfreq = lrintf((minbin * m_sliceableModel->getSampleRate()) / - m_windowSize); - int maxfreq = lrintf((std::max(maxbin, minbin+1) - * m_sliceableModel->getSampleRate()) / - m_windowSize); + int minfreq = int(lrint((minbin * m_sliceableModel->getSampleRate()) / + m_windowSize)); + int maxfreq = int(lrint((std::max(maxbin, minbin+1) + * m_sliceableModel->getSampleRate()) / + m_windowSize)); if (maxbin != minbin) { binstr = tr("%1 - %2").arg(minbin+1).arg(maxbin+1); @@ -606,21 +606,21 @@ } QString dbstr; - float mindb = AudioLevel::multiplier_to_dB(minvalue); - float maxdb = AudioLevel::multiplier_to_dB(maxvalue); + double mindb = AudioLevel::multiplier_to_dB(minvalue); + double maxdb = AudioLevel::multiplier_to_dB(maxvalue); QString mindbstr; QString maxdbstr; if (mindb == AudioLevel::DB_FLOOR) { mindbstr = tr("-Inf"); } else { - mindbstr = QString("%1").arg(lrintf(mindb)); + mindbstr = QString("%1").arg(lrint(mindb)); } if (maxdb == AudioLevel::DB_FLOOR) { maxdbstr = tr("-Inf"); } else { - maxdbstr = QString("%1").arg(lrintf(maxdb)); + maxdbstr = QString("%1").arg(lrint(maxdb)); } - if (lrintf(mindb) != lrintf(maxdb)) { + if (lrint(mindb) != lrint(maxdb)) { dbstr = tr("%1 - %2").arg(mindbstr).arg(maxdbstr); } else { dbstr = tr("%1").arg(mindbstr); @@ -666,7 +666,7 @@ FFTModel *fft = dynamic_cast (const_cast(m_sliceableModel)); - float thresh = (powf(10, -6) / m_gain) * (m_windowSize / 2.f); // -60dB adj + double thresh = (pow(10, -6) / m_gain) * (m_windowSize / 2.0); // -60dB adj int xorigin = getVerticalScaleWidth(v, false, paint) + 1; int w = v->width() - xorigin - 1; @@ -684,7 +684,7 @@ // SVDEBUG << "Showing peaks..." << endl; - int col = v->getCentreFrame() / fft->getResolution(); + int col = int(v->getCentreFrame() / fft->getResolution()); paint.save(); paint.setRenderHint(QPainter::Antialiasing, false); @@ -692,8 +692,8 @@ int peakminbin = 0; int peakmaxbin = fft->getHeight() - 1; - float peakmaxfreq = Pitch::getFrequencyForPitch(128); - peakmaxbin = ((peakmaxfreq * fft->getHeight() * 2) / fft->getSampleRate()); + double peakmaxfreq = Pitch::getFrequencyForPitch(128); + peakmaxbin = int(((peakmaxfreq * fft->getHeight() * 2) / fft->getSampleRate())); FFTModel::PeakSet peaks = fft->getPeakFrequencies (FFTModel::MajorPitchAdaptivePeaks, col, peakminbin, peakmaxbin); @@ -702,12 +702,12 @@ BiasCurve curve; getBiasCurve(curve); - int cs = curve.size(); + int cs = int(curve.size()); - std::vector values; + std::vector values; for (int bin = 0; bin < fft->getHeight(); ++bin) { - float value = m_sliceableModel->getValueAt(col, bin); + double value = m_sliceableModel->getValueAt(col, bin); if (bin < cs) value *= curve[bin]; values.push_back(value); } @@ -719,13 +719,13 @@ // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; - if (!fft->isOverThreshold(col, bin, thresh)) continue; + if (!fft->isOverThreshold(col, bin, float(thresh))) continue; - float freq = i->second; + double freq = i->second; - int x = lrintf(getXForFrequency(freq, w)); + int x = int(lrint(getXForFrequency(freq, w))); - float norm = 0.f; + double norm = 0.f; (void)getYForValue(values[bin], v, norm); // don't need return value, need norm paint.setPen(mapper.map(norm)); @@ -762,8 +762,8 @@ for (int i = 0; i < 128; ++i) { - float f = Pitch::getFrequencyForPitch(i); - int x = lrintf(getXForFrequency(f, w)); + double f = Pitch::getFrequencyForPitch(i); + int x = int(lrint(getXForFrequency(f, w))); x += xorigin; @@ -805,7 +805,7 @@ if (n == 1 || n == 3 || n == 6 || n == 8 || n == 10) { // black notes paint.drawLine(x, h - pkh, x, h); - int rw = lrintf(float(x - px) / 4) * 2; + int rw = int(lrint(double(x - px) / 4) * 2); if (rw < 2) rw = 2; paint.drawRect(x - rw/2, h - pkh, rw, pkh/2); } else if (n == 0 || n == 5) { diff -r 28d05ae8741c -r 4a578a360011 layer/TextLayer.cpp --- a/layer/TextLayer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/TextLayer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -96,7 +96,7 @@ } bool -TextLayer::getValueExtents(float &, float &, bool &, QString &) const +TextLayer::getValueExtents(double &, double &, bool &, QString &) const { return false; } @@ -114,8 +114,8 @@ { if (!m_model) return TextModel::PointList(); - long frame0 = v->getFrameForX(-150); - long frame1 = v->getFrameForX(v->width() + 150); + sv_frame_t frame0 = v->getFrameForX(-150); + sv_frame_t frame1 = v->getFrameForX(v->width() + 150); TextModel::PointList points(m_model->getPoints(frame0, frame1)); @@ -158,19 +158,19 @@ { if (!m_model) return false; - long a = v->getFrameForX(x - 120); - long b = v->getFrameForX(x + 10); + sv_frame_t a = v->getFrameForX(x - 120); + sv_frame_t b = v->getFrameForX(x + 10); TextModel::PointList onPoints = m_model->getPoints(a, b); if (onPoints.empty()) return false; - float nearestDistance = -1; + double nearestDistance = -1; for (TextModel::PointList::const_iterator i = onPoints.begin(); i != onPoints.end(); ++i) { - int yd = getYForHeight(v, (*i).height) - y; - int xd = v->getXForFrame((*i).frame) - x; - float distance = sqrtf(yd*yd + xd*xd); + double yd = getYForHeight(v, (*i).height) - y; + double xd = v->getXForFrame((*i).frame) - x; + double distance = sqrt(yd*yd + xd*xd); if (nearestDistance == -1 || distance < nearestDistance) { nearestDistance = distance; @@ -198,7 +198,7 @@ } } - long useFrame = points.begin()->frame; + sv_frame_t useFrame = points.begin()->frame; RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); @@ -220,7 +220,7 @@ //!!! too much overlap with TimeValueLayer/TimeInstantLayer bool -TextLayer::snapToFeatureFrame(View *v, int &frame, +TextLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -240,7 +240,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (TextModel::PointList::const_iterator i = points.begin(); @@ -292,17 +292,17 @@ } int -TextLayer::getYForHeight(View *v, float height) const +TextLayer::getYForHeight(View *v, double height) const { int h = v->height(); return h - int(height * h); } -float +double TextLayer::getHeightForY(View *v, int y) const { int h = v->height(); - return float(h - y) / h; + return double(h - y) / h; } void @@ -310,14 +310,14 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; // Profiler profiler("TextLayer::paint", true); int x0 = rect.left(), x1 = rect.right(); - long frame0 = v->getFrameForX(x0); - long frame1 = v->getFrameForX(x1); + sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t frame1 = v->getFrameForX(x1); TextModel::PointList points(m_model->getPoints(frame0, frame1)); if (points.empty()) return; @@ -420,13 +420,13 @@ return; } - long 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 height = getHeightForY(v, e->y()); + double height = getHeightForY(v, e->y()); - m_editingPoint = TextModel::Point(frame, height, ""); + m_editingPoint = TextModel::Point(frame, float(height), ""); m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); @@ -443,15 +443,15 @@ if (!m_model || !m_editing) return; - long 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 height = getHeightForY(v, e->y()); + double height = getHeightForY(v, e->y()); m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.height = height; + m_editingPoint.height = float(height); m_editingCommand->addPoint(m_editingPoint); } @@ -547,17 +547,17 @@ { if (!m_model || !m_editing) return; - long frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); - float heightDiff = getHeightForY(v, e->y()) - getHeightForY(v, m_editOrigin.y()); + sv_frame_t frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); + double heightDiff = getHeightForY(v, e->y()) - getHeightForY(v, m_editOrigin.y()); - long frame = m_originalPoint.frame + frameDiff; - float height = m_originalPoint.height + heightDiff; + sv_frame_t frame = m_originalPoint.frame + frameDiff; + double height = m_originalPoint.height + heightDiff; -// long 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 height = getHeightForY(v, e->y()); +// double height = getHeightForY(v, e->y()); if (!m_editingCommand) { m_editingCommand = new TextModel::EditCommand(m_model, tr("Drag Label")); @@ -565,7 +565,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.height = height; + m_editingPoint.height = float(height); m_editingCommand->addPoint(m_editingPoint); } @@ -621,7 +621,7 @@ } void -TextLayer::moveSelection(Selection s, int newStartFrame) +TextLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -665,9 +665,9 @@ if (s.contains(i->frame)) { - double target = i->frame; - target = newSize.getStartFrame() + - double(target - s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; TextModel::Point newPoint(*i); newPoint.frame = lrint(target); @@ -717,7 +717,7 @@ } bool -TextLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */) +TextLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -745,7 +745,7 @@ TextModel::EditCommand *command = new TextModel::EditCommand(m_model, tr("Paste")); - float valueMin = 0.0, valueMax = 1.0; + double valueMin = 0.0, valueMax = 1.0; for (Clipboard::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { if (i->haveValue()) { @@ -759,7 +759,7 @@ i != points.end(); ++i) { if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { @@ -778,9 +778,9 @@ TextModel::Point newPoint(frame); if (i->haveValue()) { - newPoint.height = (i->getValue() - valueMin) / (valueMax - valueMin); + newPoint.height = float((i->getValue() - valueMin) / (valueMax - valueMin)); } else { - newPoint.height = 0.5; + newPoint.height = 0.5f; } if (i->haveLabel()) { diff -r 28d05ae8741c -r 4a578a360011 layer/TimeInstantLayer.cpp --- a/layer/TimeInstantLayer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/TimeInstantLayer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -249,7 +249,7 @@ } bool -TimeInstantLayer::snapToFeatureFrame(View *v, int &frame, +TimeInstantLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -269,7 +269,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin(); @@ -666,7 +666,7 @@ } void -TimeInstantLayer::moveSelection(Selection s, int newStartFrame) +TimeInstantLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -712,9 +712,9 @@ if (s.contains(i->frame)) { - double target = i->frame; - target = newSize.getStartFrame() + - double(target - s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; SparseOneDimensionalModel::Point newPoint(*i); newPoint.frame = lrint(target); @@ -765,7 +765,7 @@ } bool -TimeInstantLayer::paste(View *v, const Clipboard &from, int frameOffset, bool) +TimeInstantLayer::paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool) { if (!m_model) return false; @@ -798,7 +798,7 @@ if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { diff -r 28d05ae8741c -r 4a578a360011 layer/TimeRulerLayer.cpp --- a/layer/TimeRulerLayer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/TimeRulerLayer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -49,7 +49,7 @@ } bool -TimeRulerLayer::snapToFeatureFrame(View *v, int &frame, +TimeRulerLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { if (!m_model) { @@ -60,7 +60,7 @@ bool q; int tick = getMajorTickSpacing(v, q); RealTime rtick = RealTime::fromMilliseconds(tick); - int rate = m_model->getSampleRate(); + sv_samplerate_t rate = m_model->getSampleRate(); RealTime rt = RealTime::frame2RealTime(frame, rate); double ratio = rt / rtick; @@ -68,9 +68,9 @@ int rounded = int(ratio); RealTime rdrt = rtick * rounded; - int left = RealTime::realTime2Frame(rdrt, rate); - resolution = RealTime::realTime2Frame(rtick, rate); - int right = left + resolution; + sv_frame_t left = RealTime::realTime2Frame(rdrt, rate); + resolution = int(RealTime::realTime2Frame(rtick, rate)); + sv_frame_t right = left + resolution; // SVDEBUG << "TimeRulerLayer::snapToFeatureFrame: type " // << int(snap) << ", frame " << frame << " (time " @@ -88,7 +88,7 @@ case SnapNearest: { - if (abs(frame - left) > abs(right - frame)) { + if (labs(frame - left) > labs(right - frame)) { frame = right; } else { frame = left; @@ -147,11 +147,11 @@ if (!m_model || !v) return 1000; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return 1000; - long startFrame = v->getStartFrame(); - long endFrame = v->getEndFrame(); + sv_frame_t startFrame = v->getStartFrame(); + sv_frame_t endFrame = v->getEndFrame(); int minPixelSpacing = 50; @@ -201,10 +201,10 @@ if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; - long startFrame = v->getFrameForX(rect.x() - 50); + sv_frame_t startFrame = v->getFrameForX(rect.x() - 50); #ifdef DEBUG_TIME_RULER_LAYER cerr << "start frame = " << startFrame << endl; @@ -213,7 +213,7 @@ bool quarter = false; int incms = getMajorTickSpacing(v, quarter); - int ms = lrint(1000.0 * (double(startFrame) / double(sampleRate))); + int ms = int(lrint(1000.0 * (double(startFrame) / double(sampleRate)))); ms = (ms / incms) * incms - incms; #ifdef DEBUG_TIME_RULER_LAYER @@ -226,8 +226,8 @@ // draw the actual ticks or lines. int minPixelSpacing = 50; - long incFrame = (incms * sampleRate) / 1000; - int incX = incFrame / v->getZoomLevel(); + sv_frame_t incFrame = lrint((incms * sampleRate) / 1000); + int incX = int(incFrame / v->getZoomLevel()); int ticks = 10; if (incX < minPixelSpacing * 2) { ticks = quarter ? 4 : 5; @@ -249,7 +249,7 @@ // re-drawing with a different start frame). double dms = ms; - long frame = lrint((dms * sampleRate) / 1000.0); + sv_frame_t frame = lrint((dms * sampleRate) / 1000.0); frame /= v->getZoomLevel(); frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel diff -r 28d05ae8741c -r 4a578a360011 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/TimeValueLayer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -329,7 +329,7 @@ } bool -TimeValueLayer::getValueExtents(float &min, float &max, +TimeValueLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; @@ -342,7 +342,7 @@ unit = getScaleUnits(); if (m_derivative) { - max = std::max(fabsf(min), fabsf(max)); + max = std::max(fabs(min), fabs(max)); min = -max; } @@ -356,7 +356,7 @@ max = max + 0.5; min = min - 0.5; } else { - float margin = (max - min) / 10.0; + double margin = (max - min) / 10.0; max = max + margin; min = min - margin; } @@ -370,7 +370,7 @@ } bool -TimeValueLayer::getDisplayExtents(float &min, float &max) const +TimeValueLayer::getDisplayExtents(double &min, double &max) const { if (!m_model || shouldAutoAlign()) return false; @@ -384,7 +384,7 @@ } if (m_derivative) { - max = std::max(fabsf(min), fabsf(max)); + max = std::max(fabs(min), fabs(max)); min = -max; } @@ -396,7 +396,7 @@ } bool -TimeValueLayer::setDisplayExtents(float min, float max) +TimeValueLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; @@ -438,7 +438,7 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return 0; - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); int nr = mapper->getPositionForValue(dmax - dmin); @@ -461,23 +461,23 @@ 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; #ifdef DEBUG_TIME_VALUE_LAYER @@ -485,7 +485,7 @@ #endif } else { - float dmid = (dmax + dmin) / 2; + double dmid = (dmax + dmin) / 2; newmin = dmid - newdist / 2; newmax = dmid + newdist / 2; } @@ -512,7 +512,7 @@ RangeMapper *mapper; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); @@ -533,7 +533,7 @@ { if (!m_model) return SparseTimeValueModel::PointList(); - long frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); SparseTimeValueModel::PointList onPoints = m_model->getPoints(frame); @@ -553,7 +553,7 @@ usePoints = nextPoints; } else if (nextPoints.empty()) { // stick with prevPoints - } else if (long(prevPoints.begin()->frame) < v->getStartFrame() && + } else if (prevPoints.begin()->frame < v->getStartFrame() && !(nextPoints.begin()->frame > v->getEndFrame())) { usePoints = nextPoints; } else if (nextPoints.begin()->frame - frame < @@ -602,7 +602,7 @@ } } - long useFrame = points.begin()->frame; + sv_frame_t useFrame = points.begin()->frame; RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); @@ -629,7 +629,7 @@ } bool -TimeValueLayer::snapToFeatureFrame(View *v, int &frame, +TimeValueLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -649,7 +649,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); @@ -701,7 +701,7 @@ } bool -TimeValueLayer::snapToSimilarFeature(View *v, int &frame, +TimeValueLayer::snapToSimilarFeature(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -716,8 +716,8 @@ SparseTimeValueModel::PointList::const_iterator i; - int matchframe = frame; - float matchvalue = 0.f; + sv_frame_t matchframe = frame; + double matchvalue = 0.0; for (i = close.begin(); i != close.end(); ++i) { if (i->frame > frame) break; @@ -725,10 +725,10 @@ matchframe = i->frame; } - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; bool distant = false; - float epsilon = 0.0001; + double epsilon = 0.0001; i = close.begin(); @@ -753,7 +753,7 @@ if (snap == SnapRight) { if (i->frame > matchframe && - fabsf(i->value - matchvalue) < epsilon) { + fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; break; @@ -762,7 +762,7 @@ } else if (snap == SnapLeft) { if (i->frame < matchframe) { - if (fabsf(i->value - matchvalue) < epsilon) { + if (fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; // don't break, as the next may be better } @@ -782,7 +782,7 @@ } void -TimeValueLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const +TimeValueLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -818,9 +818,9 @@ } int -TimeValueLayer::getYForValue(View *v, float val) const +TimeValueLayer::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(); @@ -838,16 +838,16 @@ return int(h - ((val - min) * h) / (max - min)); } -float +double TimeValueLayer::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 = LogRange::map(val); @@ -865,9 +865,9 @@ } QColor -TimeValueLayer::getColourForValue(View *v, float val) const +TimeValueLayer::getColourForValue(View *v, double val) const { - float min, max; + double min, max; bool log; getScaleExtents(v, min, max, log); @@ -900,7 +900,7 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; paint.setRenderHint(QPainter::Antialiasing, false); @@ -908,8 +908,8 @@ // Profiler profiler("TimeValueLayer::paint", true); int x0 = rect.left(), x1 = rect.right(); - long frame0 = v->getFrameForX(x0); - long frame1 = v->getFrameForX(x1); + sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t frame1 = v->getFrameForX(x1); if (m_derivative) --frame0; SparseTimeValueModel::PointList points(m_model->getPoints @@ -927,15 +927,15 @@ << m_model->getResolution() << " frames" << endl; #endif - 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; int origin = int(nearbyint(v->height() - (-min * v->height()) / (max - min))); QPoint localPos; - long illuminateFrame = -1; + sv_frame_t illuminateFrame = -1; if (v->shouldIlluminateLocalFeatures(this, localPos)) { SparseTimeValueModel::PointList localPoints = @@ -974,7 +974,7 @@ } } - int prevFrame = 0; + sv_frame_t prevFrame = 0; for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -983,7 +983,7 @@ const SparseTimeValueModel::Point &p(*i); - float value = p.value; + double value = p.value; if (m_derivative) { SparseTimeValueModel::PointList::const_iterator j = i; --j; @@ -1012,8 +1012,8 @@ } bool haveNext = false; - float nvalue = 0.f; - int nf = v->getModelsEndFrame(); + double nvalue = 0.f; + sv_frame_t nf = v->getModelsEndFrame(); int nx = v->getXForFrame(nf); int ny = y; @@ -1122,11 +1122,11 @@ } else { - float x0 = x + float(w)/2; - float x1 = nx + float(w)/2; + double x0 = x + double(w)/2; + double x1 = nx + double(w)/2; - float y0 = y; - float y1 = ny; + double y0 = y; + double y1 = ny; if (m_plotStyle == PlotDiscreteCurves) { bool nextGap = @@ -1255,7 +1255,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); @@ -1310,12 +1310,12 @@ if (!m_model) return; - long frame = v->getFrameForX(e->x()); - long resolution = m_model->getResolution(); + sv_frame_t frame = v->getFrameForX(e->x()); + int resolution = m_model->getResolution(); if (frame < 0) frame = 0; frame = (frame / resolution) * resolution; - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); bool havePoint = false; @@ -1336,7 +1336,7 @@ if (!havePoint) { m_editingPoint = SparseTimeValueModel::Point - (frame, value, tr("New Point")); + (frame, float(value), tr("New Point")); } m_originalPoint = m_editingPoint; @@ -1360,12 +1360,12 @@ if (!m_model || !m_editing) return; - long frame = v->getFrameForX(e->x()); - long resolution = m_model->getResolution(); + sv_frame_t frame = v->getFrameForX(e->x()); + int resolution = m_model->getResolution(); if (frame < 0) frame = 0; frame = (frame / resolution) * resolution; - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); @@ -1409,7 +1409,7 @@ // m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.value = value; + m_editingPoint.value = float(value); m_editingCommand->addPoint(m_editingPoint); } @@ -1502,11 +1502,11 @@ if (!m_model || !m_editing) return; - long 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()); if (!m_editingCommand) { m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, @@ -1515,7 +1515,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.value = value; + m_editingPoint.value = float(value); m_editingCommand->addPoint(m_editingPoint); } @@ -1589,7 +1589,7 @@ } void -TimeValueLayer::moveSelection(Selection s, int newStartFrame) +TimeValueLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -1635,9 +1635,9 @@ if (s.contains(i->frame)) { - double target = i->frame; - target = newSize.getStartFrame() + - double(target - s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; SparseTimeValueModel::Point newPoint(*i); newPoint.frame = lrint(target); @@ -1691,7 +1691,7 @@ } bool -TimeValueLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, +TimeValueLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool interactive) { if (!m_model) return false; @@ -1834,7 +1834,7 @@ if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { diff -r 28d05ae8741c -r 4a578a360011 layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/WaveformLayer.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -153,7 +153,7 @@ *max = 50; *deflt = 0; - val = lrint(log10(m_gain) * 20.0); + val = int(lrint(log10(m_gain) * 20.0)); if (val < *min) val = *min; if (val > *max) val = *max; @@ -222,7 +222,7 @@ WaveformLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(pow(10, float(value)/20.0)); + setGain(float(pow(10, float(value)/20.0))); } else if (name == "Normalize Visible Area") { setAutoNormalize(value ? true : false); } else if (name == "Channels") { @@ -308,7 +308,7 @@ } void -WaveformLayer::setMiddleLineHeight(float height) +WaveformLayer::setMiddleLineHeight(double height) { if (m_middleLineHeight == height) return; m_middleLineHeight = height; @@ -335,7 +335,7 @@ } bool -WaveformLayer::getValueExtents(float &min, float &max, +WaveformLayer::getValueExtents(double &min, double &max, bool &, QString &unit) const { if (m_scale == LinearScale) { @@ -353,10 +353,10 @@ } int -WaveformLayer::dBscale(float sample, int m) const +WaveformLayer::dBscale(double sample, int m) const { if (sample < 0.0) return dBscale(-sample, m); - float dB = AudioLevel::multiplier_to_dB(sample); + double dB = AudioLevel::multiplier_to_dB(sample); if (dB < -50.0) return 0; if (dB > 0.0) return m; return int(((dB + 50.0) * m) / 50.0 + 0.1); @@ -409,9 +409,9 @@ bool WaveformLayer::getSourceFramesForX(View *v, int x, int modelZoomLevel, - int &f0, int &f1) const + sv_frame_t &f0, sv_frame_t &f1) const { - int viewFrame = v->getFrameForX(x); + sv_frame_t viewFrame = v->getFrameForX(x); if (viewFrame < 0) { f0 = 0; f1 = 0; @@ -435,13 +435,13 @@ float WaveformLayer::getNormalizeGain(View *v, int channel) const { - int startFrame = v->getStartFrame(); - int endFrame = v->getEndFrame(); + sv_frame_t startFrame = v->getStartFrame(); + sv_frame_t endFrame = v->getEndFrame(); - int modelStart = m_model->getStartFrame(); - int modelEnd = m_model->getEndFrame(); + sv_frame_t modelStart = m_model->getStartFrame(); + sv_frame_t modelEnd = m_model->getEndFrame(); - int rangeStart, rangeEnd; + sv_frame_t rangeStart, rangeEnd; if (startFrame < modelStart) rangeStart = modelStart; else rangeStart = startFrame; @@ -469,7 +469,7 @@ range.setAbsmean(std::min(range.absmean(), otherRange.absmean())); } - return 1.0 / std::max(fabsf(range.max()), fabsf(range.min())); + return float(1.0 / std::max(fabs(range.max()), fabs(range.min()))); } void @@ -543,9 +543,9 @@ if (m_middleLineHeight != 0.5) { paint->save(); - float space = m_middleLineHeight * 2; + double space = m_middleLineHeight * 2; if (space > 1.0) space = 2.0 - space; - float yt = h * (m_middleLineHeight - space/2); + double yt = h * (m_middleLineHeight - space/2); paint->translate(QPointF(0, yt)); paint->scale(1.0, space); } @@ -572,9 +572,9 @@ int modelZoomLevel = m_model->getSummaryBlockSize(zoomLevel); - int frame0; - int frame1; - int spare; + sv_frame_t frame0; + sv_frame_t frame1; + sv_frame_t spare; getSourceFramesForX(v, x0, modelZoomLevel, frame0, spare); getSourceFramesForX(v, x1, modelZoomLevel, spare, frame1); @@ -616,7 +616,7 @@ m_effectiveGains[ch] = getNormalizeGain(v, ch); } - float gain = m_effectiveGains[ch]; + double gain = m_effectiveGains[ch]; int m = (h / channels) / 2; int my = m + (((ch - minChannel) * h) / channels); @@ -647,7 +647,7 @@ for (int i = 1; i < n; ++i) { - float val = 0.0, nval = 0.0; + double val = 0.0, nval = 0.0; switch (m_scale) { @@ -710,7 +710,7 @@ range = RangeSummarisableTimeValueModel::Range(); - int f0, f1; + sv_frame_t f0, f1; if (!getSourceFramesForX(v, x, modelZoomLevel, f0, f1)) continue; f1 = f1 - 1; @@ -719,8 +719,8 @@ continue; } - int i0 = (f0 - frame0) / modelZoomLevel; - int i1 = (f1 - frame0) / modelZoomLevel; + sv_frame_t i0 = (f0 - frame0) / modelZoomLevel; + sv_frame_t i1 = (f1 - frame0) / modelZoomLevel; #ifdef DEBUG_WAVEFORM_PAINT cerr << "WaveformLayer::paint: pixel " << x << ": i0 " << i0 << " (f " << f0 << "), i1 " << i1 << " (f " << f1 << ")" << endl; @@ -784,10 +784,10 @@ switch (m_scale) { case LinearScale: - rangeBottom = int( m * greyLevels * range.min() * gain); - rangeTop = int( m * greyLevels * range.max() * gain); - meanBottom = int(-m * range.absmean() * gain); - meanTop = int( m * range.absmean() * gain); + rangeBottom = int(double(m * greyLevels) * range.min() * gain); + rangeTop = int(double(m * greyLevels) * range.max() * gain); + meanBottom = int(double(-m) * range.absmean() * gain); + meanTop = int(double(m) * range.absmean() * gain); break; case dBScale: @@ -963,7 +963,7 @@ int modelZoomLevel = m_model->getSummaryBlockSize(zoomLevel); - int f0, f1; + sv_frame_t f0, f1; if (!getSourceFramesForX(v, x, modelZoomLevel, f0, f1)) return ""; QString text; @@ -1005,18 +1005,18 @@ } bool singleValue = false; - float min, max; + double min, max; if (fabs(range.min()) < 0.01) { min = range.min(); max = range.max(); singleValue = (min == max); } else { - int imin = lrint(range.min() * 10000); - int imax = lrint(range.max() * 10000); + int imin = int(lrint(range.min() * 10000)); + int imax = int(lrint(range.max() * 10000)); singleValue = (imin == imax); - min = float(imin)/10000; - max = float(imax)/10000; + min = double(imin)/10000; + max = double(imax)/10000; } int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min()), @@ -1025,10 +1025,10 @@ if (!singleValue) { text += tr("\n%1\t%2 - %3 (%4 dB peak)") - .arg(label).arg(min).arg(max).arg(float(db)/100); + .arg(label).arg(min).arg(max).arg(double(db)/100); } else { text += tr("\n%1\t%2 (%3 dB peak)") - .arg(label).arg(min).arg(float(db)/100); + .arg(label).arg(min).arg(double(db)/100); } } @@ -1036,7 +1036,7 @@ } int -WaveformLayer::getYForValue(const View *v, float value, int channel) const +WaveformLayer::getYForValue(const View *v, double value, int channel) const { int channels = 0, minChannel = 0, maxChannel = 0; bool mergingChannels = false, mixingChannels = false; @@ -1078,7 +1078,7 @@ return my - vy; } -float +double WaveformLayer::getValueForY(const View *v, int y, int &channel) const { int channels = 0, minChannel = 0, maxChannel = 0; @@ -1102,13 +1102,13 @@ int my = m + (((channel - minChannel) * h) / channels); int vy = my - y; - float value = 0; - float thresh = -50.f; + double value = 0; + double thresh = -50.f; switch (m_scale) { case LinearScale: - value = float(vy) / m; + value = double(vy) / m; break; case MeterScale: @@ -1116,7 +1116,7 @@ break; case dBScale: - value = (-thresh * float(vy)) / m + thresh; + value = (-thresh * double(vy)) / m + thresh; value = AudioLevel::dB_to_multiplier(value); break; } @@ -1126,7 +1126,7 @@ bool WaveformLayer::getYScaleValue(const View *v, int y, - float &value, QString &unit) const + double &value, QString &unit) const { int channel; @@ -1134,10 +1134,10 @@ if (m_scale == dBScale || m_scale == MeterScale) { - float thresh = -50.f; + double thresh = -50.f; - if (value > 0.f) { - value = 10.f * log10f(value); + if (value > 0.0) { + value = 10.0 * log10(value); if (value < thresh) value = thresh; } else value = thresh; @@ -1152,36 +1152,36 @@ bool WaveformLayer::getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const + double &diff, QString &unit) const { int c0, c1; - float v0 = getValueForY(v, y0, c0); - float v1 = getValueForY(v, y1, c1); + double v0 = getValueForY(v, y0, c0); + double v1 = getValueForY(v, y1, c1); if (c0 != c1) { // different channels, not comparable - diff = 0.f; + diff = 0.0; unit = ""; return false; } if (m_scale == dBScale || m_scale == MeterScale) { - float thresh = -50.f; + double thresh = -50.0; if (v1 == v0) diff = thresh; else { if (v1 > v0) diff = v0 / v1; else diff = v1 / v0; - diff = 10.f * log10f(diff); + diff = 10.0 * log10(diff); if (diff < thresh) diff = thresh; } unit = "dBV"; } else { - diff = fabsf(v1 - v0); + diff = fabs(v1 - v0); unit = "V"; } @@ -1217,7 +1217,7 @@ int textHeight = paint.fontMetrics().height(); int toff = -textHeight/2 + paint.fontMetrics().ascent() + 1; - float gain = m_gain; + double gain = m_gain; for (int ch = minChannel; ch <= maxChannel; ++ch) { @@ -1229,14 +1229,14 @@ for (int i = 0; i <= n; ++i) { - float val = 0.0, nval = 0.0; + double val = 0.0, nval = 0.0; QString text = ""; switch (m_scale) { case LinearScale: val = (i * gain) / n; - text = QString("%1").arg(float(i) / n); + text = QString("%1").arg(double(i) / n); if (i == 0) text = "0.0"; else { nval = -val; @@ -1402,7 +1402,7 @@ int WaveformLayer::getCurrentVerticalZoomStep() const { - int val = lrint(log10(m_gain) * 20.0) + 50; + int val = int(lrint(log10(m_gain) * 20.0) + 50); if (val < 0) val = 0; if (val > 100) val = 100; return val; @@ -1411,6 +1411,6 @@ void WaveformLayer::setVerticalZoomStep(int step) { - setGain(pow(10, float(step - 50) / 20.0)); + setGain(powf(10, float(step - 50) / 20.f)); } diff -r 28d05ae8741c -r 4a578a360011 layer/WaveformLayer.h --- a/layer/WaveformLayer.h Tue Mar 10 10:31:27 2015 +0000 +++ b/layer/WaveformLayer.h Tue Mar 10 13:22:10 2015 +0000 @@ -203,7 +203,7 @@ virtual void setVerticalZoomStep(int); protected: - int dBscale(float sample, int m) const; + int dBscale(double sample, int m) const; const RangeSummarisableTimeValueModel *m_model; // I do not own this @@ -216,7 +216,7 @@ double getValueForY(const View *v, int y, int &channel) const; bool getSourceFramesForX(View *v, int x, int modelZoomLevel, - int &f0, int &f1) const; + sv_frame_t &f0, sv_frame_t &f1) const; float getNormalizeGain(View *v, int channel) const; diff -r 28d05ae8741c -r 4a578a360011 view/Overview.cpp --- a/view/Overview.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/view/Overview.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -38,12 +38,12 @@ } void -Overview::modelChangedWithin(int startFrame, int endFrame) +Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { bool zoomChanged = false; - int frameCount = getModelsEndFrame() - getModelsStartFrame(); - int zoomLevel = frameCount / width(); + sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); + int zoomLevel = int(frameCount / width()); if (zoomLevel < 1) zoomLevel = 1; zoomLevel = getZoomConstraintBlockSize(zoomLevel, ZoomConstraint::RoundUp); @@ -91,7 +91,7 @@ } void -Overview::globalCentreFrameChanged(int +Overview::globalCentreFrameChanged(sv_frame_t #ifdef DEBUG_OVERVIEW f #endif @@ -104,7 +104,7 @@ } void -Overview::viewCentreFrameChanged(View *v, int +Overview::viewCentreFrameChanged(View *v, sv_frame_t #ifdef DEBUG_OVERVIEW f #endif @@ -128,7 +128,7 @@ } void -Overview::viewManagerPlaybackFrameChanged(int f) +Overview::viewManagerPlaybackFrameChanged(sv_frame_t f) { #ifdef DEBUG_OVERVIEW cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl; @@ -153,9 +153,9 @@ cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; #endif - int startFrame = getModelsStartFrame(); - int frameCount = getModelsEndFrame() - getModelsStartFrame(); - int zoomLevel = frameCount / width(); + sv_frame_t startFrame = getModelsStartFrame(); + sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); + int zoomLevel = int(frameCount / width()); if (zoomLevel < 1) zoomLevel = 1; zoomLevel = getZoomConstraintBlockSize(zoomLevel, ZoomConstraint::RoundUp); @@ -164,7 +164,7 @@ emit zoomLevelChanged(m_zoomLevel, m_followZoom); } - int centreFrame = startFrame + m_zoomLevel * (width() / 2); + sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2); if (centreFrame > (startFrame + getModelsEndFrame())/2) { centreFrame = (startFrame + getModelsEndFrame())/2; } @@ -196,23 +196,23 @@ int y = 0; - int prevx0 = -10; - int prevx1 = -10; + sv_frame_t prevx0 = -10; + sv_frame_t prevx1 = -10; for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { if (!*i) continue; View *w = (View *)*i; - int f0 = w->getFrameForX(0); - int f1 = w->getFrameForX(w->width()); + sv_frame_t f0 = w->getFrameForX(0); + sv_frame_t f1 = w->getFrameForX(w->width()); if (f0 >= 0) { - int rf0 = w->alignToReference(f0); + sv_frame_t rf0 = w->alignToReference(f0); f0 = alignFromReference(rf0); } if (f1 >= 0) { - int rf1 = w->alignToReference(f1); + sv_frame_t rf1 = w->alignToReference(f1); f1 = alignFromReference(rf1); } @@ -237,7 +237,7 @@ Overview::mousePressEvent(QMouseEvent *e) { m_clickPos = e->pos(); - int clickFrame = getFrameForX(m_clickPos.x()); + sv_frame_t clickFrame = getFrameForX(m_clickPos.x()); if (clickFrame > 0) m_dragCentreFrame = clickFrame; else m_dragCentreFrame = 0; m_clickedInRange = true; @@ -265,12 +265,12 @@ if (!m_clickedInRange) return; int xoff = int(e->x()) - int(m_clickPos.x()); - int frameOff = xoff * m_zoomLevel; + sv_frame_t frameOff = xoff * m_zoomLevel; - int newCentreFrame = m_dragCentreFrame; + sv_frame_t newCentreFrame = m_dragCentreFrame; if (frameOff > 0) { newCentreFrame += frameOff; - } else if (newCentreFrame >= int(-frameOff)) { + } else if (newCentreFrame >= -frameOff) { newCentreFrame += frameOff; } else { newCentreFrame = 0; @@ -282,8 +282,8 @@ } if (std::max(m_centreFrame, newCentreFrame) - - std::min(m_centreFrame, newCentreFrame) > int(m_zoomLevel)) { - int rf = alignToReference(newCentreFrame); + std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { + sv_frame_t rf = alignToReference(newCentreFrame); #ifdef DEBUG_OVERVIEW cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; #endif @@ -299,8 +299,8 @@ void Overview::mouseDoubleClickEvent(QMouseEvent *e) { - int frame = getFrameForX(e->x()); - int rf = 0; + sv_frame_t frame = getFrameForX(e->x()); + sv_frame_t rf = 0; if (frame > 0) rf = alignToReference(frame); #ifdef DEBUG_OVERVIEW cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl; diff -r 28d05ae8741c -r 4a578a360011 view/Overview.h --- a/view/Overview.h Tue Mar 10 10:31:27 2015 +0000 +++ b/view/Overview.h Tue Mar 10 13:22:10 2015 +0000 @@ -41,13 +41,13 @@ virtual QString getPropertyContainerIconName() const { return "panner"; } public slots: - virtual void modelChangedWithin(int startFrame, int endFrame); + virtual void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); virtual void modelReplaced(); - virtual void globalCentreFrameChanged(int); - virtual void viewCentreFrameChanged(View *, int); + virtual void globalCentreFrameChanged(sv_frame_t); + virtual void viewCentreFrameChanged(View *, sv_frame_t); virtual void viewZoomLevelChanged(View *, int, bool); - virtual void viewManagerPlaybackFrameChanged(int); + virtual void viewManagerPlaybackFrameChanged(sv_frame_t); protected: virtual void paintEvent(QPaintEvent *e); @@ -62,7 +62,7 @@ QPoint m_clickPos; QPoint m_mousePos; bool m_clickedInRange; - int m_dragCentreFrame; + sv_frame_t m_dragCentreFrame; QTime m_modelTestTime; typedef std::set ViewSet; diff -r 28d05ae8741c -r 4a578a360011 view/Pane.cpp --- a/view/Pane.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/view/Pane.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -143,7 +143,7 @@ m_hthumb->setFixedWidth(70); m_hthumb->setFixedHeight(16); m_hthumb->setDefaultValue(0); - m_hthumb->setSpeed(0.6); + m_hthumb->setSpeed(0.6f); connect(m_hthumb, SIGNAL(valueChanged(int)), this, SLOT(horizontalThumbwheelMoved(int))); connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); @@ -320,12 +320,12 @@ return; } - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax) && vmax != vmin) { - float y0 = (dmin - vmin) / (vmax - vmin); - float y1 = (dmax - vmin) / (vmax - vmin); + double y0 = (dmin - vmin) / (vmax - vmin); + double y1 = (dmax - vmin) / (vmax - vmin); m_vpan->blockSignals(true); - m_vpan->setRectExtents(0, 1.0 - y1, 1, y1 - y0); + m_vpan->setRectExtents(0, float(1.0 - y1), 1, float(y1 - y0)); m_vpan->blockSignals(false); m_vpan->show(); } else { @@ -483,7 +483,7 @@ drawFeatureDescription(topLayer, paint); } - int sampleRate = getModelsSampleRate(); + sv_samplerate_t sampleRate = getModelsSampleRate(); paint.setBrush(Qt::NoBrush); if (m_centreLineVisible && @@ -560,7 +560,7 @@ { Layer *scaleLayer = 0; - float min, max; + double min, max; bool log; QString unit; @@ -714,7 +714,7 @@ } void -Pane::drawCentreLine(int sampleRate, QPainter &paint, bool omitLine) +Pane::drawCentreLine(sv_samplerate_t sampleRate, QPainter &paint, bool omitLine) { int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); @@ -969,7 +969,7 @@ { int offset = m_mousePos.x() - m_clickPos.x(); - int origStart = m_editingSelection.getStartFrame(); + sv_frame_t origStart = m_editingSelection.getStartFrame(); int p0 = getXForFrame(origStart) + offset; int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; @@ -980,15 +980,15 @@ p0 = getXForFrame(m_editingSelection.getStartFrame()); } - int newStart = getFrameForX(p0); - int newEnd = getFrameForX(p1); + sv_frame_t newStart = getFrameForX(p0); + sv_frame_t newEnd = getFrameForX(p1); paint.save(); paint.setPen(QPen(getForeground(), 2)); int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); - int sampleRate = getModelsSampleRate(); + sv_samplerate_t sampleRate = getModelsSampleRate(); QString startText, endText, offsetText; startText = QString("%1").arg(newStart); endText = QString("%1").arg(newEnd); @@ -1037,17 +1037,17 @@ void Pane::drawDurationAndRate(QRect r, const Model *waveformModel, - int sampleRate, QPainter &paint) + sv_samplerate_t sampleRate, QPainter &paint) { int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); if (r.y() + r.height() < height() - fontHeight - 6) return; - int modelRate = waveformModel->getSampleRate(); - int nativeRate = waveformModel->getNativeRate(); - int playbackRate = m_manager->getPlaybackSampleRate(); - int outputRate = m_manager->getOutputSampleRate(); + sv_samplerate_t modelRate = waveformModel->getSampleRate(); + sv_samplerate_t nativeRate = waveformModel->getNativeRate(); + sv_samplerate_t playbackRate = m_manager->getPlaybackSampleRate(); + sv_samplerate_t outputRate = m_manager->getOutputSampleRate(); QString srNote = ""; @@ -1086,7 +1086,7 @@ } bool -Pane::render(QPainter &paint, int xorigin, int f0, int f1) +Pane::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) { if (!View::render(paint, xorigin + m_scaleWidth, f0, f1)) { return false; @@ -1117,10 +1117,10 @@ } QImage * -Pane::toNewImage(int f0, int f1) +Pane::toNewImage(sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / getZoomLevel(); - int x1 = f1 / getZoomLevel(); + int x0 = int(f0 / getZoomLevel()); + int x1 = int(f1 / getZoomLevel()); QImage *image = new QImage(x1 - x0 + m_scaleWidth, height(), QImage::Format_RGB32); @@ -1156,7 +1156,7 @@ } QSize -Pane::getImageSize(int f0, int f1) +Pane::getImageSize(sv_frame_t f0, sv_frame_t f1) { QSize s = View::getImageSize(f0, f1); QImage *image = new QImage(100, 100, QImage::Format_RGB32); @@ -1174,12 +1174,12 @@ return QSize(sw + s.width(), s.height()); } -int +sv_frame_t Pane::getFirstVisibleFrame() const { - int f0 = getFrameForX(m_scaleWidth); - int f = View::getFirstVisibleFrame(); - if (f0 < 0 || f0 < long(f)) return f; + sv_frame_t f0 = getFrameForX(m_scaleWidth); + sv_frame_t f = View::getFirstVisibleFrame(); + if (f0 < 0 || f0 < f) return f; return f0; } @@ -1190,10 +1190,10 @@ if (!m_manager) return Selection(); - int testFrame = getFrameForX(x - 5); + sv_frame_t testFrame = getFrameForX(x - 5); if (testFrame < 0) { - testFrame = getFrameForX(x); - if (testFrame < 0) return Selection(); + testFrame = getFrameForX(x); + if (testFrame < 0) return Selection(); } Selection selection = m_manager->getContainingSelection(testFrame, true); @@ -1219,15 +1219,15 @@ bool Pane::canTopLayerMoveVertical() { - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return false; if (dmin <= vmin && dmax >= vmax) return false; return true; } bool -Pane::getTopLayerDisplayExtents(float &vmin, float &vmax, - float &dmin, float &dmax, +Pane::getTopLayerDisplayExtents(double &vmin, double &vmax, + double &dmin, double &dmax, QString *unit) { Layer *layer = getTopLayer(); @@ -1241,7 +1241,7 @@ } bool -Pane::setTopLayerDisplayExtents(float dmin, float dmax) +Pane::setTopLayerDisplayExtents(double dmin, double dmax) { Layer *layer = getTopLayer(); if (!layer) return false; @@ -1327,7 +1327,7 @@ m_dragCentreFrame = m_centreFrame; m_dragStartMinValue = 0; - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { m_dragStartMinValue = dmin; } @@ -1362,9 +1362,9 @@ } else { - int mouseFrame = getFrameForX(e->x()); + sv_frame_t mouseFrame = getFrameForX(e->x()); int resolution = 1; - int snapFrame = mouseFrame; + sv_frame_t snapFrame = mouseFrame; Layer *layer = getInteractionLayer(); if (layer && !m_shiftPressed) { @@ -1433,7 +1433,7 @@ } void -Pane::schedulePlaybackFrameMove(int frame) +Pane::schedulePlaybackFrameMove(sv_frame_t frame) { m_playbackFrameMoveTo = frame; m_playbackFrameMoveScheduled = true; @@ -1468,7 +1468,7 @@ mouseMoveEvent(e); } - int mouseFrame = e ? getFrameForX(e->x()) : 0; + sv_frame_t mouseFrame = e ? getFrameForX(e->x()) : 0; if (mouseFrame < 0) mouseFrame = 0; if (m_navigating || mode == ViewManager::NavigateMode) { @@ -1854,18 +1854,18 @@ int w = x1 - x0; - int newStartFrame = getFrameForX(x0); + sv_frame_t newStartFrame = getFrameForX(x0); - int visibleFrames = getEndFrame() - getStartFrame(); + sv_frame_t visibleFrames = getEndFrame() - getStartFrame(); if (newStartFrame <= -visibleFrames) { newStartFrame = -visibleFrames + 1; } - if (newStartFrame >= long(getModelsEndFrame())) { + if (newStartFrame >= getModelsEndFrame()) { newStartFrame = getModelsEndFrame() - 1; } - float ratio = float(w) / float(width()); + double ratio = double(w) / double(width()); // cerr << "ratio: " << ratio << endl; int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); if (newZoomLevel < 1) newZoomLevel = 1; @@ -1875,7 +1875,7 @@ setStartFrame(newStartFrame); QString unit; - float min, max; + double min, max; bool log; Layer *layer = 0; for (LayerList::const_iterator i = m_layerStack.begin(); @@ -1889,15 +1889,15 @@ if (layer) { if (log) { - min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min); - max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max); + min = (min < 0.0) ? -log10(-min) : (min == 0.0) ? 0.0 : log10(min); + max = (max < 0.0) ? -log10(-max) : (max == 0.0) ? 0.0 : log10(max); } - float rmin = min + ((max - min) * (height() - y1)) / height(); - float rmax = min + ((max - min) * (height() - y0)) / height(); + double rmin = min + ((max - min) * (height() - y1)) / height(); + double rmax = min + ((max - min) * (height() - y0)) / height(); cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << endl; if (log) { - rmin = powf(10, rmin); - rmax = powf(10, rmax); + rmin = pow(10, rmin); + rmax = pow(10, rmax); } cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << endl; @@ -1946,8 +1946,8 @@ if (m_dragMode == HorizontalDrag || m_dragMode == FreeDrag) { - int frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); - int newCentreFrame = m_dragCentreFrame; + sv_frame_t frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); + sv_frame_t newCentreFrame = m_dragCentreFrame; if (frameOff < 0) { newCentreFrame -= frameOff; @@ -1975,24 +1975,24 @@ if (m_dragMode == VerticalDrag || m_dragMode == FreeDrag) { - float vmin = 0.f, vmax = 0.f; - float dmin = 0.f, dmax = 0.f; + double vmin = 0.f, vmax = 0.f; + double dmin = 0.f, dmax = 0.f; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { // cerr << "ydiff = " << ydiff << endl; int ydiff = e->y() - m_clickPos.y(); - float perpix = (dmax - dmin) / height(); - float valdiff = ydiff * perpix; + double perpix = (dmax - dmin) / height(); + double valdiff = ydiff * perpix; // cerr << "valdiff = " << valdiff << endl; if (m_dragMode == UnresolvedDrag && ydiff != 0) { m_dragMode = VerticalDrag; } - float newmin = m_dragStartMinValue + valdiff; - float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; + double newmin = m_dragStartMinValue + valdiff; + double newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; if (newmin < vmin) { newmax += vmin - newmin; newmin += vmin - newmin; @@ -2077,10 +2077,10 @@ void Pane::dragExtendSelection(QMouseEvent *e) { - int mouseFrame = getFrameForX(e->x()); + sv_frame_t mouseFrame = getFrameForX(e->x()); int resolution = 1; - int snapFrameLeft = mouseFrame; - int snapFrameRight = mouseFrame; + sv_frame_t snapFrameLeft = mouseFrame; + sv_frame_t snapFrameRight = mouseFrame; Layer *layer = getInteractionLayer(); if (layer && !m_shiftPressed) { @@ -2095,7 +2095,7 @@ if (snapFrameLeft < 0) snapFrameLeft = 0; if (snapFrameRight < 0) snapFrameRight = 0; - int min, max; + sv_frame_t min, max; if (m_selectionStartFrame > snapFrameLeft) { min = snapFrameLeft; @@ -2126,7 +2126,7 @@ void Pane::edgeScrollMaybe(int x) { - int mouseFrame = getFrameForX(x); + sv_frame_t mouseFrame = getFrameForX(x); bool doScroll = false; if (!m_manager) doScroll = true; @@ -2135,14 +2135,14 @@ if (m_followPlay != PlaybackScrollContinuous) doScroll = true; if (doScroll) { - int offset = mouseFrame - getStartFrame(); - int available = getEndFrame() - getStartFrame(); - int move = 0; - if (offset >= available * 0.95) { - move = int(offset - available * 0.95) + 1; - } else if (offset <= available * 0.10) { - move = int(available * 0.10 - offset) + 1; - move = -move; + sv_frame_t offset = mouseFrame - getStartFrame(); + sv_frame_t available = getEndFrame() - getStartFrame(); + sv_frame_t move = 0; + if (offset >= double(available) * 0.95) { + move = sv_frame_t(double(offset - available) * 0.95) + 1; + } else if (offset <= double(available) * 0.10) { + move = sv_frame_t(double(available) * 0.10 - double(offset)) + 1; + move = -move; } if (move != 0) { setCentreFrame(m_centreFrame + move); @@ -2199,7 +2199,7 @@ if (relocate) { - int f = getFrameForX(e->x()); + sv_frame_t f = getFrameForX(e->x()); setCentreFrame(f); @@ -2207,7 +2207,7 @@ m_dragStartMinValue = 0; m_dragMode = UnresolvedDrag; - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { m_dragStartMinValue = dmin; } @@ -2468,11 +2468,11 @@ void Pane::verticalPannerMoved(float , float y0, float , float h) { - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; - float y1 = y0 + h; - float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); - float newmin = vmin + ((1.0 - y1) * (vmax - vmin)); + double y1 = y0 + h; + double newmax = vmin + ((1.0 - y0) * (vmax - vmin)); + double newmin = vmin + ((1.0 - y1) * (vmax - vmin)); // cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w // << "," << h << ") -> (" << newmin << "," << newmax << ")" << endl; setTopLayerDisplayExtents(newmin, newmax); @@ -2483,7 +2483,7 @@ { if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return; - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; QString unit; if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax, &unit) || vmax == vmin) { @@ -2493,12 +2493,13 @@ RangeInputDialog dialog(tr("Enter new range"), tr("New vertical display range, from %1 to %2 %4:") .arg(vmin).arg(vmax).arg(unit), - unit, vmin, vmax, this); - dialog.setRange(dmin, dmax); + unit, float(vmin), float(vmax), this); + dialog.setRange(float(dmin), float(dmax)); if (dialog.exec() == QDialog::Accepted) { - dialog.getRange(dmin, dmax); - setTopLayerDisplayExtents(dmin, dmax); + float newmin, newmax; + dialog.getRange(newmin, newmax); + setTopLayerDisplayExtents(newmin, newmax); updateVerticalPanner(); } } @@ -2604,8 +2605,8 @@ int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; - int f0 = getFrameForX(p0); - int f1 = getFrameForX(p1); + sv_frame_t f0 = getFrameForX(p0); + sv_frame_t f1 = getFrameForX(p1); Selection newSelection(f0, f1); diff -r 28d05ae8741c -r 4a578a360011 view/Pane.h --- a/view/Pane.h Tue Mar 10 10:31:27 2015 +0000 +++ b/view/Pane.h Tue Mar 10 13:22:10 2015 +0000 @@ -48,13 +48,13 @@ void setCentreLineVisible(bool visible); bool getCentreLineVisible() const { return m_centreLineVisible; } - virtual int getFirstVisibleFrame() const; + virtual sv_frame_t getFirstVisibleFrame() const; virtual int getVerticalScaleWidth() const; - virtual QImage *toNewImage(int f0, int f1); + virtual QImage *toNewImage(sv_frame_t f0, sv_frame_t f1); virtual QImage *toNewImage() { return View::toNewImage(); } - virtual QSize getImageSize(int f0, int f1); + virtual QSize getImageSize(sv_frame_t f0, sv_frame_t f1); virtual QSize getImageSize() { return View::getImageSize(); } virtual void toXml(QTextStream &stream, QString indent = "", @@ -73,7 +73,7 @@ void rightButtonMenuRequested(QPoint position); void dropAccepted(QStringList uriList); void dropAccepted(QString text); - void doubleClickSelectInvoked(int frame); + void doubleClickSelectInvoked(sv_frame_t frame); void regionOutlined(QRect rect); public slots: @@ -119,15 +119,15 @@ void drawVerticalScale(QRect r, Layer *, QPainter &); void drawFeatureDescription(Layer *, QPainter &); - void drawCentreLine(int, QPainter &, bool omitLine); + void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine); void drawModelTimeExtents(QRect, QPainter &, const Model *); - void drawDurationAndRate(QRect, const Model *, int, QPainter &); + void drawDurationAndRate(QRect, const Model *, sv_samplerate_t, QPainter &); void drawWorkTitle(QRect, QPainter &, const Model *); void drawLayerNames(QRect, QPainter &); void drawEditingSelection(QPainter &); void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down); - virtual bool render(QPainter &paint, int x0, int f0, int f1); + virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const; @@ -140,10 +140,10 @@ void updateVerticalPanner(); bool canTopLayerMoveVertical(); - bool getTopLayerDisplayExtents(float &valueMin, float &valueMax, - float &displayMin, float &displayMax, + bool getTopLayerDisplayExtents(double &valueMin, double &valueMax, + double &displayMin, double &displayMax, QString *unit = 0); - bool setTopLayerDisplayExtents(float displayMin, float displayMax); + bool setTopLayerDisplayExtents(double displayMin, double displayMax); void dragTopLayer(QMouseEvent *e); void dragExtendSelection(QMouseEvent *e); @@ -152,7 +152,7 @@ Layer *getTopFlexiNoteLayer(); - void schedulePlaybackFrameMove(int frame); + void schedulePlaybackFrameMove(sv_frame_t frame); bool m_identifyFeatures; QPoint m_identifyPoint; @@ -167,10 +167,10 @@ bool m_resizing; bool m_editing; bool m_releasing; - int m_dragCentreFrame; - float m_dragStartMinValue; + sv_frame_t m_dragCentreFrame; + double m_dragStartMinValue; bool m_centreLineVisible; - int m_selectionStartFrame; + sv_frame_t m_selectionStartFrame; Selection m_editingSelection; int m_editingSelectionEdge; mutable int m_scaleWidth; @@ -202,7 +202,7 @@ bool m_mouseInWidget; bool m_playbackFrameMoveScheduled; - int m_playbackFrameMoveTo; + sv_frame_t m_playbackFrameMoveTo; static QCursor *m_measureCursor1; static QCursor *m_measureCursor2; diff -r 28d05ae8741c -r 4a578a360011 view/PaneStack.cpp --- a/view/PaneStack.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/view/PaneStack.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -98,7 +98,7 @@ currentIndicator->setScaledContents(true); currentIndicator->setVisible(m_showAccessories); - int initialCentreFrame = -1; + sv_frame_t initialCentreFrame = -1; if (!m_panes.empty()) { initialCentreFrame = m_panes[0].pane->getCentreFrame(); } @@ -156,8 +156,8 @@ this, SLOT(paneDropAccepted(QStringList))); connect(pane, SIGNAL(dropAccepted(QString)), this, SLOT(paneDropAccepted(QString))); - connect(pane, SIGNAL(doubleClickSelectInvoked(int)), - this, SIGNAL(doubleClickSelectInvoked(int))); + connect(pane, SIGNAL(doubleClickSelectInvoked(sv_frame_t)), + this, SIGNAL(doubleClickSelectInvoked(sv_frame_t))); emit paneAdded(pane); emit paneAdded(); @@ -323,13 +323,13 @@ int PaneStack::getPaneCount() const { - return m_panes.size(); + return int(m_panes.size()); } int PaneStack::getHiddenPaneCount() const { - return m_hiddenPanes.size(); + return int(m_hiddenPanes.size()); } void diff -r 28d05ae8741c -r 4a578a360011 view/PaneStack.h --- a/view/PaneStack.h Tue Mar 10 10:31:27 2015 +0000 +++ b/view/PaneStack.h Tue Mar 10 13:22:10 2015 +0000 @@ -20,6 +20,8 @@ #include +#include "base/BaseTypes.h" + class QWidget; class QLabel; class QStackedWidget; @@ -93,7 +95,7 @@ void paneDeleteButtonClicked(Pane *pane); - void doubleClickSelectInvoked(int frame); + void doubleClickSelectInvoked(sv_frame_t frame); public slots: void propertyContainerAdded(PropertyContainer *); diff -r 28d05ae8741c -r 4a578a360011 view/View.cpp --- a/view/View.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/view/View.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -164,7 +164,7 @@ int View::getPropertyContainerCount() const { - return m_fixedOrderLayers.size() + 1; // the 1 is for me + return int(m_fixedOrderLayers.size()) + 1; // the 1 is for me } const PropertyContainer * @@ -298,36 +298,36 @@ // subclass might override this } -int +sv_frame_t View::getStartFrame() const { return getFrameForX(0); } -int +sv_frame_t View::getEndFrame() const { return getFrameForX(width()) - 1; } void -View::setStartFrame(int f) +View::setStartFrame(sv_frame_t f) { setCentreFrame(f + m_zoomLevel * (width() / 2)); } bool -View::setCentreFrame(int f, bool e) +View::setCentreFrame(sv_frame_t f, bool e) { bool changeVisible = false; if (m_centreFrame != f) { - int formerPixel = m_centreFrame / m_zoomLevel; + int formerPixel = int(m_centreFrame / m_zoomLevel); m_centreFrame = f; - int newPixel = m_centreFrame / m_zoomLevel; + int newPixel = int(m_centreFrame / m_zoomLevel); if (newPixel != formerPixel) { @@ -340,7 +340,7 @@ } if (e) { - int rf = alignToReference(f); + sv_frame_t rf = alignToReference(f); #ifdef DEBUG_VIEW cerr << "View[" << this << "]::setCentreFrame(" << f << "): emitting centreFrameChanged(" @@ -354,16 +354,16 @@ } int -View::getXForFrame(int frame) const +View::getXForFrame(sv_frame_t frame) const { - return (frame - getStartFrame()) / m_zoomLevel; + return int((frame - getStartFrame()) / m_zoomLevel); } -int +sv_frame_t View::getFrameForX(int x) const { int z = m_zoomLevel; - int frame = m_centreFrame - (width()/2) * z; + sv_frame_t frame = m_centreFrame - (width()/2) * z; #ifdef DEBUG_VIEW_WIDGET_PAINT SVDEBUG << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl; @@ -390,15 +390,15 @@ if (lastminf != minf) { lastminf = (minf == 0.0 ? 1.0 : minf); - logminf = log10f(minf); + logminf = log10(minf); } if (lastmaxf != maxf) { lastmaxf = (maxf < lastminf ? lastminf : maxf); - logmaxf = log10f(maxf); + logmaxf = log10(maxf); } if (logminf == logmaxf) return 0; - return h - (h * (log10f(frequency) - logminf)) / (logmaxf - logminf); + return h - (h * (log10(frequency) - logminf)) / (logmaxf - logminf); } else { @@ -422,15 +422,15 @@ if (lastminf != minf) { lastminf = (minf == 0.0 ? 1.0 : minf); - logminf = log10f(minf); + logminf = log10(minf); } if (lastmaxf != maxf) { lastmaxf = (maxf < lastminf ? lastminf : maxf); - logmaxf = log10f(maxf); + logmaxf = log10(maxf); } if (logminf == logmaxf) return 0; - return pow(10.f, logminf + ((logmaxf - logminf) * (h - y)) / h); + return pow(10.0, logminf + ((logmaxf - logminf) * (h - y)) / h); } else { @@ -580,8 +580,8 @@ this, SLOT(modelCompletionChanged())); connect(layer, SIGNAL(modelAlignmentCompletionChanged()), this, SLOT(modelAlignmentCompletionChanged())); - connect(layer, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(modelChangedWithin(int, int))); + connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); connect(layer, SIGNAL(modelReplaced()), this, SLOT(modelReplaced())); @@ -636,8 +636,8 @@ this, SLOT(modelCompletionChanged())); disconnect(layer, SIGNAL(modelAlignmentCompletionChanged()), this, SLOT(modelAlignmentCompletionChanged())); - disconnect(layer, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(modelChangedWithin(int, int))); + disconnect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); disconnect(layer, SIGNAL(modelReplaced()), this, SLOT(modelReplaced())); @@ -692,26 +692,26 @@ View::setViewManager(ViewManager *manager) { if (m_manager) { - m_manager->disconnect(this, SLOT(globalCentreFrameChanged(int))); - m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, int))); - m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(int))); + m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t))); + m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); + m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool))); m_manager->disconnect(this, SLOT(toolModeChanged())); m_manager->disconnect(this, SLOT(selectionChanged())); m_manager->disconnect(this, SLOT(overlayModeChanged())); m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged())); - disconnect(m_manager, SLOT(viewCentreFrameChanged(int, bool, PlaybackFollowMode))); + disconnect(m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode))); disconnect(m_manager, SLOT(zoomLevelChanged(int, bool))); } m_manager = manager; - connect(m_manager, SIGNAL(globalCentreFrameChanged(int)), - this, SLOT(globalCentreFrameChanged(int))); - connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, int)), - this, SLOT(viewCentreFrameChanged(View *, int))); - connect(m_manager, SIGNAL(playbackFrameChanged(int)), - this, SLOT(viewManagerPlaybackFrameChanged(int))); + connect(m_manager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), + this, SLOT(globalCentreFrameChanged(sv_frame_t))); + connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)), + this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); + connect(m_manager, SIGNAL(playbackFrameChanged(sv_frame_t)), + this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), this, SLOT(viewZoomLevelChanged(View *, int, bool))); @@ -729,9 +729,9 @@ connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()), this, SLOT(zoomWheelsEnabledChanged())); - connect(this, SIGNAL(centreFrameChanged(int, bool, + connect(this, SIGNAL(centreFrameChanged(sv_frame_t, bool, PlaybackFollowMode)), - m_manager, SLOT(viewCentreFrameChanged(int, bool, + m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode))); connect(this, SIGNAL(zoomLevelChanged(int, bool)), @@ -763,7 +763,7 @@ } void -View::setViewManager(ViewManager *vm, int initialCentreFrame) +View::setViewManager(ViewManager *vm, sv_frame_t initialCentreFrame) { setViewManager(vm); setCentreFrame(initialCentreFrame, false); @@ -877,18 +877,18 @@ } void -View::modelChangedWithin(int startFrame, int endFrame) +View::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { QObject *obj = sender(); - int myStartFrame = getStartFrame(); - int myEndFrame = getEndFrame(); + sv_frame_t myStartFrame = getStartFrame(); + sv_frame_t myEndFrame = getEndFrame(); #ifdef DEBUG_VIEW_WIDGET_PAINT cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; #endif - if (myStartFrame > 0 && endFrame < int(myStartFrame)) { + if (myStartFrame > 0 && endFrame < myStartFrame) { checkProgress(obj); return; } @@ -995,10 +995,10 @@ } void -View::globalCentreFrameChanged(int rf) +View::globalCentreFrameChanged(sv_frame_t rf) { if (m_followPan) { - int f = alignFromReference(rf); + sv_frame_t f = alignFromReference(rf); #ifdef DEBUG_VIEW cerr << "View[" << this << "]::globalCentreFrameChanged(" << rf << "): setting centre frame to " << f << endl; @@ -1008,13 +1008,13 @@ } void -View::viewCentreFrameChanged(View *, int ) +View::viewCentreFrameChanged(View *, sv_frame_t ) { // We do nothing with this, but a subclass might } void -View::viewManagerPlaybackFrameChanged(int f) +View::viewManagerPlaybackFrameChanged(sv_frame_t f) { if (m_manager) { if (sender() != m_manager) return; @@ -1034,7 +1034,7 @@ } void -View::movePlayPointer(int newFrame) +View::movePlayPointer(sv_frame_t newFrame) { #ifdef DEBUG_VIEW cerr << "View(" << this << ")::movePlayPointer(" << newFrame << ")" << endl; @@ -1043,7 +1043,7 @@ if (m_playPointerFrame == newFrame) return; bool visibleChange = (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame)); - int oldPlayPointerFrame = m_playPointerFrame; + sv_frame_t oldPlayPointerFrame = m_playPointerFrame; m_playPointerFrame = newFrame; if (!visibleChange) return; @@ -1081,16 +1081,16 @@ int xold = getXForFrame(oldPlayPointerFrame); update(xold - 4, 0, 9, height()); - int w = getEndFrame() - getStartFrame(); + sv_frame_t w = getEndFrame() - getStartFrame(); w -= w/5; - int sf = (m_playPointerFrame / w) * w - w/8; + sv_frame_t sf = (m_playPointerFrame / w) * w - w/8; if (m_manager && m_manager->isPlaying() && m_manager->getPlaySelectionMode()) { MultiSelection::SelectionList selections = m_manager->getSelections(); if (!selections.empty()) { - int selectionStart = selections.begin()->getStartFrame(); + sv_frame_t selectionStart = selections.begin()->getStartFrame(); if (sf < selectionStart - w / 10) { sf = selectionStart - w / 10; } @@ -1124,8 +1124,8 @@ } if (!somethingGoingOn && shouldScroll) { - int offset = getFrameForX(width()/2) - getStartFrame(); - int newCentre = sf + offset; + sv_frame_t offset = getFrameForX(width()/2) - getStartFrame(); + sv_frame_t newCentre = sf + offset; bool changed = setCentreFrame(newCentre, false); if (changed) { xold = getXForFrame(oldPlayPointerFrame); @@ -1168,35 +1168,35 @@ update(); } -int +sv_frame_t View::getFirstVisibleFrame() const { - int f0 = getStartFrame(); - int f = getModelsStartFrame(); + sv_frame_t f0 = getStartFrame(); + sv_frame_t f = getModelsStartFrame(); if (f0 < 0 || f0 < f) return f; return f0; } -int +sv_frame_t View::getLastVisibleFrame() const { - int f0 = getEndFrame(); - int f = getModelsEndFrame(); + sv_frame_t f0 = getEndFrame(); + sv_frame_t f = getModelsEndFrame(); if (f0 > f) return f; return f0; } -int +sv_frame_t View::getModelsStartFrame() const { bool first = true; - int startFrame = 0; + sv_frame_t startFrame = 0; for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (*i)->getModel()->isOK()) { - int thisStartFrame = (*i)->getModel()->getStartFrame(); + sv_frame_t thisStartFrame = (*i)->getModel()->getStartFrame(); if (first || thisStartFrame < startFrame) { startFrame = thisStartFrame; @@ -1207,17 +1207,17 @@ return startFrame; } -int +sv_frame_t View::getModelsEndFrame() const { bool first = true; - int endFrame = 0; + sv_frame_t endFrame = 0; for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (*i)->getModel()->isOK()) { - int thisEndFrame = (*i)->getModel()->getEndFrame(); + sv_frame_t thisEndFrame = (*i)->getModel()->getEndFrame(); if (first || thisEndFrame > endFrame) { endFrame = thisEndFrame; @@ -1230,7 +1230,7 @@ return endFrame; } -int +sv_samplerate_t View::getModelsSampleRate() const { //!!! Just go for the first, for now. If we were supporting @@ -1309,8 +1309,8 @@ else return anyModel; } -int -View::alignFromReference(int f) const +sv_frame_t +View::alignFromReference(sv_frame_t f) const { if (!m_manager || !m_manager->getAlignMode()) return f; Model *aligningModel = getAligningModel(); @@ -1318,8 +1318,8 @@ return aligningModel->alignFromReference(f); } -int -View::alignToReference(int f) const +sv_frame_t +View::alignToReference(sv_frame_t f) const { if (!m_manager->getAlignMode()) return f; Model *aligningModel = getAligningModel(); @@ -1327,17 +1327,17 @@ return aligningModel->alignToReference(f); } -int +sv_frame_t View::getAlignedPlaybackFrame() const { if (!m_manager) return 0; - int pf = m_manager->getPlaybackFrame(); + sv_frame_t pf = m_manager->getPlaybackFrame(); if (!m_manager->getAlignMode()) return pf; Model *aligningModel = getAligningModel(); if (!aligningModel) return pf; - int af = aligningModel->alignFromReference(pf); + sv_frame_t af = aligningModel->alignFromReference(pf); return af; } @@ -1492,7 +1492,7 @@ void View::scroll(bool right, bool lots, bool e) { - int delta; + sv_frame_t delta; if (lots) { delta = (getEndFrame() - getStartFrame()) / 2; } else { @@ -1500,9 +1500,9 @@ } if (right) delta = -delta; - if (int(m_centreFrame) < delta) { + if (m_centreFrame < delta) { setCentreFrame(0, e); - } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) { + } else if (m_centreFrame - delta >= getModelsEndFrame()) { setCentreFrame(getModelsEndFrame(), e); } else { setCentreFrame(m_centreFrame - delta, e); @@ -1974,10 +1974,10 @@ paint.setBrush(Qt::NoBrush); } - int sampleRate = getModelsSampleRate(); + sv_samplerate_t sampleRate = getModelsSampleRate(); QPoint localPos; - int illuminateFrame = -1; + sv_frame_t illuminateFrame = -1; bool closeToLeft, closeToRight; if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) { @@ -2333,14 +2333,14 @@ } bool -View::render(QPainter &paint, int xorigin, int f0, int f1) +View::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / m_zoomLevel; - int x1 = f1 / m_zoomLevel; + int x0 = int(f0 / m_zoomLevel); + int x1 = int(f1 / m_zoomLevel); int w = x1 - x0; - int origCentreFrame = m_centreFrame; + sv_frame_t origCentreFrame = m_centreFrame; bool someLayersIncomplete = false; @@ -2440,17 +2440,17 @@ QImage * View::toNewImage() { - int f0 = getModelsStartFrame(); - int f1 = getModelsEndFrame(); + sv_frame_t f0 = getModelsStartFrame(); + sv_frame_t f1 = getModelsEndFrame(); return toNewImage(f0, f1); } QImage * -View::toNewImage(int f0, int f1) +View::toNewImage(sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / getZoomLevel(); - int x1 = f1 / getZoomLevel(); + int x0 = int(f0 / getZoomLevel()); + int x1 = int(f1 / getZoomLevel()); QImage *image = new QImage(x1 - x0, height(), QImage::Format_RGB32); @@ -2468,17 +2468,17 @@ QSize View::getImageSize() { - int f0 = getModelsStartFrame(); - int f1 = getModelsEndFrame(); + sv_frame_t f0 = getModelsStartFrame(); + sv_frame_t f1 = getModelsEndFrame(); return getImageSize(f0, f1); } QSize -View::getImageSize(int f0, int f1) +View::getImageSize(sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / getZoomLevel(); - int x1 = f1 / getZoomLevel(); + int x0 = int(f0 / getZoomLevel()); + int x1 = int(f1 / getZoomLevel()); return QSize(x1 - x0, height()); } diff -r 28d05ae8741c -r 4a578a360011 view/View.h --- a/view/View.h Tue Mar 10 10:31:27 2015 +0000 +++ b/view/View.h Tue Mar 10 13:22:10 2015 +0000 @@ -230,7 +230,7 @@ } virtual void setViewManager(ViewManager *m); - virtual void setViewManager(ViewManager *m, int initialFrame); + virtual void setViewManager(ViewManager *m, sv_frame_t initialFrame); virtual ViewManager *getViewManager() const { return m_manager; } virtual void setFollowGlobalPan(bool f); @@ -295,9 +295,9 @@ virtual PropertyContainer *getPropertyContainer(int i); // Render the contents on a wide canvas - virtual QImage *toNewImage(int f0, int f1); + virtual QImage *toNewImage(sv_frame_t f0, sv_frame_t f1); virtual QImage *toNewImage(); - virtual QSize getImageSize(int f0, int f1); + virtual QSize getImageSize(sv_frame_t f0, sv_frame_t f1); virtual QSize getImageSize(); virtual int getTextLabelHeight(const Layer *layer, QPainter &) const; @@ -375,12 +375,12 @@ virtual void paintEvent(QPaintEvent *e); virtual void drawSelections(QPainter &); virtual bool shouldLabelSelections() const { return true; } - virtual bool render(QPainter &paint, int x0, int f0, int f1); + virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); virtual void setPaintFont(QPainter &paint); typedef std::vector LayerList; - int getModelsSampleRate() const; + sv_samplerate_t getModelsSampleRate() const; bool areLayersScrollable() const; LayerList getScrollableBackLayers(bool testChanged, bool &changed) const; LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const; diff -r 28d05ae8741c -r 4a578a360011 view/ViewManager.cpp --- a/view/ViewManager.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/view/ViewManager.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -723,15 +723,15 @@ int ViewManager::scalePixelSize(int pixels) { - static float ratio = 0.f; - if (ratio == 0.f) { - float baseEm; + static double ratio = 0.0; + if (ratio == 0.0) { + double baseEm; #ifdef Q_OS_MAC - baseEm = 17.f; + baseEm = 17.0; #else - baseEm = 15.f; + baseEm = 15.0; #endif - float em = QFontMetrics(QFont()).height(); + double em = QFontMetrics(QFont()).height(); ratio = em / baseEm; } diff -r 28d05ae8741c -r 4a578a360011 widgets/AudioDial.cpp --- a/widgets/AudioDial.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/AudioDial.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -121,10 +121,10 @@ QPainter paint; - float angle = AUDIO_DIAL_MIN // offset + double angle = AUDIO_DIAL_MIN // offset + (AUDIO_DIAL_RANGE * - (float(QDial::value() - QDial::minimum()) / - (float(QDial::maximum() - QDial::minimum())))); + (double(QDial::value() - QDial::minimum()) / + (double(QDial::maximum() - QDial::minimum())))); int degrees = int(angle * 180.0 / M_PI); int ns = notchSize(); @@ -268,15 +268,15 @@ // Pointer notch... - float hyp = float(width) / 2.0; - float len = hyp - indent; + double hyp = double(width) / 2.0; + double len = hyp - indent; --len; - float x0 = hyp; - float y0 = hyp; + double x0 = hyp; + double y0 = hyp; - float x = hyp - len * sin(angle); - float y = hyp + len * cos(angle); + double x = hyp - len * sin(angle); + double y = hyp + len * cos(angle); c = palette().dark().color(); pen.setColor(isEnabled() ? c.dark(130) : c); @@ -289,27 +289,27 @@ void AudioDial::drawTick(QPainter &paint, - float angle, int size, bool internal) + double angle, int size, bool internal) { - float hyp = float(size) / 2.0; - float x0 = hyp - (hyp - 1) * sin(angle); - float y0 = hyp + (hyp - 1) * cos(angle); + double hyp = double(size) / 2.0; + double x0 = hyp - (hyp - 1) * sin(angle); + double y0 = hyp + (hyp - 1) * cos(angle); // cerr << "drawTick: angle " << angle << ", size " << size << ", internal " << internal << endl; if (internal) { - float len = hyp / 4; - float x1 = hyp - (hyp - len) * sin(angle); - float y1 = hyp + (hyp - len) * cos(angle); + double len = hyp / 4; + double x1 = hyp - (hyp - len) * sin(angle); + double y1 = hyp + (hyp - len) * cos(angle); paint.drawLine(int(x0), int(y0), int(x1), int(y1)); } else { - float len = hyp / 4; - float x1 = hyp - (hyp + len) * sin(angle); - float y1 = hyp + (hyp + len) * cos(angle); + double len = hyp / 4; + double x1 = hyp - (hyp + len) * sin(angle); + double y1 = hyp + (hyp + len) * cos(angle); paint.drawLine(int(x0), int(y0), int(x1), int(y1)); } @@ -350,7 +350,7 @@ updateMappedValue(value); } -void AudioDial::setDefaultMappedValue(float value) +void AudioDial::setDefaultMappedValue(double value) { m_defaultMappedValue = value; if (m_rangeMapper) { @@ -358,7 +358,7 @@ } } -void AudioDial::setMappedValue(float mappedValue) +void AudioDial::setMappedValue(double mappedValue) { if (m_rangeMapper) { int newPosition = m_rangeMapper->getPositionForValue(mappedValue); @@ -387,7 +387,7 @@ } -float AudioDial::mappedValue() const +double AudioDial::mappedValue() const { if (m_rangeMapper) { // SVDEBUG << "AudioDial::mappedValue(): value = " << value() << ", mappedValue = " << m_mappedValue << endl; @@ -464,11 +464,11 @@ if (m_rangeMapper) { - float min = m_rangeMapper->getValueForPosition(minimum()); - float max = m_rangeMapper->getValueForPosition(maximum()); + double min = m_rangeMapper->getValueForPosition(minimum()); + double max = m_rangeMapper->getValueForPosition(maximum()); if (min > max) { - float tmp = min; + double tmp = min; min = max; max = tmp; } @@ -494,7 +494,7 @@ } } - float newValue = QInputDialog::getDouble + double newValue = QInputDialog::getDouble (this, tr("Enter new value"), text, diff -r 28d05ae8741c -r 4a578a360011 widgets/AudioDial.h --- a/widgets/AudioDial.h Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/AudioDial.h Tue Mar 10 13:22:10 2015 +0000 @@ -73,7 +73,7 @@ void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete const RangeMapper *rangeMapper() const { return m_rangeMapper; } - float mappedValue() const; + double mappedValue() const; int defaultValue() const { return m_defaultValue; } @@ -107,14 +107,14 @@ void setValue(int value); - void setDefaultMappedValue(float mappedValue); + void setDefaultMappedValue(double mappedValue); - void setMappedValue(float mappedValue); + void setMappedValue(double mappedValue); void setToDefault(); protected: - void drawTick(QPainter &paint, float angle, int size, bool internal); + void drawTick(QPainter &paint, double angle, int size, bool internal); virtual void paintEvent(QPaintEvent *); // Alternate mouse behavior event handlers. @@ -133,8 +133,8 @@ QColor m_meterColor; int m_defaultValue; - float m_defaultMappedValue; - float m_mappedValue; + double m_defaultMappedValue; + double m_mappedValue; bool m_noMappedUpdate; // Alternate mouse behavior tracking. diff -r 28d05ae8741c -r 4a578a360011 widgets/CSVFormatDialog.cpp --- a/widgets/CSVFormatDialog.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/CSVFormatDialog.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -62,7 +62,7 @@ exampleFrame->setPalette(palette); QFont fp; - fp.setPointSize(fp.pointSize() * 0.9); + fp.setPointSize(int(floor(fp.pointSize() * 0.9))); // fp.setFixedPitch(true); // fp.setStyleHint(QFont::TypeWriter); // fp.setFamily("Monospaced"); diff -r 28d05ae8741c -r 4a578a360011 widgets/CommandHistory.cpp --- a/widgets/CommandHistory.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/CommandHistory.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -420,14 +420,14 @@ CommandHistory::documentSaved() { closeBundle(); - m_savedAt = m_undoStack.size(); + m_savedAt = int(m_undoStack.size()); } void CommandHistory::clipCommands() { - if ((int)m_undoStack.size() > m_undoLimit) { - m_savedAt -= (m_undoStack.size() - m_undoLimit); + if (int(m_undoStack.size()) > m_undoLimit) { + m_savedAt -= (int(m_undoStack.size()) - m_undoLimit); } clipStack(m_undoStack, m_undoLimit); diff -r 28d05ae8741c -r 4a578a360011 widgets/Fader.cpp --- a/widgets/Fader.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/Fader.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -110,7 +110,7 @@ if (vx > getMaxX()) vx = getMaxX(); if (vx < 0) vx = 0; - float fval = AudioLevel::fader_to_multiplier + float fval = (float)AudioLevel::fader_to_multiplier (vx, getMaxX(), AudioLevel::LongFader); setValue(fval); @@ -132,20 +132,20 @@ Fader::mouseDoubleClickEvent(QMouseEvent *) { bool ok = false; - float min = AudioLevel::fader_to_dB + float min = (float)AudioLevel::fader_to_dB (0, getMaxX(), AudioLevel::LongFader); - float max = AudioLevel::fader_to_dB + float max = (float)AudioLevel::fader_to_dB (getMaxX(), getMaxX(), AudioLevel::LongFader); - float deft = AudioLevel::multiplier_to_dB(m_value); + float deft = (float)AudioLevel::multiplier_to_dB(m_value); - float dB = QInputDialog::getDouble + float dB = (float)QInputDialog::getDouble (this, tr("Enter new fader level"), tr("New fader level, from %1 to %2 dBFS:").arg(min).arg(max), deft, min, max, 3, &ok); if (ok) { - float value = AudioLevel::dB_to_multiplier(dB); + float value = (float)AudioLevel::dB_to_multiplier(dB); setValue(value); emit valueChanged(value); update(); @@ -179,9 +179,9 @@ //!!! needs improvement if (ev->delta() > 0) { - setValue(m_value * 1.1); + setValue(m_value * 1.f); } else { - setValue(m_value / 1.1); + setValue(m_value / 1.f); } update(); @@ -203,7 +203,7 @@ void Fader::setValue(float v) { - float max = AudioLevel::dB_to_multiplier(10.0); + float max = (float)AudioLevel::dB_to_multiplier(10.0); if (v > max) { v = max; @@ -213,7 +213,7 @@ if (m_value != v) { m_value = v; - float db = AudioLevel::multiplier_to_dB(m_value); + float db = (float)AudioLevel::multiplier_to_dB(m_value); QString text; if (db <= AudioLevel::DB_FLOOR) { text = tr("Level: Off"); diff -r 28d05ae8741c -r 4a578a360011 widgets/ItemEditDialog.cpp --- a/widgets/ItemEditDialog.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/ItemEditDialog.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -200,7 +200,7 @@ RealTime rt(RealTime::frame2RealTime(frame, m_sampleRate)); m_realTimeSecsSpinBox->setValue(rt.sec); m_realTimeUSecsSpinBox->setValue(rt.usec()); - m_frameTimeSpinBox->setValue(frame); + m_frameTimeSpinBox->setValue(int(frame)); m_defaultFrame = frame; m_resetButton->setEnabled(false); } @@ -231,7 +231,7 @@ RealTime rt(RealTime::frame2RealTime(duration, m_sampleRate)); m_realDurationSecsSpinBox->setValue(rt.sec); m_realDurationUSecsSpinBox->setValue(rt.usec()); - m_frameDurationSpinBox->setValue(duration); + m_frameDurationSpinBox->setValue(int(duration)); m_defaultDuration = duration; m_resetButton->setEnabled(false); } @@ -267,7 +267,7 @@ float ItemEditDialog::getValue() const { - return m_valueSpinBox->value(); + return float(m_valueSpinBox->value()); } void @@ -307,7 +307,7 @@ RealTime rt = getRealTime(); rt.sec = i; sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameTimeSpinBox->setValue(frame); + m_frameTimeSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } @@ -317,7 +317,7 @@ RealTime rt = getRealTime(); rt.nsec = i * 1000; sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameTimeSpinBox->setValue(frame); + m_frameTimeSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } @@ -342,7 +342,7 @@ RealTime rt = getRealDuration(); rt.sec = i; sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameDurationSpinBox->setValue(frame); + m_frameDurationSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } @@ -352,7 +352,7 @@ RealTime rt = getRealDuration(); rt.nsec = i * 1000; sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameDurationSpinBox->setValue(frame); + m_frameDurationSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } diff -r 28d05ae8741c -r 4a578a360011 widgets/LayerTree.cpp --- a/widgets/LayerTree.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/LayerTree.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -253,7 +253,7 @@ int ModelMetadataModel::rowCount(const QModelIndex &parent) const { - if (!parent.isValid()) return m_models.size(); + if (!parent.isValid()) return int(m_models.size()); return 0; } diff -r 28d05ae8741c -r 4a578a360011 widgets/ListInputDialog.cpp --- a/widgets/ListInputDialog.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/ListInputDialog.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -67,7 +67,7 @@ { for (size_t i = 0; i < m_radioButtons.size(); ++i) { if (m_radioButtons[i]->isChecked()) { - return m_strings[i]; + return m_strings[int(i)]; } } return ""; diff -r 28d05ae8741c -r 4a578a360011 widgets/ModelDataTableDialog.cpp --- a/widgets/ModelDataTableDialog.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/ModelDataTableDialog.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -168,14 +168,14 @@ } void -ModelDataTableDialog::userScrolledToFrame(int frame) +ModelDataTableDialog::userScrolledToFrame(sv_frame_t frame) { QModelIndex index = m_table->getModelIndexForFrame(frame); makeCurrent(index.row()); } void -ModelDataTableDialog::playbackScrolledToFrame(int frame) +ModelDataTableDialog::playbackScrolledToFrame(sv_frame_t frame) { if (m_trackPlayback) { QModelIndex index = m_table->getModelIndexForFrame(frame); diff -r 28d05ae8741c -r 4a578a360011 widgets/ModelDataTableDialog.h --- a/widgets/ModelDataTableDialog.h Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/ModelDataTableDialog.h Tue Mar 10 13:22:10 2015 +0000 @@ -18,6 +18,8 @@ #include +#include "base/BaseTypes.h" + class TabularModel; class ModelDataTableModel; class QTableView; @@ -38,11 +40,11 @@ QToolBar *getPlayToolbar() { return m_playToolbar; } signals: - void scrollToFrame(int frame); + void scrollToFrame(sv_frame_t frame); public slots: - void userScrolledToFrame(int frame); - void playbackScrolledToFrame(int frame); + void userScrolledToFrame(sv_frame_t frame); + void playbackScrolledToFrame(sv_frame_t frame); void addCommand(Command *); protected slots: diff -r 28d05ae8741c -r 4a578a360011 widgets/Panner.cpp --- a/widgets/Panner.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/Panner.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -65,7 +65,7 @@ float unit = m_scrollUnit; if (unit == 0.f) { unit = float(m_rectHeight) / (6 * float(height())); - if (unit < 0.01) unit = 0.01; + if (unit < 0.01f) unit = 0.01f; } if (!up) { @@ -165,24 +165,24 @@ paint.setBrush(hl); - int rw = lrintf((width() - 1) * m_rectWidth); - int rh = lrintf((height() - 1) * m_rectHeight); + int rw = int(lrintf(float(width() - 1) * m_rectWidth)); + int rh = int(lrintf(float(height() - 1) * m_rectHeight)); if (rw < 2) rw = 2; if (rh < 2) rh = 2; - paint.drawRect(lrintf(width() * m_rectX), - lrintf(height() * m_rectY), + paint.drawRect(int(lrintf(float(width()) * m_rectX)), + int(lrintf(float(height()) * m_rectY)), rw, rh); } void Panner::normalise() { - if (m_rectWidth > 1.0) m_rectWidth = 1.0; - if (m_rectHeight > 1.0) m_rectHeight = 1.0; - if (m_rectX + m_rectWidth > 1.0) m_rectX = 1.0 - m_rectWidth; + if (m_rectWidth > 1.f) m_rectWidth = 1.f; + if (m_rectHeight > 1.f) m_rectHeight = 1.f; + if (m_rectX + m_rectWidth > 1.f) m_rectX = 1.f - m_rectWidth; if (m_rectX < 0) m_rectX = 0; - if (m_rectY + m_rectHeight > 1.0) m_rectY = 1.0 - m_rectHeight; + if (m_rectY + m_rectHeight > 1.f) m_rectY = 1.f - m_rectHeight; if (m_rectY < 0) m_rectY = 0; if (!m_defaultsSet) { diff -r 28d05ae8741c -r 4a578a360011 widgets/PluginParameterBox.cpp --- a/widgets/PluginParameterBox.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/PluginParameterBox.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -70,12 +70,12 @@ m_programCombo = new QComboBox; m_programCombo->setMaxVisibleItems - (m_programs.size() < 25 ? m_programs.size() : 20); + (int(m_programs.size() < 25 ? m_programs.size() : 20)); - for (size_t i = 0; i < m_programs.size(); ++i) { + for (int i = 0; in_range_for(m_programs, i); ++i) { m_programCombo->addItem(m_programs[i].c_str()); if (m_programs[i] == currentProgram) { - m_programCombo->setCurrentIndex(i); + m_programCombo->setCurrentIndex(int(i)); } } @@ -88,7 +88,7 @@ offset = 1; } - for (size_t i = 0; i < params.size(); ++i) { + for (int i = 0; in_range_for(params, i); ++i) { QString identifier = params[i].identifier.c_str(); QString name = params[i].name.c_str(); @@ -120,9 +120,9 @@ if (!(hint & PortHint::Logarithmic)) { if (qtz > 0.0) { - imax = lrintf((max - min) / qtz); + imax = int(lrintf((max - min) / qtz)); } else { - qtz = (max - min) / 100.0; + qtz = (max - min) / 100.f; } } @@ -245,19 +245,19 @@ if (ad && ad->rangeMapper()) { - newValue = ad->mappedValue(); + newValue = float(ad->mappedValue()); if (newValue < min) newValue = min; if (newValue > max) newValue = max; if (qtz != 0.0) { - ival = lrintf((newValue - min) / qtz); - newValue = min + ival * qtz; + ival = int(lrintf((newValue - min) / qtz)); + newValue = min + float(ival) * qtz; } } else { - if (qtz == 0.0) { - qtz = (max - min) / 100.0; + if (qtz == 0.f) { + qtz = (max - min) / 100.f; } - newValue = min + ival * qtz; + newValue = min + float(ival) * qtz; } // SVDEBUG << "PluginParameterBox::dialChanged: newValue = " << newValue << endl; @@ -329,8 +329,8 @@ if (params.isQuantized) qtz = params.quantizeStep; if (qtz > 0.0) { - int step = lrintf((value - min) / qtz); - value = min + step * qtz; + int step = int(lrintf(float(value - min) / qtz)); + value = min + float(step) * qtz; } // int imax = 100; @@ -338,10 +338,10 @@ if (qtz > 0.0) { // imax = lrintf((max - min) / qtz); } else { - qtz = (max - min) / 100.0; + qtz = (max - min) / 100.f; } - int ival = lrintf((value - min) / qtz); + int ival = int(lrintf(float(value - min) / qtz)); AudioDial *dial = m_params[identifier].dial; if (dial) { @@ -356,7 +356,7 @@ SVDEBUG << "setting plugin parameter \"" << identifier << "\" to value " << value << endl; - m_plugin->setParameter(identifier.toStdString(), value); + m_plugin->setParameter(identifier.toStdString(), float(value)); updateProgramCombo(); @@ -389,17 +389,17 @@ if (param.isQuantized) qtz = param.quantizeStep; if (qtz == 0.0) { - qtz = (max - min) / 100.0; + qtz = (max - min) / 100.f; } i->second.dial->blockSignals(true); - i->second.dial->setValue(lrintf((value - min) / qtz)); + i->second.dial->setValue(int(lrintf(float(value - min) / qtz))); i->second.dial->blockSignals(false); } if (i->second.combo) { i->second.combo->blockSignals(true); - i->second.combo->setCurrentIndex(lrintf(value)); + i->second.combo->setCurrentIndex(int(lrintf(value))); i->second.combo->blockSignals(false); } @@ -420,7 +420,7 @@ std::string currentProgram = m_plugin->getCurrentProgram(); - for (size_t i = 0; i < m_programs.size(); ++i) { + for (int i = 0; in_range_for(m_programs, i); ++i) { if (m_programs[i] == currentProgram) { m_programCombo->setCurrentIndex(i); } diff -r 28d05ae8741c -r 4a578a360011 widgets/PluginParameterDialog.cpp --- a/widgets/PluginParameterDialog.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/PluginParameterDialog.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -386,10 +386,10 @@ int size = 1024; int increment = 1024; if (fePlugin) { - size = fePlugin->getPreferredBlockSize(); + size = int(fePlugin->getPreferredBlockSize()); cerr << "Feature extraction plugin \"" << fePlugin->getName() << "\" reports preferred block size as " << size << endl; if (size == 0) size = 1024; - increment = fePlugin->getPreferredStepSize(); + increment = int(fePlugin->getPreferredStepSize()); if (increment == 0) { if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) { increment = size; diff -r 28d05ae8741c -r 4a578a360011 widgets/PropertyBox.cpp --- a/widgets/PropertyBox.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/PropertyBox.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -689,7 +689,7 @@ void PropertyBox::playGainChanged(float gain) { - int dialValue = lrint(log10(gain) * 20.0); + int dialValue = int(lrint(log10(gain) * 20.0)); if (dialValue < -50) dialValue = -50; if (dialValue > 50) dialValue = 50; emit changePlayGainDial(dialValue); @@ -703,7 +703,7 @@ PlayParameters *params = m_container->getPlayParameters(); if (!params) return; - float gain = pow(10, float(dialValue) / 20.0); + float gain = float(pow(10, float(dialValue) / 20.0)); if (params->getPlayGain() != gain) { PlayParameterRepository::EditCommand *command = @@ -718,7 +718,7 @@ void PropertyBox::playPanChanged(float pan) { - int dialValue = lrint(pan * 50.0); + int dialValue = int(lrint(pan * 50.0)); if (dialValue < -50) dialValue = -50; if (dialValue > 50) dialValue = 50; emit changePlayPanDial(dialValue); @@ -732,9 +732,9 @@ PlayParameters *params = m_container->getPlayParameters(); if (!params) return; - float pan = float(dialValue) / 50.0; - if (pan < -1.0) pan = -1.0; - if (pan > 1.0) pan = 1.0; + float pan = float(dialValue) / 50.f; + if (pan < -1.f) pan = -1.f; + if (pan > 1.f) pan = 1.f; if (params->getPlayPan() != pan) { PlayParameterRepository::EditCommand *command = @@ -832,7 +832,7 @@ QString extraText; AudioDial *dial = dynamic_cast(w); if (dial) { - float mv = dial->mappedValue(); + double mv = dial->mappedValue(); QString unit = ""; if (dial->rangeMapper()) unit = dial->rangeMapper()->getUnit(); if (unit != "") { diff -r 28d05ae8741c -r 4a578a360011 widgets/PropertyStack.cpp --- a/widgets/PropertyStack.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/PropertyStack.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -172,7 +172,7 @@ // remain in the same order. So we must find this container in the // box list, not in the view. - for (size_t i = 0; i < m_boxes.size(); ++i) { + for (int i = 0; in_range_for(m_boxes, i); ++i) { PropertyContainer *container = m_boxes[i]->getContainer(); if (pc == container) { return i; diff -r 28d05ae8741c -r 4a578a360011 widgets/SubdividingMenu.cpp --- a/widgets/SubdividingMenu.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/SubdividingMenu.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -53,7 +53,7 @@ { m_entriesSet = true; - int total = entries.size(); + int total = int(entries.size()); if (total < m_upperLimit) return; diff -r 28d05ae8741c -r 4a578a360011 widgets/Thumbwheel.cpp --- a/widgets/Thumbwheel.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/Thumbwheel.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -135,7 +135,7 @@ } void -Thumbwheel::setMappedValue(float mappedValue) +Thumbwheel::setMappedValue(double mappedValue) { if (m_rangeMapper) { int newValue = m_rangeMapper->getPositionForValue(mappedValue); @@ -202,7 +202,7 @@ return m_value; } -float +double Thumbwheel::getMappedValue() const { if (m_rangeMapper) { @@ -240,7 +240,7 @@ void Thumbwheel::scroll(bool up) { - int step = lrintf(m_speed); + int step = int(lrintf(m_speed)); if (step == 0) step = 1; if (up) { @@ -327,11 +327,11 @@ if (m_rangeMapper) { - float min = m_rangeMapper->getValueForPosition(m_min); - float max = m_rangeMapper->getValueForPosition(m_max); + double min = m_rangeMapper->getValueForPosition(m_min); + double max = m_rangeMapper->getValueForPosition(m_max); if (min > max) { - float tmp = min; + double tmp = min; min = max; max = tmp; } @@ -357,7 +357,7 @@ } } - float newValue = QInputDialog::getDouble + double newValue = QInputDialog::getDouble (this, tr("Enter new value"), text, @@ -398,10 +398,10 @@ dist = e->y() - m_clickPos.y(); } - float rotation = m_clickRotation + (m_speed * dist) / 100; + float rotation = m_clickRotation + (m_speed * float(dist)) / 100; if (rotation < 0.f) rotation = 0.f; if (rotation > 1.f) rotation = 1.f; - int value = lrintf(m_min + (m_max - m_min) * m_rotation); + int value = int(lrintf(float(m_min) + float(m_max - m_min) * m_rotation)); if (value != m_value) { setValue(value); if (m_tracking) emit valueChanged(getValue()); @@ -426,7 +426,7 @@ void Thumbwheel::wheelEvent(QWheelEvent *e) { - int step = lrintf(m_speed); + int step = int(lrintf(m_speed)); if (step == 0) step = 1; if (e->delta() > 0) { @@ -469,13 +469,13 @@ paint.setRenderHint(QPainter::Antialiasing, true); - float w = width(); - float w0 = 0.5; - float w1 = w - 0.5; + double w = width(); + double w0 = 0.5; + double w1 = w - 0.5; - float h = height(); - float h0 = 0.5; - float h1 = h - 0.5; + double h = height(); + double h0 = 0.5; + double h1 = h - 0.5; for (int i = bw-1; i >= 0; --i) { @@ -504,7 +504,7 @@ paint.setClipRect(subclip); - float radians = m_rotation * 1.5f * M_PI; + double radians = m_rotation * 1.5f * M_PI; // cerr << "value = " << m_value << ", min = " << m_min << ", max = " << m_max << ", rotation = " << rotation << endl; @@ -518,16 +518,16 @@ for (int i = 0; i < notches; ++i) { - float a0 = (2.f * M_PI * i) / notches + radians; - float a1 = a0 + M_PI / (notches * 2); - float a2 = (2.f * M_PI * (i + 1)) / notches + radians; + double a0 = (2.0 * M_PI * i) / notches + radians; + double a1 = a0 + M_PI / (notches * 2); + double a2 = (2.0 * M_PI * (i + 1)) / notches + radians; - float depth = cosf((a0 + a2) / 2); + double depth = cos((a0 + a2) / 2); if (depth < 0) continue; - float x0 = radius * sinf(a0) + w/2; - float x1 = radius * sinf(a1) + w/2; - float x2 = radius * sinf(a2) + w/2; + double x0 = radius * sin(a0) + w/2; + double x1 = radius * sin(a1) + w/2; + double x2 = radius * sin(a2) + w/2; if (x2 < 0 || x0 > w) continue; if (x0 < 0) x0 = 0; @@ -537,7 +537,7 @@ x1 += bw; x2 += bw; - int grey = lrintf(120 * depth); + int grey = int(lrint(120 * depth)); QColor fc = QColor(grey, grey, grey); QColor oc = palette().highlight().color(); @@ -548,9 +548,9 @@ paint.setBrush(oc); - float prop; + double prop; if (i >= notches / 4) { - prop = float(notches - (((i - float(notches) / 4.f) * 4.f) / 3.f)) + prop = double(notches - (((i - double(notches) / 4.f) * 4.f) / 3.f)) / notches; } else { prop = 0.f; diff -r 28d05ae8741c -r 4a578a360011 widgets/Thumbwheel.h --- a/widgets/Thumbwheel.h Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/Thumbwheel.h Tue Mar 10 13:22:10 2015 +0000 @@ -41,7 +41,7 @@ void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete const RangeMapper *getRangeMapper() const { return m_rangeMapper; } - float getMappedValue() const; + double getMappedValue() const; void setShowToolTip(bool show); @@ -61,7 +61,7 @@ void setTracking(bool tracking); void setShowScale(bool show); void setValue(int value); - void setMappedValue(float mappedValue); + void setMappedValue(double mappedValue); void scroll(bool up); void resetToDefault(); @@ -82,7 +82,7 @@ int m_max; int m_default; int m_value; - float m_mappedValue; + double m_mappedValue; bool m_noMappedUpdate; float m_rotation; Qt::Orientation m_orientation; diff -r 28d05ae8741c -r 4a578a360011 widgets/TipDialog.cpp --- a/widgets/TipDialog.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/TipDialog.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -105,7 +105,7 @@ TipDialog::previous() { if (--m_tipNumber < 0) { - m_tipNumber = m_tips.size() - 1; + m_tipNumber = int(m_tips.size()) - 1; } showTip(); diff -r 28d05ae8741c -r 4a578a360011 widgets/TransformFinder.cpp --- a/widgets/TransformFinder.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/TransformFinder.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -225,11 +225,11 @@ if (m_sortedResults.size() < sorted.size()) { m_infoLabel->setText (tr("Found %n description(s) containing %1, showing the first %2 only", - 0, sorted.size()).arg(text).arg(m_sortedResults.size())); + 0, int(sorted.size())).arg(text).arg(m_sortedResults.size())); } else { m_infoLabel->setText (tr("Found %n description(s) containing %1", - 0, sorted.size()).arg(text)); + 0, int(sorted.size())).arg(text)); } return; diff -r 28d05ae8741c -r 4a578a360011 widgets/WindowShapePreview.cpp --- a/widgets/WindowShapePreview.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/WindowShapePreview.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -32,7 +32,7 @@ WindowShapePreview::WindowShapePreview(QWidget *parent) : QFrame(parent), - m_windowType(WindowType(999)) + m_windowType(HanningWindow) { QHBoxLayout *layout = new QHBoxLayout; layout->setMargin(0); @@ -51,7 +51,7 @@ WindowShapePreview::updateLabels() { int step = 24; - int peak = 48; + float peak = 48; int w = step * 4, h = 64; WindowType type = m_windowType; Window windower = Window(type, step * 2); @@ -62,8 +62,8 @@ QPainterPath path; - path.moveTo(0, h - peak + 1); - path.lineTo(w, h - peak + 1); + path.moveTo(0, float(h) - peak + 1); + path.lineTo(w, float(h) - peak + 1); timePainter.setPen(Qt::gray); timePainter.setRenderHint(QPainter::Antialiasing, true); @@ -84,7 +84,7 @@ } } for (int i = 0; i < w; ++i) { - int y = h - int(peak * acc[i] + 0.001) + 1; + int y = h - int(peak * acc[i] + 0.001f) + 1; if (i == 0) path.moveTo(i, y); else path.lineTo(i, y); } @@ -150,7 +150,7 @@ float power = output[i][0] * output[i][0] + output[i][1] * output[i][1]; float db = mindb; if (power > 0) { - db = 20 * log10(power); + db = 20.f * log10f(power); if (first || db > maxdb) maxdb = db; if (first || db < mindb) mindb = db; first = false; @@ -167,8 +167,8 @@ // float ly = h - ((-80.f + -mindb) / maxval) * peak + 1; - path.moveTo(0, h - peak + 1); - path.lineTo(fw, h - peak + 1); + path.moveTo(0, float(h) - peak + 1); + path.lineTo(fw, float(h) - peak + 1); freqPainter.setPen(Qt::gray); freqPainter.setRenderHint(QPainter::Antialiasing, true); @@ -181,12 +181,12 @@ for (int i = 0; i < fftsize/2; ++i) { float power = output[i][0] * output[i][0] + output[i][1] * output[i][1]; - float db = 20 * log10(power); + float db = 20.f * log10f(power); float val = db + -mindb; if (val < 0) val = 0; float norm = val / maxval; - float x = (fw / float(fftsize/2)) * i; - float y = h - norm * peak + 1; + float x = (float(fw) / float(fftsize/2)) * float(i); + float y = float(h) - norm * peak + 1; if (i == 0) path.moveTo(x, y); else path.lineTo(x, y); } diff -r 28d05ae8741c -r 4a578a360011 widgets/WindowTypeSelector.cpp --- a/widgets/WindowTypeSelector.cpp Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/WindowTypeSelector.cpp Tue Mar 10 13:22:10 2015 +0000 @@ -22,9 +22,23 @@ #include "base/Preferences.h" -WindowTypeSelector::WindowTypeSelector(WindowType defaultType, QWidget *parent) : - QFrame(parent), - m_windowType(WindowType(999)) +WindowTypeSelector::WindowTypeSelector(WindowType defaultType) +{ + init(defaultType); +} + +WindowTypeSelector::WindowTypeSelector() +{ + Preferences *prefs = Preferences::getInstance(); + int min = 0, max = 0, deflt = 0; + WindowType type = + WindowType(prefs->getPropertyRangeAndValue("Window Type", &min, &max, + &deflt)); + init(type); +} + +void +WindowTypeSelector::init(WindowType defaultType) { QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); @@ -48,15 +62,10 @@ m_windowShape = new WindowShapePreview; m_windowCombo = new QComboBox; - int min = 0, max = 0, deflt = 0, i = 0; int window = int(defaultType); - if (window == 999) { - window = prefs->getPropertyRangeAndValue("Window Type", &min, &max, - &deflt); - } int index = 0; - for (i = 0; i <= 8; ++i) { + for (int i = 0; i <= 8; ++i) { m_windowCombo->addItem(prefs->getPropertyValueLabel("Window Type", m_windows[i])); if (m_windows[i] == window) index = i; diff -r 28d05ae8741c -r 4a578a360011 widgets/WindowTypeSelector.h --- a/widgets/WindowTypeSelector.h Tue Mar 10 10:31:27 2015 +0000 +++ b/widgets/WindowTypeSelector.h Tue Mar 10 13:22:10 2015 +0000 @@ -28,8 +28,8 @@ Q_OBJECT public: - WindowTypeSelector(WindowType defaultType = WindowType(999), // 999 -> get from preferences - QWidget *parent = 0); + WindowTypeSelector(WindowType defaultType); + WindowTypeSelector(); // get window type from preferences virtual ~WindowTypeSelector(); WindowType getWindowType() const; @@ -48,6 +48,8 @@ WindowShapePreview *m_windowShape; WindowType *m_windows; WindowType m_windowType; + + void init(WindowType type); }; #endif