changeset 905:b66fb15de477 cxx11

Working through the float/double and int/sv_frame_t fixes
author Chris Cannam
date Mon, 09 Mar 2015 14:35:21 +0000
parents e0f08e108064
children 12ab113ca2b1
files layer/ColourScaleLayer.h layer/FlexiNoteLayer.cpp layer/FlexiNoteLayer.h layer/ImageLayer.cpp layer/ImageLayer.h layer/ImageRegionFinder.cpp layer/Layer.cpp layer/Layer.h layer/LinearColourScale.cpp layer/LinearColourScale.h layer/LinearNumericalScale.cpp layer/LogColourScale.cpp layer/LogColourScale.h layer/LogNumericalScale.cpp layer/NoteLayer.cpp layer/NoteLayer.h layer/PaintAssistant.cpp layer/PaintAssistant.h layer/PianoScale.cpp layer/RegionLayer.cpp layer/RegionLayer.h layer/SliceLayer.h layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h layer/SpectrumLayer.h layer/TextLayer.h layer/TimeInstantLayer.h layer/TimeRulerLayer.h layer/TimeValueLayer.h layer/WaveformLayer.h
diffstat 30 files changed, 397 insertions(+), 403 deletions(-) [+]
line wrap: on
line diff
--- a/layer/ColourScaleLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/ColourScaleLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -23,7 +23,7 @@
 {
 public:
     virtual QString getScaleUnits() const = 0;
-    virtual QColor getColourForValue(View *v, float value) const = 0;
+    virtual QColor getColourForValue(View *v, double value) const = 0;
 };
 
 #endif
--- a/layer/FlexiNoteLayer.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/FlexiNoteLayer.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -1582,7 +1582,7 @@
 }
 
 void
-FlexiNoteLayer::moveSelection(Selection s, int newStartFrame)
+FlexiNoteLayer::moveSelection(Selection s, sv_frame_t newStartFrame)
 {
     if (!m_model) return;
 
--- a/layer/FlexiNoteLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/FlexiNoteLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -70,7 +70,7 @@
 
     virtual bool editOpen(View *v, QMouseEvent *);
 
-    virtual void moveSelection(Selection s, int newStartFrame);
+    virtual void moveSelection(Selection s, sv_frame_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
     virtual void deleteSelectionInclusive(Selection s);
--- a/layer/ImageLayer.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/ImageLayer.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -110,7 +110,7 @@
 }
 
 bool
-ImageLayer::getValueExtents(float &, float &, bool &, QString &) const
+ImageLayer::getValueExtents(double &, double &, bool &, QString &) const
 {
     return false;
 }
@@ -208,7 +208,7 @@
 //!!! too much overlap with TimeValueLayer/TimeInstantLayer/TextLayer
 
 bool
-ImageLayer::snapToFeatureFrame(View *v, int &frame,
+ImageLayer::snapToFeatureFrame(View *v, sv_frame_t &frame,
 			      int &resolution,
 			      SnapType snap) const
 {
@@ -228,7 +228,7 @@
     }    
 
     points = m_model->getPoints(frame, frame);
-    int snapped = frame;
+    sv_frame_t snapped = frame;
     bool found = false;
 
     for (ImageModel::PointList::const_iterator i = points.begin();
@@ -284,7 +284,7 @@
 {
     if (!m_model || !m_model->isOK()) return;
 
-    int sampleRate = m_model->getSampleRate();
+    sv_samplerate_t sampleRate = m_model->getSampleRate();
     if (!sampleRate) return;
 
 //    Profiler profiler("ImageLayer::paint", true);
@@ -292,8 +292,8 @@
 //    int x0 = rect.left(), x1 = rect.right();
     int x0 = 0, x1 = v->width();
 
-    int frame0 = v->getFrameForX(x0);
-    int frame1 = v->getFrameForX(x1);
+    sv_frame_t frame0 = v->getFrameForX(x0);
+    sv_frame_t frame1 = v->getFrameForX(x1);
 
     ImageModel::PointList points(m_model->getPoints(frame0, frame1));
     if (points.empty()) return;
@@ -563,7 +563,7 @@
 	return;
     }
 
-    int frame = v->getFrameForX(e->x());
+    sv_frame_t frame = v->getFrameForX(e->x());
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
@@ -584,7 +584,7 @@
 
     if (!m_model || !m_editing) return;
 
-    int frame = v->getFrameForX(e->x());
+    sv_frame_t frame = v->getFrameForX(e->x());
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
@@ -619,7 +619,7 @@
 }
 
 bool
-ImageLayer::addImage(int frame, QString url)
+ImageLayer::addImage(sv_frame_t frame, QString url)
 {
     QImage image(getLocalFilename(url));
     if (image.isNull()) {
@@ -664,8 +664,8 @@
 {
     if (!m_model || !m_editing) return;
 
-    int frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x());
-    int frame = m_originalPoint.frame + frameDiff;
+    sv_frame_t frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x());
+    sv_frame_t frame = m_originalPoint.frame + frameDiff;
 
     if (frame < 0) frame = 0;
     frame = (frame / m_model->getResolution()) * m_model->getResolution();
@@ -723,7 +723,7 @@
 }    
 
 void
-ImageLayer::moveSelection(Selection s, int newStartFrame)
+ImageLayer::moveSelection(Selection s, sv_frame_t newStartFrame)
 {
     if (!m_model) return;
 
@@ -767,9 +767,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;
 
 	    ImageModel::Point newPoint(*i);
 	    newPoint.frame = lrint(target);
@@ -819,7 +819,7 @@
 }
 
 bool
-ImageLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */)
+ImageLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */)
 {
     if (!m_model) return false;
 
@@ -852,7 +852,7 @@
         
         if (!i->haveFrame()) continue;
 
-        int frame = 0;
+        sv_frame_t frame = 0;
 
         if (!realign) {
             
--- a/layer/ImageLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/ImageLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -42,7 +42,7 @@
 
     virtual QString getFeatureDescription(View *v, QPoint &) const;
 
-    virtual bool snapToFeatureFrame(View *v, int &frame,
+    virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame,
 				    int &resolution,
 				    SnapType snap) const;
 
@@ -54,12 +54,12 @@
     virtual void editDrag(View *v, QMouseEvent *);
     virtual void editEnd(View *v, QMouseEvent *);
 
-    virtual void moveSelection(Selection s, int newStartFrame);
+    virtual void moveSelection(Selection s, sv_frame_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
 
     virtual void copy(View *v, Selection s, Clipboard &to);
-    virtual bool paste(View *v, const Clipboard &from, int frameOffset,
+    virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset,
                        bool interactive);
 
     virtual bool editOpen(View *, QMouseEvent *); // on double-click
@@ -86,7 +86,7 @@
 
     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &logarithmic, QString &unit) const;
 
     virtual void toXml(QTextStream &stream, QString indent = "",
@@ -98,7 +98,7 @@
 
     void setProperties(const QXmlAttributes &attributes);
 
-    virtual bool addImage(int frame, QString url); // using a command
+    virtual bool addImage(sv_frame_t frame, QString url); // using a command
 
 protected slots:
     void checkAddSources();
--- a/layer/ImageRegionFinder.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/ImageRegionFinder.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -107,9 +107,9 @@
         return false;
     }
 
-    float ar = float(qRed(a) / 255.f);
-    float ag = float(qGreen(a) / 255.f);
-    float ab = float(qBlue(a) / 255.f);
+    float ar = float(qRed(a)) / 255.f;
+    float ag = float(qGreen(a)) / 255.f;
+    float ab = float(qBlue(a)) / 255.f;
     float amag = sqrtf(ar * ar + ag * ag + ab * ab);
     float thresh = amag / 2;
 
--- a/layer/Layer.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/Layer.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -250,12 +250,12 @@
         // reference (i.e. having been copied from the reference
         // model).
         
-        int sourceFrame = i->getFrame();
-        int referenceFrame = sourceFrame;
+        sv_frame_t sourceFrame = i->getFrame();
+        sv_frame_t referenceFrame = sourceFrame;
         if (i->haveReferenceFrame()) {
             referenceFrame = i->getReferenceFrame();
         }
-        int myMappedFrame = alignToReference(v, sourceFrame);
+        sv_frame_t myMappedFrame = alignToReference(v, sourceFrame);
 
 //        cerr << "sourceFrame = " << sourceFrame << ", referenceFrame = " << referenceFrame << " (have = " << i->haveReferenceFrame() << "), myMappedFrame = " << myMappedFrame << endl;
 
@@ -470,8 +470,8 @@
 void
 Layer::updateMeasurePixrects(View *v) const
 {
-    int sf = v->getStartFrame();
-    int ef = v->getEndFrame();
+    sv_frame_t sf = v->getStartFrame();
+    sv_frame_t ef = v->getEndFrame();
 
     for (MeasureRectSet::const_iterator i = m_measureRects.begin(); 
          i != m_measureRects.end(); ++i) {
@@ -509,8 +509,8 @@
 void
 Layer::updateMeasureRectYCoords(View *v, const MeasureRect &r) const
 {
-    int y0 = lrint(r.startY * v->height());
-    int y1 = lrint(r.endY * v->height());
+    int y0 = int(lrint(r.startY * v->height()));
+    int y1 = int(lrint(r.endY * v->height()));
     r.pixrect = QRect(r.pixrect.x(), y0, r.pixrect.width(), y1 - y0);
 }
 
--- a/layer/Layer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/Layer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -254,7 +254,7 @@
      */
     virtual bool editOpen(View *, QMouseEvent *) { return false; }
 
-    virtual void moveSelection(Selection, int /* newStartFrame */) { }
+    virtual void moveSelection(Selection, sv_frame_t /* newStartFrame */) { }
     virtual void resizeSelection(Selection, Selection /* newSize */) { }
     virtual void deleteSelection(Selection) { }
 
@@ -546,8 +546,8 @@
 
         mutable QRect pixrect;
         bool haveFrames;
-        int startFrame; // only valid if haveFrames
-        int endFrame;   // ditto
+        sv_frame_t startFrame; // only valid if haveFrames
+        sv_frame_t endFrame;   // ditto
         double startY;
         double endY;
 
--- a/layer/LinearColourScale.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/LinearColourScale.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -34,15 +34,15 @@
 				 const ColourScaleLayer *layer,
 				 QPainter &paint,
 				 int /* x0 */,
-				 float min,
-				 float max)
+				 double min,
+				 double max)
 {
     int h = v->height();
 
     int n = 10;
 
-    float val = min;
-    float inc = (max - val) / n;
+    double val = min;
+    double inc = (max - val) / n;
     
     const int buflen = 40;
     char buffer[buflen];
@@ -58,16 +58,16 @@
 
     paint.save();
     for (int y = 0; y < boxh; ++y) {
-	float val = ((boxh - y) * (max - min)) / boxh + min;
+	double val = ((boxh - y) * (max - min)) / boxh + min;
 	paint.setPen(layer->getColourForValue(v, val));
 	paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1);
     }
     paint.restore();
 
-//    float round = 1.f;
+//    double round = 1.f;
     int dp = 0;
     if (inc > 0) {
-        int prec = trunc(log10f(inc));
+        int prec = int(trunc(log10(inc)));
         prec -= 1;
         if (prec < 0) dp = -prec;
 //        round = powf(10.f, prec);
--- a/layer/LinearColourScale.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/LinearColourScale.h	Mon Mar 09 14:35:21 2015 +0000
@@ -29,7 +29,7 @@
 
     void paintVertical
     (View *v, const ColourScaleLayer *layer, QPainter &paint, int x0,
-     float minf, float maxf);
+     double minf, double maxf);
 };
 
 #endif
--- a/layer/LinearNumericalScale.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/LinearNumericalScale.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -47,13 +47,13 @@
 
     int w = getWidth(v, paint) + x0;
 
-    double round = 1.f;
+    double round = 1.0;
     int dp = 0;
     if (inc > 0) {
-        int prec = trunc(log10f(inc));
+        int prec = int(trunc(log10(inc)));
         prec -= 1;
         if (prec < 0) dp = -prec;
-        round = powf(10.f, prec);
+        round = pow(10.0, prec);
 #ifdef DEBUG_TIME_VALUE_LAYER
         cerr << "inc = " << inc << ", round = " << round << ", dp = " << dp << endl;
 #endif
@@ -72,7 +72,7 @@
 	    v->height() < paint.fontMetrics().height() * (n*2)) {
 	    if (layer->getScaleUnits() != "") drawText = false;
 	}
-	dispval = lrintf(val / round) * round;
+	dispval = int(rint(val / round) * round);
 
 #ifdef DEBUG_TIME_VALUE_LAYER
 	cerr << "val = " << val << ", dispval = " << dispval << endl;
--- a/layer/LogColourScale.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/LogColourScale.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -36,15 +36,15 @@
 			      const ColourScaleLayer *layer,
 			      QPainter &paint,
 			      int /* x0 */,
-			      float minlog,
-			      float maxlog)
+			      double minlog,
+			      double maxlog)
 {
     int h = v->height();
 
     int n = 10;
 
-    float val = minlog;
-    float inc = (maxlog - val) / n;
+    double val = minlog;
+    double inc = (maxlog - val) / n;
 
     const int buflen = 40;
     char buffer[buflen];
@@ -60,7 +60,7 @@
 
     paint.save();
     for (int y = 0; y < boxh; ++y) {
-	float val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog;
+	double val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog;
 	paint.setPen(layer->getColourForValue(v, LogRange::unmap(val)));
 	paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1);
     }
@@ -68,7 +68,7 @@
 
     int dp = 0;
     if (inc > 0) {
-        int prec = trunc(log10f(inc));
+        int prec = int(trunc(log10(inc)));
         prec -= 1;
         if (prec < 0) dp = -prec;
     }
@@ -83,7 +83,7 @@
 	    paint.fontMetrics().ascent() + 2;
 
 	double dv = LogRange::unmap(val);
-	int digits = trunc(log10f(dv));
+	int digits = int(trunc(log10(dv)));
 	int sf = dp + (digits > 0 ? digits : 0);
 	if (sf < 2) sf = 2;
 	snprintf(buffer, buflen, "%.*g", sf, dv);
--- a/layer/LogColourScale.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/LogColourScale.h	Mon Mar 09 14:35:21 2015 +0000
@@ -29,7 +29,7 @@
 
     void paintVertical
     (View *v, const ColourScaleLayer *layer, QPainter &paint, int x0,
-     float minf, float maxf);
+     double minf, double maxf);
 };
 
 #endif
--- a/layer/LogNumericalScale.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/LogNumericalScale.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -62,9 +62,9 @@
     int dp = 0;
 
     if (minDispInc > 0) {
-        int prec = trunc(log10f(minDispInc));
+        int prec = int(trunc(log10(minDispInc)));
         if (prec < 0) dp = -prec;
-        round = powf(10.f, prec);
+        round = pow(10.0, prec);
         if (dp > 4) dp = 4;
 #ifdef DEBUG_TIME_VALUE_LAYER
         cerr << "round = " << round << ", prec = " << prec << ", dp = " << dp << endl;
@@ -99,7 +99,7 @@
 	    continue;
         }
 
-	int digits = trunc(log10f(dispval));
+	int digits = int(trunc(log10(dispval)));
 	int sf = dp + (digits > 0 ? digits : 0);
 	if (sf < 4) sf = 4;
 #ifdef DEBUG_TIME_VALUE_LAYER
--- a/layer/NoteLayer.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/NoteLayer.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -209,7 +209,7 @@
 }
 
 bool
-NoteLayer::getValueExtents(float &min, float &max,
+NoteLayer::getValueExtents(double &min, double &max,
                            bool &logarithmic, QString &unit) const
 {
     if (!m_model) return false;
@@ -218,8 +218,8 @@
 
     if (shouldConvertMIDIToHz()) {
         unit = "Hz";
-        min = Pitch::getFrequencyForPitch(lrintf(min));
-        max = Pitch::getFrequencyForPitch(lrintf(max + 1));
+        min = Pitch::getFrequencyForPitch(int(lrint(min)));
+        max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
     } else unit = getScaleUnits();
 
     if (m_verticalScale == MIDIRangeScale ||
@@ -229,7 +229,7 @@
 }
 
 bool
-NoteLayer::getDisplayExtents(float &min, float &max) const
+NoteLayer::getDisplayExtents(double &min, double &max) const
 {
     if (!m_model || shouldAutoAlign()) return false;
 
@@ -248,8 +248,8 @@
     }
 
     if (shouldConvertMIDIToHz()) {
-        min = Pitch::getFrequencyForPitch(lrintf(min));
-        max = Pitch::getFrequencyForPitch(lrintf(max + 1));
+        min = Pitch::getFrequencyForPitch(int(lrint(min)));
+        max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
     }
 
 #ifdef DEBUG_NOTE_LAYER
@@ -260,7 +260,7 @@
 }
 
 bool
-NoteLayer::setDisplayExtents(float min, float max)
+NoteLayer::setDisplayExtents(double min, double max)
 {
     if (!m_model) return false;
 
@@ -302,7 +302,7 @@
     RangeMapper *mapper = getNewVerticalZoomRangeMapper();
     if (!mapper) return 0;
 
-    float dmin, dmax;
+    double dmin, dmax;
     getDisplayExtents(dmin, dmax);
 
     int nr = mapper->getPositionForValue(dmax - dmin);
@@ -323,29 +323,29 @@
     RangeMapper *mapper = getNewVerticalZoomRangeMapper();
     if (!mapper) return;
     
-    float min, max;
+    double min, max;
     bool logarithmic;
     QString unit;
     getValueExtents(min, max, logarithmic, unit);
     
-    float dmin, dmax;
+    double dmin, dmax;
     getDisplayExtents(dmin, dmax);
 
-    float newdist = mapper->getValueForPosition(100 - step);
+    double newdist = mapper->getValueForPosition(100 - step);
 
-    float newmin, newmax;
+    double newmin, newmax;
 
     if (logarithmic) {
 
         // see SpectrogramLayer::setVerticalZoomStep
 
-        newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2;
+        newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2;
         newmin = newmax - newdist;
 
 //        cerr << "newmin = " << newmin << ", newmax = " << newmax << endl;
 
     } else {
-        float dmid = (dmax + dmin) / 2;
+        double dmid = (dmax + dmin) / 2;
         newmin = dmid - newdist / 2;
         newmax = dmid + newdist / 2;
     }
@@ -372,7 +372,7 @@
     
     RangeMapper *mapper;
 
-    float min, max;
+    double min, max;
     bool logarithmic;
     QString unit;
     getValueExtents(min, max, logarithmic, unit);
@@ -393,7 +393,7 @@
 {
     if (!m_model) return NoteModel::PointList();
 
-    int frame = v->getFrameForX(x);
+    sv_frame_t frame = v->getFrameForX(x);
 
     NoteModel::PointList onPoints =
 	m_model->getPoints(frame);
@@ -436,7 +436,7 @@
 {
     if (!m_model) return false;
 
-    int frame = v->getFrameForX(x);
+    sv_frame_t frame = v->getFrameForX(x);
 
     NoteModel::PointList onPoints = m_model->getPoints(frame);
     if (onPoints.empty()) return false;
@@ -506,9 +506,9 @@
 
     if (shouldConvertMIDIToHz()) {
 
-        int mnote = lrintf(note.value);
-        int cents = lrintf((note.value - mnote) * 100);
-        float freq = Pitch::getFrequencyForPitch(mnote, cents);
+        int mnote = int(lrint(note.value));
+        int cents = int(lrint((note.value - float(mnote)) * 100));
+        double freq = Pitch::getFrequencyForPitch(mnote, cents);
         pitchText = tr("%1 (%2, %3 Hz)")
             .arg(Pitch::getPitchLabel(mnote, cents))
             .arg(mnote)
@@ -547,7 +547,7 @@
 }
 
 bool
-NoteLayer::snapToFeatureFrame(View *v, int &frame,
+NoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame,
 			      int &resolution,
 			      SnapType snap) const
 {
@@ -567,7 +567,7 @@
     }    
 
     points = m_model->getPoints(frame, frame);
-    int snapped = frame;
+    sv_frame_t snapped = frame;
     bool found = false;
 
     for (NoteModel::PointList::const_iterator i = points.begin();
@@ -619,7 +619,7 @@
 }
 
 void
-NoteLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const
+NoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const
 {
     min = 0.0;
     max = 0.0;
@@ -637,8 +637,8 @@
             max = m_model->getValueMaximum();
 
             if (shouldConvertMIDIToHz()) {
-                min = Pitch::getFrequencyForPitch(lrintf(min));
-                max = Pitch::getFrequencyForPitch(lrintf(max + 1));
+                min = Pitch::getFrequencyForPitch(int(lrint(min)));
+                max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
             }
 
 #ifdef DEBUG_NOTE_LAYER
@@ -663,8 +663,8 @@
             min = Pitch::getFrequencyForPitch(0);
             max = Pitch::getFrequencyForPitch(127);
         } else if (shouldConvertMIDIToHz()) {
-            min = Pitch::getFrequencyForPitch(lrintf(min));
-            max = Pitch::getFrequencyForPitch(lrintf(max + 1));
+            min = Pitch::getFrequencyForPitch(int(lrint(min)));
+            max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
         }
 
         if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) {
@@ -677,9 +677,9 @@
 }
 
 int
-NoteLayer::getYForValue(View *v, float val) const
+NoteLayer::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();
 
@@ -690,8 +690,8 @@
 #endif
 
     if (shouldConvertMIDIToHz()) {
-        val = Pitch::getFrequencyForPitch(lrintf(val),
-                                          lrintf((val - lrintf(val)) * 100));
+        val = Pitch::getFrequencyForPitch(int(lrint(val)),
+                                          int(lrint((val - rint(val)) * 100)));
 #ifdef DEBUG_NOTE_LAYER
         cerr << "shouldConvertMIDIToHz true, val now = " << val << endl;
 #endif
@@ -711,19 +711,19 @@
     return y;
 }
 
-float
+double
 NoteLayer::getValueForY(View *v, int y) const
 {
-    float min = 0.0, max = 0.0;
+    double min = 0.0, max = 0.0;
     bool logarithmic = false;
     int h = v->height();
 
     getScaleExtents(v, min, max, logarithmic);
 
-    float val = min + (float(h - y) * float(max - min)) / h;
+    double val = min + (double(h - y) * double(max - min)) / h;
 
     if (logarithmic) {
-        val = powf(10.f, val);
+        val = pow(10.0, val);
     }
 
     if (shouldConvertMIDIToHz()) {
@@ -745,14 +745,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("NoteLayer::paint", true);
 
     int x0 = rect.left(), x1 = rect.right();
-    int frame0 = v->getFrameForX(x0);
-    int frame1 = v->getFrameForX(x1);
+    sv_frame_t frame0 = v->getFrameForX(x0);
+    sv_frame_t frame1 = v->getFrameForX(x1);
 
     NoteModel::PointList points(m_model->getPoints(frame0, frame1));
     if (points.empty()) return;
@@ -765,8 +765,8 @@
 //    SVDEBUG << "NoteLayer::paint: resolution is "
 //	      << m_model->getResolution() << " frames" << endl;
 
-    float min = m_model->getValueMinimum();
-    float max = m_model->getValueMaximum();
+    double min = m_model->getValueMinimum();
+    double max = m_model->getValueMaximum();
     if (max == min) max = min + 1.0;
 
     QPoint localPos;
@@ -849,7 +849,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);
@@ -888,13 +888,13 @@
 
     if (!m_model) return;
 
-    int frame = v->getFrameForX(e->x());
+    sv_frame_t frame = v->getFrameForX(e->x());
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
-    float value = getValueForY(v, e->y());
+    double value = getValueForY(v, e->y());
 
-    m_editingPoint = NoteModel::Point(frame, value, 0, 0.8, tr("New Point"));
+    m_editingPoint = NoteModel::Point(frame, float(value), 0, 0.8f, tr("New Point"));
     m_originalPoint = m_editingPoint;
 
     if (m_editingCommand) finish(m_editingCommand);
@@ -912,14 +912,14 @@
 
     if (!m_model || !m_editing) return;
 
-    int frame = v->getFrameForX(e->x());
+    sv_frame_t frame = v->getFrameForX(e->x());
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
-    float newValue = getValueForY(v, e->y());
+    double newValue = getValueForY(v, e->y());
 
-    int newFrame = m_editingPoint.frame;
-    int newDuration = frame - newFrame;
+    sv_frame_t newFrame = m_editingPoint.frame;
+    sv_frame_t newDuration = frame - newFrame;
     if (newDuration < 0) {
         newFrame = frame;
         newDuration = -newDuration;
@@ -929,7 +929,7 @@
 
     m_editingCommand->deletePoint(m_editingPoint);
     m_editingPoint.frame = newFrame;
-    m_editingPoint.value = newValue;
+    m_editingPoint.value = float(newValue);
     m_editingPoint.duration = newDuration;
     m_editingCommand->addPoint(m_editingPoint);
 }
@@ -1019,11 +1019,11 @@
     int newx = m_dragPointX + xdist;
     int newy = m_dragPointY + ydist;
 
-    int frame = v->getFrameForX(newx);
+    sv_frame_t frame = v->getFrameForX(newx);
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
-    float value = getValueForY(v, newy);
+    double value = getValueForY(v, newy);
 
     if (!m_editingCommand) {
 	m_editingCommand = new NoteModel::EditCommand(m_model,
@@ -1032,7 +1032,7 @@
 
     m_editingCommand->deletePoint(m_editingPoint);
     m_editingPoint.frame = frame;
-    m_editingPoint.value = value;
+    m_editingPoint.value = float(value);
     m_editingCommand->addPoint(m_editingPoint);
 }
 
@@ -1107,7 +1107,7 @@
 }
 
 void
-NoteLayer::moveSelection(Selection s, int newStartFrame)
+NoteLayer::moveSelection(Selection s, sv_frame_t newStartFrame)
 {
     if (!m_model) return;
 
@@ -1151,13 +1151,13 @@
 
 	if (s.contains(i->frame)) {
 
-	    double targetStart = i->frame;
-	    targetStart = newSize.getStartFrame() + 
-		double(targetStart - s.getStartFrame()) * ratio;
+	    double targetStart = double(i->frame);
+	    targetStart = double(newSize.getStartFrame()) +
+		targetStart - double(s.getStartFrame()) * ratio;
 
-	    double targetEnd = i->frame + i->duration;
-	    targetEnd = newSize.getStartFrame() +
-		double(targetEnd - s.getStartFrame()) * ratio;
+	    double targetEnd = double(i->frame + i->duration);
+	    targetEnd = double(newSize.getStartFrame()) +
+		targetEnd - double(s.getStartFrame()) * ratio;
 
 	    NoteModel::Point newPoint(*i);
 	    newPoint.frame = lrint(targetStart);
@@ -1211,7 +1211,7 @@
 }
 
 bool
-NoteLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */)
+NoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */)
 {
     if (!m_model) return false;
 
@@ -1243,7 +1243,7 @@
          i != points.end(); ++i) {
         
         if (!i->haveFrame()) continue;
-        int frame = 0;
+        sv_frame_t frame = 0;
 
         if (!realign) {
             
@@ -1268,7 +1268,7 @@
         if (i->haveLevel()) newPoint.level = i->getLevel();
         if (i->haveDuration()) newPoint.duration = i->getDuration();
         else {
-            int nextFrame = frame;
+            sv_frame_t nextFrame = frame;
             Clipboard::PointList::const_iterator j = i;
             for (; j != points.end(); ++j) {
                 if (!j->haveFrame()) continue;
@@ -1292,13 +1292,13 @@
 }
 
 void
-NoteLayer::addNoteOn(int frame, int pitch, int velocity)
+NoteLayer::addNoteOn(sv_frame_t frame, int pitch, int velocity)
 {
-    m_pendingNoteOns.insert(Note(frame, pitch, 0, float(velocity) / 127.0, ""));
+    m_pendingNoteOns.insert(Note(frame, float(pitch), 0, float(velocity) / 127.f, ""));
 }
 
 void
-NoteLayer::addNoteOff(int frame, int pitch)
+NoteLayer::addNoteOff(sv_frame_t frame, int pitch)
 {
     for (NoteSet::iterator i = m_pendingNoteOns.begin();
          i != m_pendingNoteOns.end(); ++i) {
--- a/layer/NoteLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/NoteLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -42,7 +42,7 @@
 
     virtual QString getFeatureDescription(View *v, QPoint &) const;
 
-    virtual bool snapToFeatureFrame(View *v, int &frame,
+    virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame,
 				    int &resolution,
 				    SnapType snap) const;
 
@@ -60,12 +60,12 @@
 
     virtual bool editOpen(View *v, QMouseEvent *);
 
-    virtual void moveSelection(Selection s, int newStartFrame);
+    virtual void moveSelection(Selection s, sv_frame_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
 
     virtual void copy(View *v, Selection s, Clipboard &to);
-    virtual bool paste(View *v, const Clipboard &from, int frameOffset,
+    virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset,
                        bool interactive);
 
     virtual const Model *getModel() const { return m_model; }
@@ -97,11 +97,11 @@
 
     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &log, QString &unit) const;
 
-    virtual bool getDisplayExtents(float &min, float &max) const;
-    virtual bool setDisplayExtents(float min, float max);
+    virtual bool getDisplayExtents(double &min, double &max) const;
+    virtual bool setDisplayExtents(double min, double max);
 
     virtual int getVerticalZoomSteps(int &defaultStep) const;
     virtual int getCurrentVerticalZoomStep() const;
@@ -113,13 +113,13 @@
      * not be finally added to the layer until the corresponding
      * note-off.
      */
-    void addNoteOn(int frame, int pitch, int velocity);
+    void addNoteOn(sv_frame_t frame, int pitch, int velocity);
     
     /**
      * Add a note-off.  This will cause a note to appear, if and only
      * if there is a matching pending note-on.
      */
-    void addNoteOff(int frame, int pitch);
+    void addNoteOff(sv_frame_t frame, int pitch);
 
     /**
      * Abandon all pending note-on events.
@@ -132,12 +132,12 @@
     void setProperties(const QXmlAttributes &attributes);
 
     /// VerticalScaleLayer methods
-    virtual int getYForValue(View *v, float value) const;
-    virtual float getValueForY(View *v, int y) const;
+    virtual int getYForValue(View *v, double value) const;
+    virtual double getValueForY(View *v, int y) const;
     virtual QString getScaleUnits() const;
 
 protected:
-    void getScaleExtents(View *, float &min, float &max, bool &log) const;
+    void getScaleExtents(View *, double &min, double &max, bool &log) const;
     bool shouldConvertMIDIToHz() const;
 
     virtual int getDefaultColourHint(bool dark, bool &impose);
@@ -160,8 +160,8 @@
     typedef std::set<NoteModel::Point, NoteModel::Point::Comparator> NoteSet;
     NoteSet m_pendingNoteOns;
 
-    mutable float m_scaleMinimum;
-    mutable float m_scaleMaximum;
+    mutable double m_scaleMinimum;
+    mutable double m_scaleMaximum;
 
     bool shouldAutoAlign() const;
 
--- a/layer/PaintAssistant.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/PaintAssistant.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -25,11 +25,11 @@
 
 void
 PaintAssistant::paintVerticalLevelScale(QPainter &paint, QRect rect,
-					float minVal, float maxVal,
+					double minVal, double maxVal,
                                         Scale scale, int &mult,
                                         std::vector<int> *vy)
 {
-    static float meterdbs[] = { -40, -30, -20, -15, -10,
+    static double meterdbs[] = { -40, -30, -20, -15, -10,
                                 -5, -3, -2, -1, -0.5, 0 };
 
     int h = rect.height(), w = rect.width();
@@ -41,7 +41,7 @@
     int n = 10;
     if (vy) vy->clear();
 
-    float step = 0;
+    double step = 0;
     mult = 1;
     if (scale == LinearScale) {
         step = (maxVal - minVal) / n;
@@ -53,8 +53,8 @@
         if (round) {
             mult /= 10;
 //            cerr << "\n\nstep goes from " << step;
-            step = float(round) / mult;
-            n = lrintf((maxVal - minVal) / step);
+            step = double(round) / mult;
+            n = int(lrint((maxVal - minVal) / step));
             if (mult > 1) {
                 mult /= 10;
             }
@@ -64,7 +64,7 @@
 
     for (int i = 0; i <= n; ++i) {
         
-        float val = 0.0, nval = 0.0;
+        double val = 0.0, nval = 0.0;
         QString text = "";
 
         switch (scale) {
@@ -166,20 +166,20 @@
 }
 
 static int
-dBscale(float sample, int m, float maxVal, float minVal) 
+dBscale(double sample, int m, double maxVal, double minVal) 
 {
     if (sample < 0.0) return dBscale(-sample, m, maxVal, minVal);
-    float dB = AudioLevel::multiplier_to_dB(sample);
-    float mindB = AudioLevel::multiplier_to_dB(minVal);
-    float maxdB = AudioLevel::multiplier_to_dB(maxVal);
+    double dB = AudioLevel::multiplier_to_dB(sample);
+    double mindB = AudioLevel::multiplier_to_dB(minVal);
+    double maxdB = AudioLevel::multiplier_to_dB(maxVal);
     if (dB < mindB) return 0;
     if (dB > 0.0) return m;
     return int(((dB - mindB) * m) / (maxdB - mindB) + 0.1);
 }
 
 int
-PaintAssistant::getYForValue(Scale scale, float value, 
-                             float minVal, float maxVal,
+PaintAssistant::getYForValue(Scale scale, double value, 
+                             double minVal, double maxVal,
                              int minY, int height)
 {
     int vy = 0;
--- a/layer/PaintAssistant.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/PaintAssistant.h	Mon Mar 09 14:35:21 2015 +0000
@@ -27,12 +27,12 @@
     enum Scale { LinearScale, MeterScale, dBScale };
 
     static void paintVerticalLevelScale(QPainter &p, QRect rect,
-                                        float minVal, float maxVal,
+                                        double minVal, double maxVal,
                                         Scale scale, int &multRtn,
                                         std::vector<int> *markCoordRtns = 0);
 
-    static int getYForValue(Scale scale, float value,
-                            float minVal, float maxVal,
+    static int getYForValue(Scale scale, double value,
+                            double minVal, double maxVal,
                             int minY, int height);
 };
 
--- a/layer/PianoScale.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/PianoScale.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -40,7 +40,7 @@
     for (int i = 0; i < 128; ++i) {
 
 	double f = Pitch::getFrequencyForPitch(i);
-	int y = lrintf(v->getYForFrequency(f, minf, maxf, true));
+	int y = int(lrint(v->getYForFrequency(f, minf, maxf, true)));
 
 	if (y < y0 - 2) break;
 	if (y > y1 + 2) {
--- a/layer/RegionLayer.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/RegionLayer.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -275,7 +275,7 @@
 }
 
 bool
-RegionLayer::getValueExtents(float &min, float &max,
+RegionLayer::getValueExtents(double &min, double &max,
                            bool &logarithmic, QString &unit) const
 {
     if (!m_model) return false;
@@ -289,7 +289,7 @@
 }
 
 bool
-RegionLayer::getDisplayExtents(float &min, float &max) const
+RegionLayer::getDisplayExtents(double &min, double &max) const
 {
     if (!m_model ||
         m_verticalScale == AutoAlignScale ||
@@ -453,7 +453,7 @@
 }
 
 bool
-RegionLayer::snapToFeatureFrame(View *v, int &frame,
+RegionLayer::snapToFeatureFrame(View *v, sv_frame_t &frame,
                                 int &resolution,
                                 SnapType snap) const
 {
@@ -473,7 +473,7 @@
     }    
 
     points = m_model->getPoints(frame, frame);
-    int snapped = frame;
+    sv_frame_t snapped = frame;
     bool found = false;
 
     for (RegionModel::PointList::const_iterator i = points.begin();
@@ -536,7 +536,7 @@
 }
 
 bool
-RegionLayer::snapToSimilarFeature(View *v, int &frame,
+RegionLayer::snapToSimilarFeature(View *v, sv_frame_t &frame,
                                   int &resolution,
                                   SnapType snap) const
 {
@@ -551,8 +551,8 @@
 
     RegionModel::PointList::const_iterator i;
 
-    int matchframe = frame;
-    float matchvalue = 0.f;
+    sv_frame_t matchframe = frame;
+    double matchvalue = 0.f;
 
     for (i = close.begin(); i != close.end(); ++i) {
         if (i->frame > frame) break;
@@ -560,10 +560,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();
 
@@ -588,7 +588,7 @@
 	if (snap == SnapRight) {
 
 	    if (i->frame > matchframe &&
-                fabsf(i->value - matchvalue) < epsilon) {
+                fabs(i->value - matchvalue) < epsilon) {
 		snapped = i->frame;
 		found = true;
 		break;
@@ -597,7 +597,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
                 }
@@ -624,7 +624,7 @@
 }
 
 void
-RegionLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const
+RegionLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const
 {
     min = 0.0;
     max = 0.0;
@@ -679,28 +679,28 @@
 RegionLayer::spacingIndexToY(View *v, int i) const
 {
     int h = v->height();
-    int n = m_spacingMap.size();
+    int n = int(m_spacingMap.size());
     // this maps from i (spacing of the value from the spacing
     // map) and n (number of region types) to y
     int y = h - (((h * i) / n) + (h / (2 * n)));
     return y;
 }
 
-float
+double
 RegionLayer::yToSpacingIndex(View *v, int y) const
 {
-    // we return an inexact result here (float rather than int)
+    // we return an inexact result here (double rather than int)
     int h = v->height();
-    int n = m_spacingMap.size();
+    int n = int(m_spacingMap.size());
     // from y = h - ((h * i) / n) + (h / (2 * n)) as above (vh taking place of i)
-    float vh = float(2*h*n - h - 2*n*y) / float(2*h);
+    double vh = double(2*h*n - h - 2*n*y) / double(2*h);
     return vh;
 }
 
 int
-RegionLayer::getYForValue(View *v, float val) const
+RegionLayer::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();
 
@@ -732,16 +732,16 @@
     }
 }
 
-float
+double
 RegionLayer::getValueForY(View *v, int y) const
 {
     return getValueForY(v, y, -1);
 }
 
-float
+double
 RegionLayer::getValueForY(View *v, int y, int avoid) const
 {
-    float min = 0.0, max = 0.0;
+    double min = 0.0, max = 0.0;
     bool logarithmic = false;
     int h = v->height();
 
@@ -757,14 +757,14 @@
         // one of the m/n divisions in the y scale, we should snap to
         // the value of the mth region.
 
-        float vh = yToSpacingIndex(v, y);
+        double vh = yToSpacingIndex(v, y);
 
         // spacings in the map are integral, so find the closest one,
         // map it back to its y coordinate, and see how far we are
         // from it
 
-        int n = m_spacingMap.size();
-        int ivh = lrintf(vh);
+        int n = int(m_spacingMap.size());
+        int ivh = int(lrint(vh));
         if (ivh < 0) ivh = 0;
         if (ivh > n-1) ivh = n-1;
         int iy = spacingIndexToY(v, ivh);
@@ -783,7 +783,7 @@
 
 //        cerr << "nearest existing value = " << i->first << " at " << iy << endl;
 
-        float val = 0;
+        double val = 0;
 
 //        cerr << "note: avoid = " << avoid << ", i->second = " << i->second << endl;
 
@@ -825,10 +825,10 @@
 
         getScaleExtents(v, min, max, logarithmic);
 
-        float val = min + (float(h - y) * float(max - min)) / h;
+        double val = min + (double(h - y) * double(max - min)) / h;
 
         if (logarithmic) {
-            val = powf(10.f, val);
+            val = pow(10.0, val);
         }
 
         return val;
@@ -836,9 +836,9 @@
 }
 
 QColor
-RegionLayer::getColourForValue(View *v, float val) const
+RegionLayer::getColourForValue(View *v, double val) const
 {
-    float min, max;
+    double min, max;
     bool log;
     getScaleExtents(v, min, max, log);
 
@@ -870,14 +870,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("RegionLayer::paint", true);
 
     int x0 = rect.left() - 40, 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);
 
     RegionModel::PointList points(m_model->getPoints(frame0, frame1));
     if (points.empty()) return;
@@ -890,8 +890,8 @@
 //    SVDEBUG << "RegionLayer::paint: resolution is "
 //	      << m_model->getResolution() << " frames" << endl;
 
-    float min = m_model->getValueMinimum();
-    float max = m_model->getValueMaximum();
+    double min = m_model->getValueMinimum();
+    double max = m_model->getValueMaximum();
     if (max == min) max = min + 1.0;
 
     QPoint localPos;
@@ -1083,7 +1083,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);
@@ -1129,9 +1129,9 @@
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
-    float value = getValueForY(v, e->y());
+    double value = getValueForY(v, e->y());
 
-    m_editingPoint = RegionModel::Point(frame, value, 0, "");
+    m_editingPoint = RegionModel::Point(frame, float(value), 0, "");
     m_originalPoint = m_editingPoint;
 
     if (m_editingCommand) finish(m_editingCommand);
@@ -1149,15 +1149,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 newValue = m_editingPoint.value;
+    double newValue = m_editingPoint.value;
     if (m_verticalScale != EqualSpaced) newValue = getValueForY(v, e->y());
 
-    long newFrame = m_editingPoint.frame;
-    long newDuration = frame - newFrame;
+    sv_frame_t newFrame = m_editingPoint.frame;
+    sv_frame_t newDuration = frame - newFrame;
     if (newDuration < 0) {
         newFrame = frame;
         newDuration = -newDuration;
@@ -1167,7 +1167,7 @@
 
     m_editingCommand->deletePoint(m_editingPoint);
     m_editingPoint.frame = newFrame;
-    m_editingPoint.value = newValue;
+    m_editingPoint.value = float(newValue);
     m_editingPoint.duration = newDuration;
     m_editingCommand->addPoint(m_editingPoint);
 
@@ -1274,7 +1274,7 @@
     // ... unless there are other points with the same value
     if (m_distributionMap[m_editingPoint.value] > 1) avoid = -1;
 
-    float value = getValueForY(v, newy, avoid);
+    double value = getValueForY(v, newy, avoid);
 
     if (!m_editingCommand) {
 	m_editingCommand = new RegionModel::EditCommand(m_model,
@@ -1283,7 +1283,7 @@
 
     m_editingCommand->deletePoint(m_editingPoint);
     m_editingPoint.frame = frame;
-    m_editingPoint.value = value;
+    m_editingPoint.value = float(value);
     m_editingCommand->addPoint(m_editingPoint);
     recalcSpacing();
 }
@@ -1358,7 +1358,7 @@
 }
 
 void
-RegionLayer::moveSelection(Selection s, int newStartFrame)
+RegionLayer::moveSelection(Selection s, sv_frame_t newStartFrame)
 {
     if (!m_model) return;
 
@@ -1403,13 +1403,13 @@
 
 	if (s.contains(i->frame)) {
 
-	    double targetStart = i->frame;
-	    targetStart = newSize.getStartFrame() + 
-		double(targetStart - s.getStartFrame()) * ratio;
+	    double targetStart = double(i->frame);
+	    targetStart = double(newSize.getStartFrame()) +
+		targetStart - double(s.getStartFrame()) * ratio;
 
-	    double targetEnd = i->frame + i->duration;
-	    targetEnd = newSize.getStartFrame() +
-		double(targetEnd - s.getStartFrame()) * ratio;
+	    double targetEnd = double(i->frame + i->duration);
+	    targetEnd = double(newSize.getStartFrame()) +
+		targetEnd - double(s.getStartFrame()) * ratio;
 
 	    RegionModel::Point newPoint(*i);
 	    newPoint.frame = lrint(targetStart);
@@ -1465,7 +1465,7 @@
 }
 
 bool
-RegionLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */)
+RegionLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */)
 {
     if (!m_model) return false;
 
@@ -1497,7 +1497,7 @@
          i != points.end(); ++i) {
         
         if (!i->haveFrame()) continue;
-        int frame = 0;
+        sv_frame_t frame = 0;
 
         if (!realign) {
             
@@ -1521,7 +1521,7 @@
                                m_model->getValueMaximum()) / 2;
         if (i->haveDuration()) newPoint.duration = i->getDuration();
         else {
-            int nextFrame = frame;
+            sv_frame_t nextFrame = frame;
             Clipboard::PointList::const_iterator j = i;
             for (; j != points.end(); ++j) {
                 if (!j->haveFrame()) continue;
--- a/layer/RegionLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/RegionLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -47,10 +47,10 @@
     virtual QString getFeatureDescription(View *v, QPoint &) const;
     virtual QString getLabelPreceding(int) const;
 
-    virtual bool snapToFeatureFrame(View *v, int &frame,
+    virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame,
 				    int &resolution,
 				    SnapType snap) const;
-    virtual bool snapToSimilarFeature(View *v, int &frame,
+    virtual bool snapToSimilarFeature(View *v, sv_frame_t &frame,
                                       int &resolution,
                                       SnapType snap) const;
 
@@ -68,12 +68,12 @@
 
     virtual bool editOpen(View *v, QMouseEvent *);
 
-    virtual void moveSelection(Selection s, int newStartFrame);
+    virtual void moveSelection(Selection s, sv_frame_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
 
     virtual void copy(View *v, Selection s, Clipboard &to);
-    virtual bool paste(View *v, const Clipboard &from, int frameOffset,
+    virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset,
                        bool interactive);
 
     virtual const Model *getModel() const { return m_model; }
@@ -116,10 +116,10 @@
 
     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &log, QString &unit) const;
 
-    virtual bool getDisplayExtents(float &min, float &max) const;
+    virtual bool getDisplayExtents(double &min, double &max) const;
 
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
@@ -127,17 +127,17 @@
     void setProperties(const QXmlAttributes &attributes);
 
     /// VerticalScaleLayer and ColourScaleLayer methods
-    int getYForValue(View *v, float value) const;
-    float getValueForY(View *v, int y) const;
+    int getYForValue(View *v, double value) const;
+    double getValueForY(View *v, int y) const;
     virtual QString getScaleUnits() const;
-    QColor getColourForValue(View *v, float value) const;
+    QColor getColourForValue(View *v, double value) const;
 
 protected slots:
     void recalcSpacing();
 
 protected:
-    float getValueForY(View *v, int y, int avoid) const;
-    void getScaleExtents(View *, float &min, float &max, bool &log) const;
+    double getValueForY(View *v, int y, int avoid) const;
+    void getScaleExtents(View *, double &min, double &max, bool &log) const;
 
     virtual int getDefaultColourHint(bool dark, bool &impose);
 
@@ -158,7 +158,7 @@
     int m_colourMap;
     PlotStyle m_plotStyle;
 
-    typedef std::map<float, int> SpacingMap;
+    typedef std::map<double, int> SpacingMap;
 
     // region value -> ordering
     SpacingMap m_spacingMap;
@@ -167,7 +167,7 @@
     SpacingMap m_distributionMap;
 
     int spacingIndexToY(View *v, int i) const;
-    float yToSpacingIndex(View *v, int y) const;
+    double yToSpacingIndex(View *v, int y) const;
 
     void finish(RegionModel::EditCommand *command) {
         Command *c = command->finish();
--- a/layer/SliceLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/SliceLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -62,7 +62,7 @@
     virtual void setProperty(const PropertyName &, int value);
     virtual void setProperties(const QXmlAttributes &);
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &logarithmic, QString &unit) const;
 
     virtual bool hasTimeXAxis() const { return false; }
@@ -93,7 +93,7 @@
     BinScale getBinScale() const { return m_binScale; }
 
     void setThreshold(float);
-    int getThreshold() const { return m_threshold; }
+    float getThreshold() const { return m_threshold; }
 
     void setGain(float gain);
     float getGain() const;
@@ -109,11 +109,11 @@
     void modelAboutToBeDeleted(Model *);
 
 protected:
-    virtual float getXForBin(int bin, int totalBins, float w) const;
-    virtual int getBinForX(float x, int totalBins, float w) const;
+    virtual double getXForBin(int bin, int totalBins, double w) const;
+    virtual int getBinForX(double x, int totalBins, double w) const;
 
-    virtual float getYForValue(float value, const View *v, float &norm) const;
-    virtual float getValueForY(float y, const View *v) const;
+    virtual double getYForValue(double value, const View *v, double &norm) const;
+    virtual double getValueForY(double y, const View *v) const;
     
     virtual QString getFeatureDescriptionAux(View *v, QPoint &,
                                              bool includeBinDescription,
--- a/layer/SpectrogramLayer.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/SpectrogramLayer.cpp	Mon Mar 09 14:35:21 2015 +0000
@@ -1263,11 +1263,11 @@
     return value;
 }
 
-float
+double
 SpectrogramLayer::getEffectiveMinFrequency() const
 {
     int sr = m_model->getSampleRate();
-    float minf = float(sr) / m_fftSize;
+    double minf = double(sr) / m_fftSize;
 
     if (m_minFrequency > 0.0) {
 	int minbin = int((double(m_minFrequency) * m_fftSize) / sr + 0.01);
@@ -1278,11 +1278,11 @@
     return minf;
 }
 
-float
+double
 SpectrogramLayer::getEffectiveMaxFrequency() const
 {
     int sr = m_model->getSampleRate();
-    float maxf = float(sr) / 2;
+    double maxf = double(sr) / 2;
 
     if (m_maxFrequency > 0.0) {
 	int maxbin = int((double(m_maxFrequency) * m_fftSize) / sr + 0.1);
@@ -1294,7 +1294,7 @@
 }
 
 bool
-SpectrogramLayer::getYBinRange(View *v, int y, float &q0, float &q1) const
+SpectrogramLayer::getYBinRange(View *v, int y, double &q0, double &q1) const
 {
     Profiler profiler("SpectrogramLayer::getYBinRange");
     
@@ -1302,8 +1302,8 @@
     if (y < 0 || y >= h) return false;
 
     int sr = m_model->getSampleRate();
-    float minf = getEffectiveMinFrequency();
-    float maxf = getEffectiveMaxFrequency();
+    double minf = getEffectiveMinFrequency();
+    double maxf = getEffectiveMaxFrequency();
 
     bool logarithmic = (m_frequencyScale == LogFrequencyScale);
 
@@ -1320,7 +1320,7 @@
 }
 
 bool
-SpectrogramLayer::getSmoothedYBinRange(View *v, int y, float &q0, float &q1) const
+SpectrogramLayer::getSmoothedYBinRange(View *v, int y, double &q0, double &q1) const
 {
     Profiler profiler("SpectrogramLayer::getSmoothedYBinRange");
 
@@ -1328,8 +1328,8 @@
     if (y < 0 || y >= h) return false;
 
     int sr = m_model->getSampleRate();
-    float minf = getEffectiveMinFrequency();
-    float maxf = getEffectiveMaxFrequency();
+    double minf = getEffectiveMinFrequency();
+    double maxf = getEffectiveMaxFrequency();
 
     bool logarithmic = (m_frequencyScale == LogFrequencyScale);
 
@@ -1346,7 +1346,7 @@
 }
     
 bool
-SpectrogramLayer::getXBinRange(View *v, int x, float &s0, float &s1) const
+SpectrogramLayer::getXBinRange(View *v, int x, double &s0, double &s1) const
 {
     int modelStart = m_model->getStartFrame();
     int modelEnd = m_model->getEndFrame();
@@ -1363,8 +1363,8 @@
     // range of spectrogram windows:
 
     int windowIncrement = getWindowIncrement();
-    s0 = float(f0) / windowIncrement;
-    s1 = float(f1) / windowIncrement;
+    s0 = double(f0) / windowIncrement;
+    s1 = double(f1) / windowIncrement;
 
     return true;
 }
@@ -1372,7 +1372,7 @@
 bool
 SpectrogramLayer::getXBinSourceRange(View *v, int x, RealTime &min, RealTime &max) const
 {
-    float s0 = 0, s1 = 0;
+    double s0 = 0, s1 = 0;
     if (!getXBinRange(v, x, s0, s1)) return false;
     
     int s0i = int(s0 + 0.001);
@@ -1389,10 +1389,10 @@
 }
 
 bool
-SpectrogramLayer::getYBinSourceRange(View *v, int y, float &freqMin, float &freqMax)
+SpectrogramLayer::getYBinSourceRange(View *v, int y, double &freqMin, double &freqMax)
 const
 {
-    float q0 = 0, q1 = 0;
+    double q0 = 0, q1 = 0;
     if (!getYBinRange(v, y, q0, q1)) return false;
 
     int q0i = int(q0 + 0.001);
@@ -1409,8 +1409,8 @@
 
 bool
 SpectrogramLayer::getAdjustedYBinSourceRange(View *v, int x, int y,
-					     float &freqMin, float &freqMax,
-					     float &adjFreqMin, float &adjFreqMax)
+					     double &freqMin, double &freqMax,
+					     double &adjFreqMin, double &adjFreqMax)
 const
 {
     if (!m_model || !m_model->isOK() || !m_model->isReady()) {
@@ -1420,10 +1420,10 @@
     FFTModel *fft = getFFTModel(v);
     if (!fft) return false;
 
-    float s0 = 0, s1 = 0;
+    double s0 = 0, s1 = 0;
     if (!getXBinRange(v, x, s0, s1)) return false;
 
-    float q0 = 0, q1 = 0;
+    double q0 = 0, q1 = 0;
     if (!getYBinRange(v, y, q0, q1)) return false;
 
     int s0i = int(s0 + 0.001);
@@ -1445,7 +1445,7 @@
 
             if (!fft->isColumnAvailable(s)) continue;
 
-	    float binfreq = (float(sr) * q) / m_windowSize;
+	    double binfreq = (double(sr) * q) / m_windowSize;
 	    if (q == q0i) freqMin = binfreq;
 	    if (q == q1i) freqMax = binfreq;
 
@@ -1453,7 +1453,7 @@
 
 	    if (!fft->isOverThreshold(s, q, m_threshold * (m_fftSize/2))) continue;
 
-	    float freq = binfreq;
+	    double freq = binfreq;
 	    
 	    if (s < int(fft->getWidth()) - 1) {
 
@@ -1476,17 +1476,17 @@
     
 bool
 SpectrogramLayer::getXYBinSourceRange(View *v, int x, int y,
-				      float &min, float &max,
-				      float &phaseMin, float &phaseMax) const
+				      double &min, double &max,
+				      double &phaseMin, double &phaseMax) const
 {
     if (!m_model || !m_model->isOK() || !m_model->isReady()) {
 	return false;
     }
 
-    float q0 = 0, q1 = 0;
+    double q0 = 0, q1 = 0;
     if (!getYBinRange(v, y, q0, q1)) return false;
 
-    float s0 = 0, s1 = 0;
+    double s0 = 0, s1 = 0;
     if (!getXBinRange(v, x, s0, s1)) return false;
     
     int q0i = int(q0 + 0.001);
@@ -1520,7 +1520,7 @@
 
                     if (!fft->isColumnAvailable(s)) continue;
                     
-                    float value;
+                    double value;
 
                     value = fft->getPhaseAt(s, q);
                     if (!have || value < phaseMin) { phaseMin = value; }
@@ -1573,9 +1573,9 @@
 	if (minbin >= maxbin) minbin = maxbin - 1;
     }
 
-    float perPixel =
-        float(v->height()) /
-        float((maxbin - minbin) / (m_zeroPadLevel + 1));
+    double perPixel =
+        double(v->height()) /
+        double((maxbin - minbin) / (m_zeroPadLevel + 1));
 
     if (perPixel > 2.8) {
         return 3; // 4x oversampling
@@ -1724,7 +1724,7 @@
     MagnitudeRange mag;
 
     int x0 = 0, x1 = v->width();
-    float s00 = 0, s01 = 0, s10 = 0, s11 = 0;
+    double s00 = 0, s01 = 0, s10 = 0, s11 = 0;
     
     if (!getXBinRange(v, x0, s00, s01)) {
         s00 = s01 = m_model->getStartFrame() / getWindowIncrement();
@@ -1830,7 +1830,7 @@
     x0 = rect.left();
     x1 = rect.right() + 1;
 /*
-    float xPixelRatio = float(fft->getResolution()) / float(zoomLevel);
+    double xPixelRatio = double(fft->getResolution()) / double(zoomLevel);
     cerr << "xPixelRatio = " << xPixelRatio << endl;
     if (xPixelRatio < 1.f) xPixelRatio = 1.f;
 */
@@ -2137,11 +2137,11 @@
     minbin = minbin * zpl;
     maxbin = (maxbin + 1) * zpl - 1;
 
-    float minFreq = (float(minbin) * sr) / fftSize;
-    float maxFreq = (float(maxbin) * sr) / fftSize;
-
-    float displayMinFreq = minFreq;
-    float displayMaxFreq = maxFreq;
+    double minFreq = (double(minbin) * sr) / fftSize;
+    double maxFreq = (double(maxbin) * sr) / fftSize;
+
+    double displayMinFreq = minFreq;
+    double displayMaxFreq = maxFreq;
 
     if (fftSize != m_fftSize) {
         displayMinFreq = getEffectiveMinFrequency();
@@ -2154,10 +2154,10 @@
     
     bool logarithmic = (m_frequencyScale == LogFrequencyScale);
 /*
-    float yforbin[maxbin - minbin + 1];
+    double yforbin[maxbin - minbin + 1];
 
     for (int q = minbin; q <= maxbin; ++q) {
-        float f0 = (float(q) * sr) / fftSize;
+        double f0 = (double(q) * sr) / fftSize;
         yforbin[q - minbin] =
             v->getYForFrequency(f0, displayMinFreq, displayMaxFreq,
                                 logarithmic);
@@ -2167,7 +2167,7 @@
     bool overallMagChanged = false;
 
 #ifdef DEBUG_SPECTROGRAM_REPAINT
-    cerr << ((float(v->getFrameForX(1) - v->getFrameForX(0))) / increment) << " bin(s) per pixel" << endl;
+    cerr << ((double(v->getFrameForX(1) - v->getFrameForX(0))) / increment) << " bin(s) per pixel" << endl;
 #endif
 
     if (w == 0) {
@@ -2231,10 +2231,10 @@
 
 #ifdef __GNUC__
     int binforx[bufwid];
-    float binfory[h];
+    double binfory[h];
 #else
     int *binforx = (int *)alloca(bufwid * sizeof(int));
-    float *binfory = (float *)alloca(h * sizeof(float));
+    double *binfory = (double *)alloca(h * sizeof(double));
 #endif
 
     bool usePeaksCache = false;
@@ -2247,7 +2247,7 @@
         m_drawBuffer = QImage(bufwid, h, QImage::Format_Indexed8);
     } else {
         for (int x = 0; x < bufwid; ++x) {
-            float s0 = 0, s1 = 0;
+            double s0 = 0, s1 = 0;
             if (getXBinRange(v, x + x0, s0, s1)) {
                 binforx[x] = int(s0 + 0.0001);
             } else {
@@ -2271,7 +2271,7 @@
     if (m_binDisplay != PeakFrequencies) {
 
         for (int y = 0; y < h; ++y) {
-            float q0 = 0, q1 = 0;
+            double q0 = 0, q1 = 0;
             if (!getSmoothedYBinRange(v, h-y-1, q0, q1)) {
                 binfory[y] = -1;
             } else {
@@ -2460,8 +2460,8 @@
                                                  int *binforx,
                                                  int minbin,
                                                  int maxbin,
-                                                 float displayMinFreq,
-                                                 float displayMaxFreq,
+                                                 double displayMinFreq,
+                                                 double displayMaxFreq,
                                                  bool logarithmic,
                                                  MagnitudeRange &overallMag,
                                                  bool &overallMagChanged) const
@@ -2522,7 +2522,7 @@
                     fft->getNormalizedMagnitudesAt(sx, values, minbin, maxbin - minbin + 1);
                 } else if (m_normalizeHybrid) {
                     fft->getNormalizedMagnitudesAt(sx, values, minbin, maxbin - minbin + 1);
-                    float max = fft->getMaximumMagnitudeAt(sx);
+                    double max = fft->getMaximumMagnitudeAt(sx);
                     if (max > 0.f) {
                         for (int i = minbin; i <= maxbin; ++i) {
                             values[i - minbin] *= log10(max);
@@ -2553,7 +2553,7 @@
                     value *= m_gain;
                 }
 
-                float y = v->getYForFrequency
+                double y = v->getYForFrequency
                     (freq, displayMinFreq, displayMaxFreq, logarithmic);
 
                 int iy = int(y + 0.5);
@@ -2586,7 +2586,7 @@
                                   int w,
                                   int h,
                                   int *binforx,
-                                  float *binfory,
+                                  double *binfory,
                                   bool usePeaksCache,
                                   MagnitudeRange &overallMag,
                                   bool &overallMagChanged) const
@@ -2689,7 +2689,7 @@
                         fft->getNormalizedMagnitudesAt(sx, autoarray, minbin, maxbin - minbin + 1);
                     } else if (m_normalizeHybrid) {
                         fft->getNormalizedMagnitudesAt(sx, autoarray, minbin, maxbin - minbin + 1);
-                        float max = fft->getMaximumMagnitudeAt(sx);
+                        double max = fft->getMaximumMagnitudeAt(sx);
                         for (int i = minbin; i <= maxbin; ++i) {
                             if (max > 0.f) {
                                 autoarray[i - minbin] *= log10(max);
@@ -2715,25 +2715,25 @@
 
             for (int y = 0; y < h; ++y) {
 
-                float sy0 = binfory[y];
-                float sy1 = sy0 + 1;
+                double sy0 = binfory[y];
+                double sy1 = sy0 + 1;
                 if (y+1 < h) sy1 = binfory[y+1];
 
-                float value = 0.f;
+                double value = 0.f;
 
                 if (interpolate && fabsf(sy1 - sy0) < 1.f) {
 
-                    float centre = (sy0 + sy1) / 2;
-                    float dist = (centre - 0.5) - lrintf(centre - 0.5);
+                    double centre = (sy0 + sy1) / 2;
+                    double dist = (centre - 0.5) - lrintf(centre - 0.5);
                     int bin = int(centre);
                     int other = (dist < 0 ? (bin-1) : (bin+1));
                     if (bin < minbin) bin = minbin;
                     if (bin > maxbin) bin = maxbin;
                     if (other < minbin || other > maxbin) other = bin;
-                    float prop = 1.f - fabsf(dist);
-
-                    float v0 = values[bin - minbin];
-                    float v1 = values[other - minbin];
+                    double prop = 1.f - fabsf(dist);
+
+                    double v0 = values[bin - minbin];
+                    double v1 = values[other - minbin];
                     if (m_binDisplay == PeakBins) {
                         if (bin == minbin || bin == maxbin ||
                             v0 < values[bin-minbin-1] ||
@@ -2800,7 +2800,7 @@
 
         for (int y = 0; y < h; ++y) {
 
-            float peak = peaks[y];
+            double peak = peaks[y];
             
             if (m_colourScale != PhaseColourScale &&
                 (m_normalizeColumns || m_normalizeHybrid) && 
@@ -2833,8 +2833,8 @@
 //    cerr << "SpectrogramLayer: illuminateLocalFeatures("
 //              << localPos.x() << "," << localPos.y() << ")" << endl;
 
-    float s0, s1;
-    float f0, f1;
+    double s0, s1;
+    double f0, f1;
 
     if (getXBinRange(v, localPos.x(), s0, s1) &&
         getYBinSourceRange(v, localPos.y(), f0, f1)) {
@@ -2859,8 +2859,8 @@
     }
 }
 
-float
-SpectrogramLayer::getYForFrequency(const View *v, float frequency) const
+double
+SpectrogramLayer::getYForFrequency(const View *v, double frequency) const
 {
     return v->getYForFrequency(frequency,
 			       getEffectiveMinFrequency(),
@@ -2868,7 +2868,7 @@
 			       m_frequencyScale == LogFrequencyScale);
 }
 
-float
+double
 SpectrogramLayer::getFrequencyForY(const View *v, int y) const
 {
     return v->getFrequencyForY(y,
@@ -2898,14 +2898,14 @@
 }
 
 bool
-SpectrogramLayer::getValueExtents(float &min, float &max,
+SpectrogramLayer::getValueExtents(double &min, double &max,
                                   bool &logarithmic, QString &unit) const
 {
     if (!m_model) return false;
 
     int sr = m_model->getSampleRate();
-    min = float(sr) / m_fftSize;
-    max = float(sr) / 2;
+    min = double(sr) / m_fftSize;
+    max = double(sr) / 2;
     
     logarithmic = (m_frequencyScale == LogFrequencyScale);
     unit = "Hz";
@@ -2913,7 +2913,7 @@
 }
 
 bool
-SpectrogramLayer::getDisplayExtents(float &min, float &max) const
+SpectrogramLayer::getDisplayExtents(double &min, double &max) const
 {
     min = getEffectiveMinFrequency();
     max = getEffectiveMaxFrequency();
@@ -2923,7 +2923,7 @@
 }    
 
 bool
-SpectrogramLayer::setDisplayExtents(float min, float max)
+SpectrogramLayer::setDisplayExtents(double min, double max)
 {
     if (!m_model) return false;
 
@@ -2956,7 +2956,7 @@
 
 bool
 SpectrogramLayer::getYScaleValue(const View *v, int y,
-                                 float &value, QString &unit) const
+                                 double &value, QString &unit) const
 {
     value = getFrequencyForY(v, y);
     unit = "Hz";
@@ -3062,7 +3062,7 @@
     paint.drawLine(0, cursorPos.y(), cursorPos.x() - 1, cursorPos.y());
     paint.drawLine(cursorPos.x(), 0, cursorPos.x(), v->height());
     
-    float fundamental = getFrequencyForY(v, cursorPos.y());
+    double fundamental = getFrequencyForY(v, cursorPos.y());
 
     v->drawVisibleText(paint,
                        sw + 2,
@@ -3098,7 +3098,7 @@
 
     while (harmonic < 100) {
 
-        float hy = lrintf(getYForFrequency(v, fundamental * harmonic));
+        double hy = lrintf(getYForFrequency(v, fundamental * harmonic));
         if (hy < 0 || hy > v->height()) break;
         
         int len = 7;
@@ -3130,10 +3130,10 @@
 
     if (!m_model || !m_model->isOK()) return "";
 
-    float magMin = 0, magMax = 0;
-    float phaseMin = 0, phaseMax = 0;
-    float freqMin = 0, freqMax = 0;
-    float adjFreqMin = 0, adjFreqMax = 0;
+    double magMin = 0, magMax = 0;
+    double phaseMin = 0, phaseMax = 0;
+    double freqMin = 0, freqMax = 0;
+    double adjFreqMin = 0, adjFreqMax = 0;
     QString pitchMin, pitchMax;
     RealTime rtMin, rtMax;
 
@@ -3205,8 +3205,8 @@
     }	
 
     if (haveValues) {
-	float dbMin = AudioLevel::multiplier_to_dB(magMin);
-	float dbMax = AudioLevel::multiplier_to_dB(magMax);
+	double dbMin = AudioLevel::multiplier_to_dB(magMin);
+	double dbMax = AudioLevel::multiplier_to_dB(magMax);
 	QString dbMinString;
 	QString dbMaxString;
 	if (dbMin == AudioLevel::DB_FLOOR) {
@@ -3308,11 +3308,11 @@
 	paint.drawRect(4 + cw - cbw, textHeight * topLines + 4, cbw - 1, ch + 1);
 
 	QString top, bottom;
-        float min = m_viewMags[v].getMin();
-        float max = m_viewMags[v].getMax();
-
-        float dBmin = AudioLevel::multiplier_to_dB(min);
-        float dBmax = AudioLevel::multiplier_to_dB(max);
+        double min = m_viewMags[v].getMin();
+        double max = m_viewMags[v].getMax();
+
+        double dBmin = AudioLevel::multiplier_to_dB(min);
+        double dBmax = AudioLevel::multiplier_to_dB(max);
 
         if (dBmax < -60.f) dBmax = -60.f;
         else top = QString("%1").arg(lrintf(dBmax));
@@ -3342,10 +3342,10 @@
 
 	for (int i = 0; i < ch; ++i) {
 
-            float dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1));
+            double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1));
             int idb = int(dBval);
 
-            float value = AudioLevel::dB_to_multiplier(dBval);
+            double value = AudioLevel::dB_to_multiplier(dBval);
             int colour = getDisplayValue(v, value * m_gain);
 
 	    paint.setPen(m_palette.getColour(colour));
@@ -3382,7 +3382,7 @@
 
     for (int y = 0; y < v->height(); ++y) {
 
-	float q0, q1;
+	double q0, q1;
 	if (!getYBinRange(v, v->height() - y, q0, q1)) continue;
 
 	int vy;
@@ -3493,9 +3493,9 @@
 
     SpectrogramRangeMapper mapper(sr, m_fftSize);
 
-//    int maxStep = mapper.getPositionForValue((float(sr) / m_fftSize) + 0.001);
+//    int maxStep = mapper.getPositionForValue((double(sr) / m_fftSize) + 0.001);
     int maxStep = mapper.getPositionForValue(0);
-    int minStep = mapper.getPositionForValue(float(sr) / 2);
+    int minStep = mapper.getPositionForValue(double(sr) / 2);
 
     int initialMax = m_initialMaxFrequency;
     if (initialMax == 0) initialMax = sr / 2;
@@ -3512,7 +3512,7 @@
 {
     if (!m_model) return 0;
 
-    float dmin, dmax;
+    double dmin, dmax;
     getDisplayExtents(dmin, dmax);
     
     SpectrogramRangeMapper mapper(m_model->getSampleRate(), m_fftSize);
@@ -3526,16 +3526,16 @@
 {
     if (!m_model) return;
 
-    float dmin = m_minFrequency, dmax = m_maxFrequency;
+    double dmin = m_minFrequency, dmax = m_maxFrequency;
 //    getDisplayExtents(dmin, dmax);
 
 //    cerr << "current range " << dmin << " -> " << dmax << ", range " << dmax-dmin << ", mid " << (dmax + dmin)/2 << endl;
     
     int sr = m_model->getSampleRate();
     SpectrogramRangeMapper mapper(sr, m_fftSize);
-    float newdist = mapper.getValueForPosition(step);
-
-    float newmin, newmax;
+    double newdist = mapper.getValueForPosition(step);
+
+    double newmin, newmax;
 
     if (m_frequencyScale == LogFrequencyScale) {
 
@@ -3566,14 +3566,14 @@
 //        cerr << "newmin = " << newmin << ", newmax = " << newmax << endl;
 
     } else {
-        float dmid = (dmax + dmin) / 2;
+        double dmid = (dmax + dmin) / 2;
         newmin = dmid - newdist / 2;
         newmax = dmid + newdist / 2;
     }
 
-    float mmin, mmax;
+    double mmin, mmax;
     mmin = 0;
-    mmax = float(sr) / 2;
+    mmax = double(sr) / 2;
     
     if (newmin < mmin) {
         newmax += (mmin - newmin);
--- a/layer/SpectrogramLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/SpectrogramLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -69,7 +69,7 @@
 
     virtual QString getFeatureDescription(View *v, QPoint &) const;
 
-    virtual bool snapToFeatureFrame(View *v, int &frame,
+    virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame,
 				    int &resolution,
 				    SnapType snap) const;
 
@@ -210,20 +210,20 @@
         return ColourHasMeaningfulValue;
     }
 
-    float getYForFrequency(const View *v, float frequency) const;
-    float getFrequencyForY(const View *v, int y) const;
+    double getYForFrequency(const View *v, double frequency) const;
+    double getFrequencyForY(const View *v, int y) const;
 
     virtual int getCompletion(View *v) const;
     virtual QString getError(View *v) const;
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &logarithmic, QString &unit) const;
 
-    virtual bool getDisplayExtents(float &min, float &max) const;
+    virtual bool getDisplayExtents(double &min, double &max) const;
 
-    virtual bool setDisplayExtents(float min, float max);
+    virtual bool setDisplayExtents(double min, double max);
 
-    virtual bool getYScaleValue(const View *, int, float &, QString &) const;
+    virtual bool getYScaleValue(const View *, int, double &, QString &) const;
 
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
@@ -340,8 +340,8 @@
 
     void illuminateLocalFeatures(View *v, QPainter &painter) const;
 
-    float getEffectiveMinFrequency() const;
-    float getEffectiveMaxFrequency() const;
+    double getEffectiveMinFrequency() const;
+    double getEffectiveMaxFrequency() const;
 
     struct LayerRange {
 	int   startFrame;
@@ -356,17 +356,17 @@
     // position, if the spectrogram has oversampling smoothing.  Use
     // getSmoothedYBinRange to obtain that.
 
-    bool getXBinRange(View *v, int x, float &windowMin, float &windowMax) const;
-    bool getYBinRange(View *v, int y, float &freqBinMin, float &freqBinMax) const;
-    bool getSmoothedYBinRange(View *v, int y, float &freqBinMin, float &freqBinMax) const;
+    bool getXBinRange(View *v, int x, double &windowMin, double &windowMax) const;
+    bool getYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const;
+    bool getSmoothedYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const;
 
-    bool getYBinSourceRange(View *v, int y, float &freqMin, float &freqMax) const;
+    bool getYBinSourceRange(View *v, int y, double &freqMin, double &freqMax) const;
     bool getAdjustedYBinSourceRange(View *v, int x, int y,
-				    float &freqMin, float &freqMax,
-				    float &adjFreqMin, float &adjFreqMax) const;
+				    double &freqMin, double &freqMax,
+				    double &adjFreqMin, double &adjFreqMax) const;
     bool getXBinSourceRange(View *v, int x, RealTime &timeMin, RealTime &timeMax) const;
-    bool getXYBinSourceRange(View *v, int x, int y, float &min, float &max,
-			     float &phaseMin, float &phaseMax) const;
+    bool getXYBinSourceRange(View *v, int x, int y, double &min, double &max,
+			     double &phaseMin, double &phaseMax) const;
 
     int getWindowIncrement() const {
         if (m_windowHopLevel == 0) return m_windowSize;
@@ -393,20 +393,19 @@
         bool operator==(const MagnitudeRange &r) {
             return r.m_min == m_min && r.m_max == m_max;
         }
-        bool isSet() const { return (m_min != 0 || m_max != 0); }
+        bool isSet() const { return (m_min != 0.f || m_max != 0.f); }
         void set(float min, float max) {
-            m_min = convert(min);
-            m_max = convert(max);
+            m_min = min;
+            m_max = max;
             if (m_max < m_min) m_max = m_min;
         }
         bool sample(float f) {
-            unsigned int ui = convert(f);
             bool changed = false;
             if (isSet()) {
-                if (ui < m_min) { m_min = ui; changed = true; }
-                if (ui > m_max) { m_max = ui; changed = true; }
+                if (f < m_min) { m_min = f; changed = true; }
+                if (f > m_max) { m_max = f; changed = true; }
             } else {
-                m_max = m_min = ui;
+                m_max = m_min = f;
                 changed = true;
             }
             return changed;
@@ -423,16 +422,11 @@
             }
             return changed;
         }            
-        float getMin() const { return float(m_min) / UINT_MAX; }
-        float getMax() const { return float(m_max) / UINT_MAX; }
+        float getMin() const { return m_min; }
+        float getMax() const { return m_max; }
     private:
-        unsigned int m_min;
-        unsigned int m_max;
-        unsigned int convert(float f) {
-            if (f < 0.f) f = 0.f;
-            if (f > 1.f) f = 1.f;
-            return (unsigned int)(f * UINT_MAX);
-        }
+        float m_min;
+        float m_max;
     };
 
     typedef std::map<const View *, MagnitudeRange> ViewMagMap;
@@ -441,7 +435,7 @@
     void invalidateMagnitudes();
     bool updateViewMagnitudes(View *v) const;
     bool paintDrawBuffer(View *v, int w, int h,
-                         int *binforx, float *binfory,
+                         int *binforx, double *binfory,
                          bool usePeaksCache,
                          MagnitudeRange &overallMag,
                          bool &overallMagChanged) const;
@@ -449,8 +443,8 @@
                                         int *binforx,
                                         int minbin,
                                         int maxbin,
-                                        float displayMinFreq,
-                                        float displayMaxFreq,
+                                        double displayMinFreq,
+                                        double displayMaxFreq,
                                         bool logarithmic,
                                         MagnitudeRange &overallMag,
                                         bool &overallMagChanged) const;
--- a/layer/SpectrumLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/SpectrumLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -64,17 +64,17 @@
     virtual void setProperty(const PropertyName &, int value);
     virtual void setProperties(const QXmlAttributes &);
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &logarithmic, QString &unit) const;
 
     virtual bool getXScaleValue(const View *v, int x,
-                                float &value, QString &unit) const;
+                                double &value, QString &unit) const;
 
     virtual bool getYScaleValue(const View *, int y,
-                                float &value, QString &unit) const;
+                                double &value, QString &unit) const;
 
     virtual bool getYScaleDifference(const View *, int y0, int y1,
-                                     float &diff, QString &unit) const;
+                                     double &diff, QString &unit) const;
 
     virtual bool isLayerScrollable(const View *) const { return false; }
 
@@ -123,11 +123,11 @@
     virtual void getBiasCurve(BiasCurve &) const;
     BiasCurve m_biasCurve;
 
-    virtual float getXForBin(int bin, int totalBins, float w) const;
-    virtual int getBinForX(float x, int totalBins, float w) const;
+    virtual double getXForBin(int bin, int totalBins, double w) const;
+    virtual int getBinForX(double x, int totalBins, double w) const;
 
-    float getFrequencyForX(float x, float w) const;
-    float getXForFrequency(float freq, float w) const;
+    double getFrequencyForX(double x, double w) const;
+    double getXForFrequency(double freq, double w) const;
 
     int getWindowIncrement() const {
         if (m_windowHopLevel == 0) return m_windowSize;
--- a/layer/TextLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/TextLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -36,7 +36,7 @@
 
     virtual QString getFeatureDescription(View *v, QPoint &) const;
 
-    virtual bool snapToFeatureFrame(View *v, int &frame,
+    virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame,
 				    int &resolution,
 				    SnapType snap) const;
 
@@ -52,12 +52,12 @@
     virtual void editDrag(View *v, QMouseEvent *);
     virtual void editEnd(View *v, QMouseEvent *);
 
-    virtual void moveSelection(Selection s, int newStartFrame);
+    virtual void moveSelection(Selection s, sv_frame_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
 
     virtual void copy(View *v, Selection s, Clipboard &to);
-    virtual bool paste(View *v, const Clipboard &from, int frameOffset,
+    virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset,
                        bool interactive);
 
     virtual bool editOpen(View *, QMouseEvent *); // on double-click
@@ -80,7 +80,7 @@
 
     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &logarithmic, QString &unit) const;
 
     virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
@@ -91,8 +91,8 @@
     void setProperties(const QXmlAttributes &attributes);
 
 protected:
-    int getYForHeight(View *v, float height) const;
-    float getHeightForY(View *v, int y) const;
+    int getYForHeight(View *v, double height) const;
+    double getHeightForY(View *v, int y) const;
 
     virtual int getDefaultColourHint(bool dark, bool &impose);
 
--- a/layer/TimeInstantLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/TimeInstantLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -38,7 +38,7 @@
     virtual QString getLabelPreceding(int) const;
     virtual QString getFeatureDescription(View *v, QPoint &) const;
 
-    virtual bool snapToFeatureFrame(View *v, int &frame,
+    virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame,
 				    int &resolution,
 				    SnapType snap) const;
 
@@ -56,12 +56,12 @@
 
     virtual bool editOpen(View *, QMouseEvent *);
 
-    virtual void moveSelection(Selection s, int newStartFrame);
+    virtual void moveSelection(Selection s, sv_frame_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
 
     virtual void copy(View *v, Selection s, Clipboard &to);
-    virtual bool paste(View *v, const Clipboard &from, int frameOffset,
+    virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset,
                        bool interactive);
 
     virtual const Model *getModel() const { return m_model; }
@@ -92,7 +92,7 @@
 
     virtual bool needsTextLabelHeight() const { return m_model->hasTextLabels(); }
 
-    virtual bool getValueExtents(float &, float &, bool &, QString &) const {
+    virtual bool getValueExtents(double &, double &, bool &, QString &) const {
         return false;
     }
 
--- a/layer/TimeRulerLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/TimeRulerLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -41,13 +41,13 @@
     void setLabelHeight(LabelHeight h) { m_labelHeight = h; }
     LabelHeight getLabelHeight() const { return m_labelHeight; }
 
-    virtual bool snapToFeatureFrame(View *, int &, int &, SnapType) const;
+    virtual bool snapToFeatureFrame(View *, sv_frame_t &, int &, SnapType) const;
 
     virtual ColourSignificance getLayerColourSignificance() const {
         return ColourIrrelevant;
     }
 
-    virtual bool getValueExtents(float &, float &, bool &, QString &) const {
+    virtual bool getValueExtents(double &, double &, bool &, QString &) const {
         return false;
     }
 
--- a/layer/TimeValueLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/TimeValueLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -45,10 +45,10 @@
     virtual QString getFeatureDescription(View *v, QPoint &) const;
     virtual QString getLabelPreceding(int) const;
 
-    virtual bool snapToFeatureFrame(View *v, int &frame,
+    virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame,
 				    int &resolution,
 				    SnapType snap) const;
-    virtual bool snapToSimilarFeature(View *v, int &frame,
+    virtual bool snapToSimilarFeature(View *v, sv_frame_t &frame,
                                       int &resolution,
                                       SnapType snap) const;
 
@@ -66,12 +66,12 @@
 
     virtual bool editOpen(View *v, QMouseEvent *);
 
-    virtual void moveSelection(Selection s, int newStartFrame);
+    virtual void moveSelection(Selection s, sv_frame_t newStartFrame);
     virtual void resizeSelection(Selection s, Selection newSize);
     virtual void deleteSelection(Selection s);
 
     virtual void copy(View *v, Selection s, Clipboard &to);
-    virtual bool paste(View *v, const Clipboard &from, int frameOffset,
+    virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset,
                        bool interactive);
 
     virtual const Model *getModel() const { return m_model; }
@@ -130,11 +130,11 @@
         return m_plotStyle == PlotSegmentation && m_model->hasTextLabels();
     }
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &logarithmic, QString &unit) const;
 
-    virtual bool getDisplayExtents(float &min, float &max) const;
-    virtual bool setDisplayExtents(float min, float max);
+    virtual bool getDisplayExtents(double &min, double &max) const;
+    virtual bool setDisplayExtents(double min, double max);
 
     virtual int getVerticalZoomSteps(int &defaultStep) const;
     virtual int getCurrentVerticalZoomStep() const;
@@ -155,13 +155,13 @@
     }
 
     /// VerticalScaleLayer and ColourScaleLayer methods
-    virtual int getYForValue(View *, float value) const;
-    virtual float getValueForY(View *, int y) const;
+    virtual int getYForValue(View *, double value) const;
+    virtual double getValueForY(View *, int y) const;
     virtual QString getScaleUnits() const;
-    virtual QColor getColourForValue(View *v, float value) const;
+    virtual QColor getColourForValue(View *v, double value) const;
 
 protected:
-    void getScaleExtents(View *, float &min, float &max, bool &log) const;
+    void getScaleExtents(View *, double &min, double &max, bool &log) const;
     bool shouldAutoAlign() const;
 
     SparseTimeValueModel::PointList getLocalPoints(View *v, int) const;
@@ -179,8 +179,8 @@
     bool m_drawSegmentDivisions;
     bool m_derivative;
 
-    mutable float m_scaleMinimum;
-    mutable float m_scaleMaximum;
+    mutable double m_scaleMinimum;
+    mutable double m_scaleMaximum;
 
     void finish(SparseTimeValueModel::EditCommand *command) {
         Command *c = command->finish();
--- a/layer/WaveformLayer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/layer/WaveformLayer.h	Mon Mar 09 14:35:21 2015 +0000
@@ -156,8 +156,8 @@
      * bottom; the default value of 0.5 indicates that it occupies the
      * whole layer, centred at the middle.
      */
-    void setMiddleLineHeight(float height);
-    float getMiddleLineHeight() const { return m_middleLineHeight; }
+    void setMiddleLineHeight(double);
+    double getMiddleLineHeight() const { return m_middleLineHeight; }
 
     /**
      * Enable or disable aggressive pixmap cacheing.  If enabled,
@@ -184,14 +184,14 @@
 
     virtual int getCompletion(View *) const;
 
-    virtual bool getValueExtents(float &min, float &max,
+    virtual bool getValueExtents(double &min, double &max,
                                  bool &log, QString &unit) const;
 
     virtual bool getYScaleValue(const View *v, int y,
-                                float &value, QString &unit) const;
+                                double &value, QString &unit) const;
     
     virtual bool getYScaleDifference(const View *v, int y0, int y1,
-                                     float &diff, QString &unit) const;
+                                     double &diff, QString &unit) const;
 
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
@@ -211,9 +211,9 @@
     int getChannelArrangement(int &min, int &max,
                                  bool &merging, bool &mixing) const;
 
-    int getYForValue(const View *v, float value, int channel) const;
+    int getYForValue(const View *v, double value, int channel) const;
 
-    float getValueForY(const View *v, int y, int &channel) const;
+    double getValueForY(const View *v, int y, int &channel) const;
 
     bool getSourceFramesForX(View *v, int x, int modelZoomLevel,
                              int &f0, int &f1) const;
@@ -229,7 +229,7 @@
     ChannelMode  m_channelMode;
     int          m_channel;
     Scale        m_scale;
-    float        m_middleLineHeight;
+    double       m_middleLineHeight;
     bool         m_aggressive;
 
     mutable std::vector<float> m_effectiveGains;