changeset 1040:a1cd5abcb38b cxx11

Introduce and use a samplerate type
author Chris Cannam
date Wed, 04 Mar 2015 12:01:04 +0000
parents b14064bd1f97
children 843f67be0ed9
files base/AudioPlaySource.h base/RealTime.cpp base/RealTime.h base/test/TestRealTime.h data/fileio/AudioFileReader.h data/fileio/AudioFileReaderFactory.cpp data/fileio/AudioFileReaderFactory.h data/fileio/CodedAudioFileReader.cpp data/fileio/CodedAudioFileReader.h data/fileio/CoreAudioFileReader.cpp data/fileio/CoreAudioFileReader.h data/fileio/DecodingWavFileReader.cpp data/fileio/DecodingWavFileReader.h data/fileio/MP3FileReader.cpp data/fileio/MP3FileReader.h data/fileio/OggVorbisFileReader.cpp data/fileio/OggVorbisFileReader.h data/fileio/QuickTimeFileReader.cpp data/fileio/QuickTimeFileReader.h data/fileio/WavFileReader.cpp data/fileio/WavFileWriter.cpp data/fileio/WavFileWriter.h data/fileio/test/AudioFileReaderTest.h data/fileio/test/AudioTestData.h data/model/AggregateWaveModel.cpp data/model/AggregateWaveModel.h data/model/AlignmentModel.cpp data/model/AlignmentModel.h data/model/Dense3DModelPeakCache.h data/model/EditableDenseThreeDimensionalModel.cpp data/model/EditableDenseThreeDimensionalModel.h data/model/FFTModel.cpp data/model/FFTModel.h data/model/FlexiNoteModel.h data/model/ImageModel.h data/model/IntervalModel.h data/model/Model.h data/model/NoteModel.h data/model/PathModel.h data/model/RegionModel.h data/model/SparseModel.h data/model/SparseOneDimensionalModel.h data/model/SparseTimeValueModel.h data/model/SparseValueModel.h data/model/TextModel.h data/model/WaveFileModel.cpp data/model/WaveFileModel.h data/model/WritableWaveFileModel.cpp data/model/WritableWaveFileModel.h plugin/DSSIPluginFactory.cpp plugin/DSSIPluginFactory.h plugin/DSSIPluginInstance.cpp plugin/DSSIPluginInstance.h plugin/FeatureExtractionPluginFactory.cpp plugin/FeatureExtractionPluginFactory.h plugin/LADSPAPluginFactory.cpp plugin/LADSPAPluginFactory.h plugin/LADSPAPluginInstance.cpp plugin/LADSPAPluginInstance.h plugin/RealTimePluginFactory.cpp plugin/RealTimePluginFactory.h plugin/RealTimePluginInstance.h rdf/RDFExporter.cpp rdf/RDFImporter.cpp rdf/RDFImporter.h transform/FeatureExtractionModelTransformer.cpp transform/ModelTransformerFactory.cpp transform/RealTimeEffectModelTransformer.cpp
diffstat 68 files changed, 369 insertions(+), 317 deletions(-) [+]
line wrap: on
line diff
--- a/base/AudioPlaySource.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/base/AudioPlaySource.h	Wed Mar 04 12:01:04 2015 +0000
@@ -16,6 +16,8 @@
 #ifndef _AUDIO_PLAY_SOURCE_H_
 #define _AUDIO_PLAY_SOURCE_H_
 
+#include "BaseTypes.h"
+
 struct Auditionable {
     virtual ~Auditionable() { }
 };
@@ -37,7 +39,7 @@
      * Start playing from the given frame.  If playback is already
      * under way, reseek to the given frame and continue.
      */
-    virtual void play(int startFrame) = 0;
+    virtual void play(sv_frame_t startFrame) = 0;
 
     /**
      * Stop playback.
@@ -53,7 +55,7 @@
      * Return the frame number that is currently expected to be coming
      * out of the speakers.  (i.e. compensating for playback latency.)
      */
-    virtual int getCurrentPlayingFrame() = 0;
+    virtual sv_frame_t getCurrentPlayingFrame() = 0;
 
     /**
      * Return the current (or thereabouts) output levels in the range
@@ -65,14 +67,14 @@
      * Return the sample rate of the source material -- any material
      * that wants to play at a different rate will sound wrong.
      */
-    virtual int getSourceSampleRate() const = 0;
+    virtual sv_samplerate_t getSourceSampleRate() const = 0;
 
     /**
      * Return the sample rate set by the target audio device (or the
      * source sample rate if the target hasn't set one).  If the
      * source and target sample rates differ, resampling will occur.
      */
-    virtual int getTargetSampleRate() const = 0;
+    virtual sv_samplerate_t getTargetSampleRate() const = 0;
 
     /**
      * Get the block size of the target audio device.  This may be an
--- a/base/RealTime.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/base/RealTime.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -456,24 +456,36 @@
     else return lTotal/rTotal;
 }
 
+static RealTime
+frame2RealTime_i(sv_frame_t frame, sv_frame_t iSampleRate)
+{
+    if (frame < 0) return -frame2RealTime_i(-frame, iSampleRate);
+
+    RealTime rt;
+    sv_frame_t sec = frame / iSampleRate;
+    rt.sec = int(sec);
+    frame -= sec * iSampleRate;
+    rt.nsec = (int)(((double(frame) * 1000000.0) / double(iSampleRate)) * 1000.0);
+    return rt;
+}
+
 sv_frame_t
-RealTime::realTime2Frame(const RealTime &time, int sampleRate)
+RealTime::realTime2Frame(const RealTime &time, sv_samplerate_t sampleRate)
 {
     if (time < zeroTime) return -realTime2Frame(-time, sampleRate);
     double s = time.sec + double(time.nsec + 1) / 1000000000.0;
-    return sv_frame_t(s * double(sampleRate));
+    return sv_frame_t(s * sampleRate);
 }
 
 RealTime
-RealTime::frame2RealTime(sv_frame_t frame, int sampleRate)
+RealTime::frame2RealTime(sv_frame_t frame, sv_samplerate_t sampleRate)
 {
-    if (frame < 0) return -frame2RealTime(-frame, sampleRate);
+    if (sampleRate == double(int(sampleRate))) {
+        return frame2RealTime_i(frame, int(sampleRate));
+    }
 
-    RealTime rt;
-    rt.sec = int(frame / sv_frame_t(sampleRate));
-    frame -= rt.sec * sv_frame_t(sampleRate);
-    rt.nsec = (int)(((double(frame) * 1000000.0) / long(sampleRate)) * 1000.0);
-    return rt;
+    double sec = double(frame) / sampleRate;
+    return fromSeconds(sec);
 }
 
 const RealTime RealTime::zeroTime(0,0);
--- a/base/RealTime.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/base/RealTime.h	Wed Mar 04 12:01:04 2015 +0000
@@ -26,6 +26,8 @@
 #include <iostream>
 #include <string>
 
+#include <vamp-hostsdk/RealTime.h>
+
 struct timeval;
 
 /**
@@ -47,12 +49,16 @@
     RealTime(const RealTime &r) :
 	sec(r.sec), nsec(r.nsec) { }
 
+    RealTime(const Vamp::RealTime &r) :
+	sec(r.sec), nsec(r.nsec) { }
+
     static RealTime fromSeconds(double sec);
     static RealTime fromMilliseconds(int msec);
     static RealTime fromTimeval(const struct timeval &);
     static RealTime fromXsdDuration(std::string xsdd);
 
     double toDouble() const;
+    Vamp::RealTime toVampRealTime() const { return Vamp::RealTime(sec, nsec); }
 
     RealTime &operator=(const RealTime &r) {
 	sec = r.sec; nsec = r.nsec; return *this;
@@ -150,12 +156,12 @@
     /**
      * Convert a RealTime into a sample frame at the given sample rate.
      */
-    static sv_frame_t realTime2Frame(const RealTime &r, int sampleRate);
+    static sv_frame_t realTime2Frame(const RealTime &r, sv_samplerate_t sampleRate);
 
     /**
      * Convert a sample frame at the given sample rate into a RealTime.
      */
-    static RealTime frame2RealTime(sv_frame_t frame, int sampleRate);
+    static RealTime frame2RealTime(sv_frame_t frame, sv_samplerate_t sampleRate);
 
     static const RealTime zeroTime;
 };
--- a/base/test/TestRealTime.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/base/test/TestRealTime.h	Wed Mar 04 12:01:04 2015 +0000
@@ -282,12 +282,12 @@
         int m = sizeof(rates)/sizeof(rates[0]);
 
         for (int i = 0; i < n; ++i) {
-            int frame = frames[i];
+            sv_frame_t frame = frames[i];
             for (int j = 0; j < m; ++j) {
                 int rate = rates[j];
 
                 RealTime rt = RealTime::frame2RealTime(frame, rate);
-                int conv = RealTime::realTime2Frame(rt, rate);
+                sv_frame_t conv = RealTime::realTime2Frame(rt, rate);
                 QCOMPARE(frame, conv);
 
                 rt = RealTime::frame2RealTime(-frame, rate);
--- a/data/fileio/AudioFileReader.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/AudioFileReader.h	Wed Mar 04 12:01:04 2015 +0000
@@ -39,9 +39,9 @@
 
     sv_frame_t getFrameCount() const { return m_frameCount; }
     int getChannelCount() const { return m_channelCount; }
-    int getSampleRate() const { return m_sampleRate; }
+    sv_samplerate_t getSampleRate() const { return m_sampleRate; }
 
-    virtual int getNativeRate() const { return m_sampleRate; } // if resampled
+    virtual sv_samplerate_t getNativeRate() const { return m_sampleRate; } // if resampled
 
     /**
      * Return the location of the audio data in the reader (as passed
@@ -119,7 +119,7 @@
 protected:
     sv_frame_t m_frameCount;
     int m_channelCount;
-    int m_sampleRate;
+    sv_samplerate_t m_sampleRate;
 };
 
 #endif
--- a/data/fileio/AudioFileReaderFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/AudioFileReaderFactory.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -59,7 +59,7 @@
 
 AudioFileReader *
 AudioFileReaderFactory::createReader(FileSource source, 
-                                     int targetRate,
+                                     sv_samplerate_t targetRate,
                                      bool normalised,
                                      ProgressReporter *reporter)
 {
@@ -68,7 +68,7 @@
 
 AudioFileReader *
 AudioFileReaderFactory::createThreadingReader(FileSource source, 
-                                              int targetRate,
+                                              sv_samplerate_t targetRate,
                                               bool normalised,
                                               ProgressReporter *reporter)
 {
@@ -77,7 +77,7 @@
 
 AudioFileReader *
 AudioFileReaderFactory::create(FileSource source, 
-                               int targetRate, 
+                               sv_samplerate_t targetRate, 
                                bool normalised,
                                bool threading,
                                ProgressReporter *reporter)
@@ -105,7 +105,7 @@
 
         reader = new WavFileReader(source);
 
-        int fileRate = reader->getSampleRate();
+        sv_samplerate_t fileRate = reader->getSampleRate();
 
         if (reader->isOK() &&
             (!reader->isQuicklySeekable() ||
@@ -224,7 +224,7 @@
 
         reader = new WavFileReader(source);
 
-        int fileRate = reader->getSampleRate();
+        sv_samplerate_t fileRate = reader->getSampleRate();
 
         if (reader->isOK() &&
             (!reader->isQuicklySeekable() ||
--- a/data/fileio/AudioFileReaderFactory.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/AudioFileReaderFactory.h	Wed Mar 04 12:01:04 2015 +0000
@@ -19,6 +19,7 @@
 #include <QString>
 
 #include "FileSource.h"
+#include "base/BaseTypes.h"
 
 class AudioFileReader;
 class ProgressReporter;
@@ -53,7 +54,7 @@
      * Caller owns the returned object and must delete it after use.
      */
     static AudioFileReader *createReader(FileSource source,
-                                         int targetRate = 0,
+                                         sv_samplerate_t targetRate = 0,
                                          bool normalised = false,
                                          ProgressReporter *reporter = 0);
 
@@ -82,13 +83,13 @@
      * Caller owns the returned object and must delete it after use.
      */
     static AudioFileReader *createThreadingReader(FileSource source,
-                                                  int targetRate = 0,
+                                                  sv_samplerate_t targetRate = 0,
                                                   bool normalised = false,
                                                   ProgressReporter *reporter = 0);
 
 protected:
     static AudioFileReader *create(FileSource source,
-                                   int targetRate,
+                                   sv_samplerate_t targetRate,
                                    bool normalised,
                                    bool threading,
                                    ProgressReporter *reporter);
--- a/data/fileio/CodedAudioFileReader.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/CodedAudioFileReader.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -28,7 +28,7 @@
 #include <QMutexLocker>
 
 CodedAudioFileReader::CodedAudioFileReader(CacheMode cacheMode,
-                                           int targetRate,
+                                           sv_samplerate_t targetRate,
                                            bool normalised) :
     m_cacheMode(cacheMode),
     m_initialised(false),
@@ -113,7 +113,7 @@
         m_resampler = new Resampler(Resampler::FastestTolerable,
                                     m_channelCount,
                                     m_cacheWriteBufferSize);
-        double ratio = double(m_sampleRate) / double(m_fileRate);
+        double ratio = m_sampleRate / m_fileRate;
         m_resampleBuffer = new float
             [lrint(ceil(double(m_cacheWriteBufferSize) * m_channelCount * ratio + 1))];
     }
@@ -129,9 +129,15 @@
                                            .arg((intptr_t)this));
 
             SF_INFO fileInfo;
-            fileInfo.samplerate = m_sampleRate;
+            int fileRate = int(round(m_sampleRate));
+            if (m_sampleRate != sv_samplerate_t(fileRate)) {
+                cerr << "CodedAudioFileReader: WARNING: Non-integer sample rate "
+                     << m_sampleRate << " presented for writing, rounding to " << fileRate
+                     << endl;
+            }
+            fileInfo.samplerate = fileRate;
             fileInfo.channels = m_channelCount;
-
+            
             // No point in writing 24-bit or float; generally this
             // class is used for decoding files that have come from a
             // 16 bit source or that decode to only 16 bits anyway.
@@ -297,12 +303,12 @@
 {
     m_fileFrameCount += sz;
 
-    float ratio = 1.f;
+    double ratio = 1.0;
     if (m_resampler && m_fileRate != 0) {
-        ratio = float(m_sampleRate) / float(m_fileRate);
+        ratio = m_sampleRate / m_fileRate;
     }
         
-    if (ratio != 1.f) {
+    if (ratio != 1.0) {
         pushBufferResampling(buffer, sz, ratio, final);
     } else {
         pushBufferNonResampling(buffer, sz);
--- a/data/fileio/CodedAudioFileReader.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/CodedAudioFileReader.h	Wed Mar 04 12:01:04 2015 +0000
@@ -41,7 +41,7 @@
     virtual void getInterleavedFrames(sv_frame_t start, sv_frame_t count,
 				      SampleBlock &frames) const;
 
-    virtual int getNativeRate() const { return m_fileRate; }
+    virtual sv_samplerate_t getNativeRate() const { return m_fileRate; }
 
     virtual QString getLocalFilename() const { return m_cacheFileName; }
     
@@ -53,7 +53,7 @@
 
 protected:
     CodedAudioFileReader(CacheMode cacheMode, 
-                         int targetRate,
+                         sv_samplerate_t targetRate,
                          bool normalised);
 
     void initialiseDecodeCache(); // samplerate, channels must have been set
@@ -83,7 +83,7 @@
     mutable QReadWriteLock m_dataLock;
     bool m_initialised;
     Serialiser *m_serialiser;
-    int m_fileRate;
+    sv_samplerate_t m_fileRate;
 
     QString m_cacheFileName;
     SNDFILE *m_cacheFileWritePtr;
--- a/data/fileio/CoreAudioFileReader.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/CoreAudioFileReader.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -59,7 +59,7 @@
 CoreAudioFileReader::CoreAudioFileReader(FileSource source,
                                          DecodeMode decodeMode,
                                          CacheMode mode,
-                                         int targetRate,
+                                         sv_samplerate_t targetRate,
                                          bool normalised,
                                          ProgressReporter *reporter) :
     CodedAudioFileReader(mode, targetRate, normalised),
--- a/data/fileio/CoreAudioFileReader.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/CoreAudioFileReader.h	Wed Mar 04 12:01:04 2015 +0000
@@ -39,7 +39,7 @@
     CoreAudioFileReader(FileSource source,
                         DecodeMode decodeMode,
                         CacheMode cacheMode,
-                        int targetRate = 0,
+                        sv_samplerate_t targetRate = 0,
                         bool normalised = false,
                         ProgressReporter *reporter = 0);
     virtual ~CoreAudioFileReader();
--- a/data/fileio/DecodingWavFileReader.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/DecodingWavFileReader.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -24,7 +24,7 @@
 DecodingWavFileReader::DecodingWavFileReader(FileSource source,
                                              ResampleMode resampleMode,
                                              CacheMode mode,
-                                             int targetRate,
+                                             sv_samplerate_t targetRate,
                                              bool normalised,
                                              ProgressReporter *reporter) :
     CodedAudioFileReader(mode, targetRate, normalised),
--- a/data/fileio/DecodingWavFileReader.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/DecodingWavFileReader.h	Wed Mar 04 12:01:04 2015 +0000
@@ -37,7 +37,7 @@
     DecodingWavFileReader(FileSource source,
                           ResampleMode resampleMode,
                           CacheMode cacheMode,
-                          int targetRate = 0,
+                          sv_samplerate_t targetRate = 0,
                           bool normalised = false,
                           ProgressReporter *reporter = 0);
     virtual ~DecodingWavFileReader();
--- a/data/fileio/MP3FileReader.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/MP3FileReader.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -37,7 +37,7 @@
 #include <QFileInfo>
 
 MP3FileReader::MP3FileReader(FileSource source, DecodeMode decodeMode, 
-                             CacheMode mode, int targetRate,
+                             CacheMode mode, sv_samplerate_t targetRate,
                              bool normalised,
                              ProgressReporter *reporter) :
     CodedAudioFileReader(mode, targetRate, normalised),
--- a/data/fileio/MP3FileReader.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/MP3FileReader.h	Wed Mar 04 12:01:04 2015 +0000
@@ -40,7 +40,7 @@
     MP3FileReader(FileSource source,
                   DecodeMode decodeMode,
                   CacheMode cacheMode,
-                  int targetRate = 0,
+                  sv_samplerate_t targetRate = 0,
                   bool normalised = false,
                   ProgressReporter *reporter = 0);
     virtual ~MP3FileReader();
--- a/data/fileio/OggVorbisFileReader.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/OggVorbisFileReader.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -34,7 +34,7 @@
 OggVorbisFileReader::OggVorbisFileReader(FileSource source,
                                          DecodeMode decodeMode,
                                          CacheMode mode,
-                                         int targetRate,
+                                         sv_samplerate_t targetRate,
                                          bool normalised,
                                          ProgressReporter *reporter) :
     CodedAudioFileReader(mode, targetRate, normalised),
--- a/data/fileio/OggVorbisFileReader.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/OggVorbisFileReader.h	Wed Mar 04 12:01:04 2015 +0000
@@ -42,7 +42,7 @@
     OggVorbisFileReader(FileSource source,
                         DecodeMode decodeMode,
                         CacheMode cacheMode,
-                        int targetRate = 0,
+                        sv_samplerate_t targetRate = 0,
                         bool normalised = false,
                         ProgressReporter *reporter = 0);
     virtual ~OggVorbisFileReader();
--- a/data/fileio/QuickTimeFileReader.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/QuickTimeFileReader.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -50,7 +50,7 @@
 QuickTimeFileReader::QuickTimeFileReader(FileSource source,
                                          DecodeMode decodeMode,
                                          CacheMode mode,
-                                         int targetRate,
+                                         sv_samplerate_t targetRate,
                                          bool normalised,
                                          ProgressReporter *reporter) :
     CodedAudioFileReader(mode, targetRate, normalised),
--- a/data/fileio/QuickTimeFileReader.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/QuickTimeFileReader.h	Wed Mar 04 12:01:04 2015 +0000
@@ -42,7 +42,7 @@
     QuickTimeFileReader(FileSource source,
                         DecodeMode decodeMode,
                         CacheMode cacheMode,
-                        int targetRate = 0,
+                        sv_samplerate_t targetRate = 0,
                         bool normalised = false,
                         ProgressReporter *reporter = 0);
     virtual ~QuickTimeFileReader();
--- a/data/fileio/WavFileReader.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/WavFileReader.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -136,13 +136,13 @@
         return;
     }
 
-    if ((long)start >= m_fileInfo.frames) {
+    if (start >= m_fileInfo.frames) {
 //        SVDEBUG << "WavFileReader::getInterleavedFrames: " << start
 //                  << " > " << m_fileInfo.frames << endl;
 	return;
     }
 
-    if (long(start + count) > m_fileInfo.frames) {
+    if (start + count > m_fileInfo.frames) {
 	count = m_fileInfo.frames - start;
     }
 
--- a/data/fileio/WavFileWriter.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/WavFileWriter.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -25,7 +25,7 @@
 #include <iostream>
 
 WavFileWriter::WavFileWriter(QString path,
-			     int sampleRate,
+			     sv_samplerate_t sampleRate,
                              int channels,
                              FileWriteMode mode) :
     m_path(path),
@@ -35,7 +35,14 @@
     m_file(0)
 {
     SF_INFO fileInfo;
-    fileInfo.samplerate = m_sampleRate;
+
+    int fileRate = int(round(m_sampleRate));
+    if (m_sampleRate != sv_samplerate_t(fileRate)) {
+        cerr << "WavFileWriter: WARNING: Non-integer sample rate "
+             << m_sampleRate << " presented, rounding to " << fileRate
+             << endl;
+    }
+    fileInfo.samplerate = fileRate;
     fileInfo.channels = m_channels;
     fileInfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
 
--- a/data/fileio/WavFileWriter.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/WavFileWriter.h	Wed Mar 04 12:01:04 2015 +0000
@@ -46,7 +46,7 @@
         WriteToTarget
     };
 
-    WavFileWriter(QString path, int sampleRate, int channels,
+    WavFileWriter(QString path, sv_samplerate_t sampleRate, int channels,
                   FileWriteMode mode);
     virtual ~WavFileWriter();
 
@@ -65,7 +65,7 @@
 
 protected:
     QString m_path;
-    int m_sampleRate;
+    sv_samplerate_t m_sampleRate;
     int m_channels;
     TempWriteFile *m_temp;
     SNDFILE *m_file;
--- a/data/fileio/test/AudioFileReaderTest.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/test/AudioFileReaderTest.h	Wed Mar 04 12:01:04 2015 +0000
@@ -63,7 +63,7 @@
     {
         QFETCH(QString, audiofile);
 
-        int readRate = 48000;
+        sv_samplerate_t readRate = 48000;
 
 	AudioFileReader *reader =
 	    AudioFileReaderFactory::createReader
@@ -72,7 +72,7 @@
         QStringList fileAndExt = audiofile.split(".");
         QStringList bits = fileAndExt[0].split("-");
         QString extension = fileAndExt[1];
-        int nominalRate = bits[0].toInt();
+        sv_samplerate_t nominalRate = bits[0].toInt();
         int nominalChannels = bits[1].toInt();
         int nominalDepth = 16;
         if (bits.length() > 2) nominalDepth = bits[2].toInt();
@@ -86,14 +86,14 @@
 	}
 
         QCOMPARE((int)reader->getChannelCount(), nominalChannels);
-        QCOMPARE((int)reader->getNativeRate(), nominalRate);
-        QCOMPARE((int)reader->getSampleRate(), readRate);
+        QCOMPARE(reader->getNativeRate(), nominalRate);
+        QCOMPARE(reader->getSampleRate(), readRate);
 
 	int channels = reader->getChannelCount();
 	AudioTestData tdata(readRate, channels);
 	
 	float *reference = tdata.getInterleavedData();
-        int refFrames = tdata.getFrameCount();
+        sv_frame_t refFrames = tdata.getFrameCount();
 	
 	vector<float> test;
 	
@@ -103,7 +103,7 @@
 	// expected number back (if this is not mp3/aac) or (b) take
 	// into account silence at beginning and end (if it is).
 	reader->getInterleavedFrames(0, refFrames + 5000, test);
-	int read = test.size() / channels;
+	sv_frame_t read = test.size() / channels;
 
         if (extension == "mp3" || extension == "aac" || extension == "m4a") {
             // mp3s and aacs can have silence at start and end
@@ -116,8 +116,8 @@
         // or resampler quality here, just whether the results are
         // plainly wrong (e.g. at wrong samplerate or with an offset)
 
-	float limit = 0.01;
-        float edgeLimit = limit * 10; // in first or final edgeSize frames
+	double limit = 0.01;
+        double edgeLimit = limit * 10; // in first or final edgeSize frames
         int edgeSize = 100; 
 
         if (nominalDepth < 16) {
@@ -130,23 +130,23 @@
         }
 
         // And we ignore completely the last few frames when upsampling
-        int discard = 1 + readRate / nominalRate;
+        int discard = 1 + int(round(readRate / nominalRate));
 
         int offset = 0;
 
         if (extension == "aac" || extension == "m4a") {
             // our m4a file appears to have a fixed offset of 1024 (at
             // file sample rate)
-            offset = (1024 / float(nominalRate)) * readRate;
+            offset = int(round((1024 / nominalRate) * readRate));
         }
 
         if (extension == "mp3") {
             // while mp3s appear to vary
             for (int i = 0; i < read; ++i) {
                 bool any = false;
-                float thresh = 0.01;
+                double thresh = 0.01;
                 for (int c = 0; c < channels; ++c) {
-                    if (fabsf(test[i * channels + c]) > thresh) {
+                    if (fabs(test[i * channels + c]) > thresh) {
                         any = true;
                         break;
                     }
@@ -180,7 +180,7 @@
                     }
 		}
 	    }
-	    float meandiff = totdiff / read;
+	    float meandiff = totdiff / float(read);
 //	    cerr << "meandiff on channel " << c << ": " << meandiff << endl;
 //	    cerr << "maxdiff on channel " << c << ": " << maxdiff << " at " << maxAt << endl;
             if (meandiff >= limit) {
--- a/data/fileio/test/AudioTestData.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/fileio/test/AudioTestData.h	Wed Mar 04 12:01:04 2015 +0000
@@ -18,6 +18,8 @@
 
 #include <cmath>
 
+#include "base/BaseTypes.h"
+
 /**
  * Class that generates a single fixed test pattern to a given sample
  * rate and number of channels.
@@ -35,7 +37,7 @@
 class AudioTestData
 {
 public:
-    AudioTestData(float rate, int channels) :
+    AudioTestData(double rate, int channels) :
 	m_channelCount(channels),
 	m_duration(2.0),
 	m_sampleRate(rate),
@@ -54,24 +56,25 @@
 
     void generate() {
 
-	float hpw = m_pulseWidth / 2.0;
+	double hpw = m_pulseWidth / 2.0;
 
 	for (int i = 0; i < m_frameCount; ++i) {
 	    for (int c = 0; c < m_channelCount; ++c) {
 
-		float s = 0.f;
+		double s = 0.0;
 
 		if (c == 0) {
 
-		    float phase = (i * m_sinFreq * 2.f * M_PI) / m_sampleRate;
-		    s = sinf(phase);
+		    double phase = (i * m_sinFreq * 2.0 * M_PI) / m_sampleRate;
+		    s = sin(phase);
 
 		} else if (c == 1) {
 
 		    int pulseNo = int((i * m_pulseFreq) / m_sampleRate);
-		    int index = (i * m_pulseFreq) - (m_sampleRate * pulseNo);
+		    int index = int(round((i * m_pulseFreq) -
+                                          (m_sampleRate * pulseNo)));
 		    if (index < m_pulseWidth) {
-			s = 1.0 - fabsf(hpw - index) / hpw;
+			s = 1.0 - fabs(hpw - index) / hpw;
 			if (pulseNo % 2) s = -s;
 		    }
 
@@ -80,7 +83,7 @@
 		    s = c / 20.0;
 		}
 
-		m_data[i * m_channelCount + c] = s;
+		m_data[i * m_channelCount + c] = float(s);
 	    }
 	}
     }
@@ -89,7 +92,7 @@
 	return m_data;
     }
 
-    int getFrameCount() const { 
+    sv_frame_t getFrameCount() const { 
 	return m_frameCount;
     }
 
@@ -97,23 +100,23 @@
 	return m_channelCount;
     }
 
-    float getSampleRate () const {
+    sv_samplerate_t getSampleRate () const {
 	return m_sampleRate;
     }
 
-    float getDuration() const { // seconds
+    double getDuration() const { // seconds
 	return m_duration;
     }
 
 private:
     float *m_data;
-    int m_frameCount;
+    sv_frame_t m_frameCount;
     int m_channelCount;
-    float m_duration;
-    float m_sampleRate;
-    float m_sinFreq;
-    float m_pulseFreq;
-    float m_pulseWidth;
+    double m_duration;
+    sv_samplerate_t m_sampleRate;
+    double m_sinFreq;
+    double m_pulseFreq;
+    double m_pulseWidth;
 };
 
 #endif
--- a/data/model/AggregateWaveModel.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/AggregateWaveModel.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -85,7 +85,7 @@
     return int(m_components.size());
 }
 
-int
+sv_samplerate_t
 AggregateWaveModel::getSampleRate() const
 {
     if (m_components.empty()) return 0;
--- a/data/model/AggregateWaveModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/AggregateWaveModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -51,7 +51,7 @@
 
     sv_frame_t getFrameCount() const;
     int getChannelCount() const;
-    int getSampleRate() const;
+    sv_samplerate_t getSampleRate() const;
 
     virtual Model *clone() const;
 
--- a/data/model/AlignmentModel.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/AlignmentModel.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -90,7 +90,7 @@
     return std::max(a, b);
 }
 
-int
+sv_samplerate_t
 AlignmentModel::getSampleRate() const
 {
     return m_reference->getSampleRate();
--- a/data/model/AlignmentModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/AlignmentModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -39,7 +39,7 @@
     virtual bool isOK() const;
     virtual sv_frame_t getStartFrame() const;
     virtual sv_frame_t getEndFrame() const;
-    virtual int getSampleRate() const;
+    virtual sv_samplerate_t getSampleRate() const;
     virtual Model *clone() const;
     virtual bool isReady(int *completion = 0) const;
     virtual const ZoomConstraint *getZoomConstraint() const;
--- a/data/model/Dense3DModelPeakCache.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/Dense3DModelPeakCache.h	Wed Mar 04 12:01:04 2015 +0000
@@ -33,7 +33,7 @@
         return m_source && m_source->isOK(); 
     }
 
-    virtual int getSampleRate() const {
+    virtual sv_samplerate_t getSampleRate() const {
         return m_source->getSampleRate();
     }
 
--- a/data/model/EditableDenseThreeDimensionalModel.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/EditableDenseThreeDimensionalModel.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -29,7 +29,7 @@
 
 #include "system/System.h"
 
-EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(int sampleRate,
+EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate,
                                                                        int resolution,
                                                                        int yBinCount,
                                                                        CompressionType compression,
@@ -55,7 +55,7 @@
     return true;
 }
 
-int
+sv_samplerate_t
 EditableDenseThreeDimensionalModel::getSampleRate() const
 {
     return m_sampleRate;
--- a/data/model/EditableDenseThreeDimensionalModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/EditableDenseThreeDimensionalModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -42,7 +42,7 @@
         BasicMultirateCompression
     };
 
-    EditableDenseThreeDimensionalModel(int sampleRate,
+    EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate,
 				       int resolution,
 				       int yBinCount,
                                        CompressionType compression,
@@ -50,7 +50,7 @@
 
     virtual bool isOK() const;
 
-    virtual int getSampleRate() const;
+    virtual sv_samplerate_t getSampleRate() const;
     virtual sv_frame_t getStartFrame() const;
     virtual sv_frame_t getEndFrame() const;
 
@@ -217,7 +217,7 @@
     QString m_binValueUnit;
 
     sv_frame_t m_startFrame;
-    int m_sampleRate;
+    sv_samplerate_t m_sampleRate;
     int m_resolution;
     int m_yBinCount;
     CompressionType m_compression;
--- a/data/model/FFTModel.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/FFTModel.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -159,7 +159,7 @@
                                            fillFromColumn);
 }
 
-int
+sv_samplerate_t
 FFTModel::getSampleRate() const
 {
     return isOK() ? m_server->getModel()->getSampleRate() : 0;
@@ -198,7 +198,7 @@
 QString
 FFTModel::getBinName(int n) const
 {
-    int sr = getSampleRate();
+    sv_samplerate_t sr = getSampleRate();
     if (!sr) return "";
     QString name = tr("%1 Hz").arg((n * sr) / ((getHeight()-1) * 2));
     return name;
@@ -209,10 +209,10 @@
 {
     if (!isOK()) return false;
 
-    int sampleRate = m_server->getModel()->getSampleRate();
+    sv_samplerate_t sampleRate = m_server->getModel()->getSampleRate();
 
     int fftSize = m_server->getFFTSize() >> m_yshift;
-    frequency = float((double(y) * sampleRate) / fftSize);
+    frequency = float((y * sampleRate) / fftSize);
 
     if (x+1 >= getWidth()) return false;
 
@@ -291,7 +291,7 @@
     // exceed the median.  For pitch adaptivity, we adjust the window
     // size to a roughly constant pitch range (about four tones).
 
-    int sampleRate = getSampleRate();
+    sv_samplerate_t sampleRate = getSampleRate();
 
     std::deque<float> window;
     std::vector<int> inrange;
@@ -373,7 +373,7 @@
 }
 
 int
-FFTModel::getPeakPickWindowSize(PeakPickType type, int sampleRate,
+FFTModel::getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate,
                                 int bin, float &percentile) const
 {
     percentile = 0.5;
@@ -381,7 +381,7 @@
     if (bin == 0) return 3;
 
     int fftSize = m_server->getFFTSize() >> m_yshift;
-    double binfreq = (double(sampleRate) * bin) / fftSize;
+    double binfreq = (sampleRate * bin) / fftSize;
     double hifreq = Pitch::getFrequencyForPitch(73, 0, binfreq);
 
     int hibin = int(lrint((hifreq * fftSize) / sampleRate));
@@ -403,7 +403,7 @@
     if (!isOK()) return peaks;
     PeakLocationSet locations = getPeaks(type, x, ymin, ymax);
 
-    int sampleRate = getSampleRate();
+    sv_samplerate_t sampleRate = getSampleRate();
     int fftSize = m_server->getFFTSize() >> m_yshift;
     int incr = getResolution();
 
--- a/data/model/FFTModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/FFTModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -126,7 +126,7 @@
     virtual sv_frame_t getEndFrame() const {
         return sv_frame_t(getWidth()) * getResolution() + getResolution();
     }
-    virtual int getSampleRate() const;
+    virtual sv_samplerate_t getSampleRate() const;
     virtual int getResolution() const {
         return m_server->getWindowIncrement() << m_xshift;
     }
@@ -202,8 +202,8 @@
                              int, WindowType, int, int, int,
                              bool, StorageAdviser::Criteria, int);
 
-    int getPeakPickWindowSize(PeakPickType type, int sampleRate,
-                                 int bin, float &percentile) const;
+    int getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate,
+                              int bin, float &percentile) const;
 
     int getYRatio() {
         int ys = m_yshift;
--- a/data/model/FlexiNoteModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/FlexiNoteModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -66,7 +66,7 @@
             .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, int sampleRate) const
+    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
@@ -102,15 +102,15 @@
     Q_OBJECT
     
 public:
-    FlexiNoteModel(int sampleRate, int resolution,
-	      bool notifyOnAdd = true) :
+    FlexiNoteModel(sv_samplerate_t sampleRate, int resolution,
+                   bool notifyOnAdd = true) :
 	IntervalModel<FlexiNote>(sampleRate, resolution, notifyOnAdd),
 	m_valueQuantization(0)
     {
 	PlayParameterRepository::getInstance()->addPlayable(this);
     }
 
-    FlexiNoteModel(int sampleRate, int resolution,
+    FlexiNoteModel(sv_samplerate_t sampleRate, int resolution,
 	      float valueMinimum, float valueMaximum,
 	      bool notifyOnAdd = true) :
 	IntervalModel<FlexiNote>(sampleRate, resolution,
@@ -238,7 +238,7 @@
         for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) {
     	    sv_frame_t duration = pli->duration;
             if (duration == 0 || duration == 1) {
-                duration = getSampleRate() / 20;
+                duration = sv_frame_t(getSampleRate() / 20);
             }
             int pitch = int(lrintf(pli->value));
 
--- a/data/model/ImageModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/ImageModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -55,7 +55,7 @@
             .arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, int sampleRate) const
+    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
@@ -89,7 +89,7 @@
     Q_OBJECT
 
 public:
-    ImageModel(int sampleRate, int resolution, bool notifyOnAdd = true) :
+    ImageModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) :
 	SparseModel<ImagePoint>(sampleRate, resolution, notifyOnAdd)
     { }
 
--- a/data/model/IntervalModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/IntervalModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -29,12 +29,12 @@
 class IntervalModel : public SparseValueModel<PointType>
 {
 public:
-    IntervalModel(int sampleRate, int resolution,
+    IntervalModel(sv_samplerate_t sampleRate, int resolution,
                   bool notifyOnAdd = true) :
 	SparseValueModel<PointType>(sampleRate, resolution, notifyOnAdd)
     { }
 
-    IntervalModel(int sampleRate, int resolution,
+    IntervalModel(sv_samplerate_t sampleRate, int resolution,
                   float valueMinimum, float valueMaximum,
                   bool notifyOnAdd = true) :
 	SparseValueModel<PointType>(sampleRate, resolution,
--- a/data/model/Model.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/Model.h	Wed Mar 04 12:01:04 2015 +0000
@@ -61,13 +61,13 @@
     /**
      * Return the frame rate in frames per second.
      */
-    virtual int getSampleRate() const = 0;
+    virtual sv_samplerate_t getSampleRate() const = 0;
 
     /**
      * Return the frame rate of the underlying material, if the model
      * itself has already been resampled.
      */
-    virtual int getNativeRate() const { return getSampleRate(); }
+    virtual sv_samplerate_t getNativeRate() const { return getSampleRate(); }
 
     /**
      * Return the "work title" of the model, if known.
--- a/data/model/NoteModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/NoteModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -62,7 +62,7 @@
             .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, int sampleRate) const
+    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
@@ -98,7 +98,7 @@
     Q_OBJECT
     
 public:
-    NoteModel(int sampleRate, int resolution,
+    NoteModel(sv_samplerate_t sampleRate, int resolution,
 	      bool notifyOnAdd = true) :
 	IntervalModel<Note>(sampleRate, resolution, notifyOnAdd),
 	m_valueQuantization(0)
@@ -106,7 +106,7 @@
 	PlayParameterRepository::getInstance()->addPlayable(this);
     }
 
-    NoteModel(int sampleRate, int resolution,
+    NoteModel(sv_samplerate_t sampleRate, int resolution,
 	      float valueMinimum, float valueMaximum,
 	      bool notifyOnAdd = true) :
 	IntervalModel<Note>(sampleRate, resolution,
@@ -234,7 +234,7 @@
 
 	    sv_frame_t duration = pli->duration;
             if (duration == 0 || duration == 1) {
-                duration = getSampleRate() / 20;
+                duration = sv_frame_t(getSampleRate() / 20);
             }
 
             int pitch = int(lrintf(pli->value));
--- a/data/model/PathModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/PathModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -19,20 +19,21 @@
 #include "Model.h"
 #include "SparseModel.h"
 #include "base/RealTime.h"
+#include "base/BaseTypes.h"
 
 #include <QStringList>
 
 
 struct PathPoint
 {
-    PathPoint(long _frame) : frame(_frame), mapframe(_frame) { }
-    PathPoint(long _frame, long _mapframe) :
+    PathPoint(sv_frame_t _frame) : frame(_frame), mapframe(_frame) { }
+    PathPoint(sv_frame_t _frame, sv_frame_t _mapframe) :
         frame(_frame), mapframe(_mapframe) { }
 
     int getDimensions() const { return 2; }
 
-    long frame;
-    long mapframe;
+    sv_frame_t frame;
+    sv_frame_t mapframe;
 
     QString getLabel() const { return ""; }
 
@@ -43,7 +44,7 @@
     }
         
     QString toDelimitedDataString(QString delimiter,
-                                  int sampleRate) const {
+                                  sv_samplerate_t sampleRate) const {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
         list << QString("%1").arg(mapframe);
@@ -67,7 +68,7 @@
 class PathModel : public SparseModel<PathPoint>
 {
 public:
-    PathModel(int sampleRate, int resolution, bool notify = true) :
+    PathModel(sv_samplerate_t sampleRate, int resolution, bool notify = true) :
         SparseModel<PathPoint>(sampleRate, resolution, notify) { }
 
     virtual void toXml(QTextStream &out,
--- a/data/model/RegionModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/RegionModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -60,7 +60,7 @@
             .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, int sampleRate) const
+    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
@@ -94,7 +94,7 @@
     Q_OBJECT
     
 public:
-    RegionModel(int sampleRate, int resolution,
+    RegionModel(sv_samplerate_t sampleRate, int resolution,
                 bool notifyOnAdd = true) :
 	IntervalModel<RegionRec>(sampleRate, resolution, notifyOnAdd),
 	m_valueQuantization(0),
@@ -102,7 +102,7 @@
     {
     }
 
-    RegionModel(int sampleRate, int resolution,
+    RegionModel(sv_samplerate_t sampleRate, int resolution,
                 float valueMinimum, float valueMaximum,
                 bool notifyOnAdd = true) :
 	IntervalModel<RegionRec>(sampleRate, resolution,
--- a/data/model/SparseModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/SparseModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -43,14 +43,14 @@
                     public TabularModel
 {
 public:
-    SparseModel(int sampleRate, int resolution,
+    SparseModel(sv_samplerate_t sampleRate, int resolution,
 		bool notifyOnAdd = true);
     virtual ~SparseModel() { }
     
     virtual bool isOK() const { return true; }
     virtual sv_frame_t getStartFrame() const;
     virtual sv_frame_t getEndFrame() const;
-    virtual int getSampleRate() const { return m_sampleRate; }
+    virtual sv_samplerate_t getSampleRate() const { return m_sampleRate; }
 
     virtual Model *clone() const;
 
@@ -366,7 +366,7 @@
     }
             
 protected:
-    int m_sampleRate;
+    sv_samplerate_t m_sampleRate;
     int m_resolution;
     bool m_notifyOnAdd;
     sv_frame_t m_sinceLastNotifyMin;
@@ -460,7 +460,7 @@
 
 
 template <typename PointType>
-SparseModel<PointType>::SparseModel(int sampleRate,
+SparseModel<PointType>::SparseModel(sv_samplerate_t sampleRate,
                                     int resolution,
                                     bool notifyOnAdd) :
     m_sampleRate(sampleRate),
--- a/data/model/SparseOneDimensionalModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/SparseOneDimensionalModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -45,7 +45,7 @@
             .arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, int sampleRate) const
+    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
@@ -76,7 +76,7 @@
     Q_OBJECT
     
 public:
-    SparseOneDimensionalModel(int sampleRate, int resolution,
+    SparseOneDimensionalModel(sv_samplerate_t sampleRate, int resolution,
 			      bool notifyOnAdd = true) :
 	SparseModel<OneDimensionalPoint>(sampleRate, resolution, notifyOnAdd)
     {
@@ -197,7 +197,7 @@
 
             notes.push_back
                 (NoteData(pli->frame,
-                          getSampleRate() / 6, // arbitrary short duration
+                          sv_frame_t(getSampleRate() / 6), // arbitrary short duration
                           64,   // default pitch
                           100)); // default velocity
         }
--- a/data/model/SparseTimeValueModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/SparseTimeValueModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -49,7 +49,7 @@
             .arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, int sampleRate) const
+    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
@@ -81,7 +81,7 @@
     Q_OBJECT
     
 public:
-    SparseTimeValueModel(int sampleRate, int resolution,
+    SparseTimeValueModel(sv_samplerate_t sampleRate, int resolution,
 			 bool notifyOnAdd = true) :
 	SparseValueModel<TimeValuePoint>(sampleRate, resolution,
 					 notifyOnAdd)
@@ -91,7 +91,7 @@
 	PlayParameterRepository::getInstance()->addPlayable(this);
     }
 
-    SparseTimeValueModel(int sampleRate, int resolution,
+    SparseTimeValueModel(sv_samplerate_t sampleRate, int resolution,
 			 float valueMinimum, float valueMaximum,
 			 bool notifyOnAdd = true) :
 	SparseValueModel<TimeValuePoint>(sampleRate, resolution,
--- a/data/model/SparseValueModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/SparseValueModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -31,7 +31,7 @@
 class SparseValueModel : public SparseModel<PointType>
 {
 public:
-    SparseValueModel(int sampleRate, int resolution,
+    SparseValueModel(sv_samplerate_t sampleRate, int resolution,
 		     bool notifyOnAdd = true) :
 	SparseModel<PointType>(sampleRate, resolution, notifyOnAdd),
 	m_valueMinimum(0.f),
@@ -39,7 +39,7 @@
         m_haveExtents(false)
     { }
 
-    SparseValueModel(int sampleRate, int resolution,
+    SparseValueModel(sv_samplerate_t sampleRate, int resolution,
 		     float valueMinimum, float valueMaximum,
 		     bool notifyOnAdd = true) :
 	SparseModel<PointType>(sampleRate, resolution, notifyOnAdd),
--- a/data/model/TextModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/TextModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -51,7 +51,7 @@
             .arg(encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, int sampleRate) const
+    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
@@ -85,7 +85,7 @@
     Q_OBJECT
     
 public:
-    TextModel(int sampleRate, int resolution, bool notifyOnAdd = true) :
+    TextModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) :
 	SparseModel<TextPoint>(sampleRate, resolution, notifyOnAdd)
     { }
 
--- a/data/model/WaveFileModel.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/WaveFileModel.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -37,7 +37,7 @@
 PowerOfSqrtTwoZoomConstraint
 WaveFileModel::m_zoomConstraint;
 
-WaveFileModel::WaveFileModel(FileSource source, int targetRate) :
+WaveFileModel::WaveFileModel(FileSource source, sv_samplerate_t targetRate) :
     m_source(source),
     m_path(source.getLocation()),
     m_reader(0),
@@ -145,18 +145,18 @@
     return m_reader->getChannelCount();
 }
 
-int
+sv_samplerate_t
 WaveFileModel::getSampleRate() const 
 {
     if (!m_reader) return 0;
     return m_reader->getSampleRate();
 }
 
-int
+sv_samplerate_t
 WaveFileModel::getNativeRate() const 
 {
     if (!m_reader) return 0;
-    int rate = m_reader->getNativeRate();
+    sv_samplerate_t rate = m_reader->getNativeRate();
     if (rate == 0) rate = getSampleRate();
     return rate;
 }
--- a/data/model/WaveFileModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/WaveFileModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -34,7 +34,7 @@
     Q_OBJECT
 
 public:
-    WaveFileModel(FileSource source, int targetRate = 0);
+    WaveFileModel(FileSource source, sv_samplerate_t targetRate = 0);
     WaveFileModel(FileSource source, AudioFileReader *reader);
     ~WaveFileModel();
 
@@ -45,8 +45,8 @@
 
     sv_frame_t getFrameCount() const;
     int getChannelCount() const;
-    int getSampleRate() const;
-    int getNativeRate() const;
+    sv_samplerate_t getSampleRate() const;
+    sv_samplerate_t getNativeRate() const;
 
     QString getTitle() const;
     QString getMaker() const;
--- a/data/model/WritableWaveFileModel.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/WritableWaveFileModel.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -30,7 +30,7 @@
 
 //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1
 
-WritableWaveFileModel::WritableWaveFileModel(int sampleRate,
+WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate,
 					     int channels,
 					     QString path) :
     m_model(0),
--- a/data/model/WritableWaveFileModel.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/data/model/WritableWaveFileModel.h	Wed Mar 04 12:01:04 2015 +0000
@@ -26,7 +26,7 @@
     Q_OBJECT
 
 public:
-    WritableWaveFileModel(int sampleRate, int channels, QString path = "");
+    WritableWaveFileModel(sv_samplerate_t sampleRate, int channels, QString path = "");
     ~WritableWaveFileModel();
 
     /**
@@ -50,7 +50,7 @@
 
     sv_frame_t getFrameCount() const;
     int getChannelCount() const { return m_channels; }
-    int getSampleRate() const { return m_sampleRate; }
+    sv_samplerate_t getSampleRate() const { return m_sampleRate; }
 
     virtual Model *clone() const;
 
@@ -89,7 +89,7 @@
     WaveFileModel *m_model;
     WavFileWriter *m_writer;
     WavFileReader *m_reader;
-    int m_sampleRate;
+    sv_samplerate_t m_sampleRate;
     int m_channels;
     sv_frame_t m_frameCount;
     sv_frame_t m_startFrame;
--- a/plugin/DSSIPluginFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/DSSIPluginFactory.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -113,9 +113,9 @@
 DSSIPluginFactory::instantiatePlugin(QString identifier,
 				     int instrument,
 				     int position,
-				     unsigned int sampleRate,
-				     unsigned int blockSize,
-				     unsigned int channels)
+				     sv_samplerate_t sampleRate,
+				     int blockSize,
+				     int channels)
 {
     Profiler profiler("DSSIPluginFactory::instantiatePlugin");
 
--- a/plugin/DSSIPluginFactory.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/DSSIPluginFactory.h	Wed Mar 04 12:01:04 2015 +0000
@@ -40,9 +40,9 @@
     virtual RealTimePluginInstance *instantiatePlugin(QString identifier,
 						      int clientId,
 						      int position,
-						      unsigned int sampleRate,
-						      unsigned int blockSize,
-						      unsigned int channels);
+						      sv_samplerate_t sampleRate,
+						      int blockSize,
+						      int channels);
 
 protected:
     DSSIPluginFactory();
--- a/plugin/DSSIPluginInstance.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/DSSIPluginInstance.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -57,8 +57,8 @@
 				       int clientId,
 				       QString identifier,
 				       int position,
-				       int sampleRate,
-				       size_t blockSize,
+				       sv_samplerate_t sampleRate,
+				       int blockSize,
 				       int idealChannelCount,
 				       const DSSI_Descriptor* descriptor) :
     RealTimePluginInstance(factory, identifier),
@@ -90,7 +90,7 @@
     for (size_t i = 0; i < m_audioPortsIn.size(); ++i) {
 	m_inputBuffers[i] = new sample_t[blockSize];
     }
-    for (size_t i = 0; i < m_outputBufferCount; ++i) {
+    for (int i = 0; i < m_outputBufferCount; ++i) {
 	m_outputBuffers[i] = new sample_t[blockSize];
     }
 
@@ -265,13 +265,14 @@
 #endif
     }
 
-    m_outputBufferCount = std::max(m_idealChannelCount, m_audioPortsOut.size());
+    m_outputBufferCount = std::max(m_idealChannelCount,
+                                   (int)m_audioPortsOut.size());
 }
 
-size_t
+sv_frame_t
 DSSIPluginInstance::getLatency()
 {
-    size_t latency = 0;
+    sv_frame_t latency = 0;
 
 #ifdef DEBUG_DSSI_PROCESS
     SVDEBUG << "DSSIPluginInstance::getLatency(): m_latencyPort " << m_latencyPort << ", m_run " << m_run << endl;
@@ -279,14 +280,14 @@
 
     if (m_latencyPort) {
 	if (!m_run) {
-            for (size_t i = 0; i < getAudioInputCount(); ++i) {
-                for (size_t j = 0; j < m_blockSize; ++j) {
+            for (int i = 0; i < getAudioInputCount(); ++i) {
+                for (int j = 0; j < m_blockSize; ++j) {
                     m_inputBuffers[i][j] = 0.f;
                 }
             }
             run(Vamp::RealTime::zeroTime);
         }
-	latency = (size_t)(*m_latencyPort + 0.1);
+	latency = (sv_frame_t)(*m_latencyPort + 0.1);
     }
     
 #ifdef DEBUG_DSSI_PROCESS
@@ -312,7 +313,7 @@
 }
 
 void
-DSSIPluginInstance::setIdealChannelCount(size_t channels)
+DSSIPluginInstance::setIdealChannelCount(int channels)
 {
 #ifdef DEBUG_DSSI
     SVDEBUG << "DSSIPluginInstance::setIdealChannelCount: channel count "
@@ -332,7 +333,7 @@
 
     if (channels > m_outputBufferCount) {
 
-	for (size_t i = 0; i < m_outputBufferCount; ++i) {
+	for (int i = 0; i < m_outputBufferCount; ++i) {
 	    delete[] m_outputBuffers[i];
 	}
 
@@ -342,7 +343,7 @@
 
 	m_outputBuffers = new sample_t*[m_outputBufferCount];
 
-	for (size_t i = 0; i < m_outputBufferCount; ++i) {
+	for (int i = 0; i < m_outputBufferCount; ++i) {
 	    m_outputBuffers[i] = new sample_t[m_blockSize];
 	}
 
@@ -438,10 +439,10 @@
     m_controlPortsOut.clear();
 
     if (m_ownBuffers) {
-	for (size_t i = 0; i < m_audioPortsIn.size(); ++i) {
+	for (int i = 0; i < getAudioInputCount(); ++i) {
 	    delete[] m_inputBuffers[i];
 	}
-	for (size_t i = 0; i < m_outputBufferCount; ++i) {
+	for (int i = 0; i < m_outputBufferCount; ++i) {
 	    delete[] m_outputBuffers[i];
 	}
 
@@ -455,7 +456,7 @@
 
 
 void
-DSSIPluginInstance::instantiate(int sampleRate)
+DSSIPluginInstance::instantiate(sv_samplerate_t sampleRate)
 {
     if (!m_descriptor) return;
 
@@ -472,7 +473,13 @@
 	return;
     }
 
-    m_instanceHandle = descriptor->instantiate(descriptor, sampleRate);
+    unsigned long pluginRate = (unsigned long)(sampleRate);
+    if (sampleRate != sv_samplerate_t(pluginRate)) {
+        cerr << "DSSIPluginInstance: WARNING: Non-integer sample rate "
+             << sampleRate << " presented, rounding to " << pluginRate
+             << endl;
+    }
+    m_instanceHandle = descriptor->instantiate(descriptor, pluginRate);
 
     if (m_instanceHandle) {
 
@@ -689,7 +696,7 @@
 {
     if (!m_descriptor || !m_descriptor->LADSPA_Plugin->connect_port) return;
 #ifdef DEBUG_DSSI
-    SVDEBUG << "DSSIPluginInstance::connectPorts: " << m_audioPortsIn.size() 
+    SVDEBUG << "DSSIPluginInstance::connectPorts: " << getAudioInputCount() 
 	      << " audio ports in, " << m_audioPortsOut.size() << " out, "
 	      << m_outputBufferCount << " output buffers" << endl;
 #endif
@@ -700,7 +707,7 @@
     LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory);
     int inbuf = 0, outbuf = 0;
 
-    for (size_t i = 0; i < m_audioPortsIn.size(); ++i) {
+    for (int i = 0; i < getAudioInputCount(); ++i) {
 	m_descriptor->LADSPA_Plugin->connect_port
 	    (m_instanceHandle,
 	     m_audioPortsIn[i],
@@ -811,7 +818,7 @@
 }
 
 float
-DSSIPluginInstance::getControlOutputValue(size_t output) const
+DSSIPluginInstance::getControlOutputValue(int output) const
 {
     if (!in_range_for(m_controlPortsOut, output)) return 0.0;
     return (*m_controlPortsOut[output].second);
@@ -906,7 +913,7 @@
 }
 
 void
-DSSIPluginInstance::sendEvent(const Vamp::RealTime &eventTime,
+DSSIPluginInstance::sendEvent(const RealTime &eventTime,
 			      const void *e)
 {
 #ifdef DEBUG_DSSI_PROCESS
@@ -982,7 +989,7 @@
 }
 
 void
-DSSIPluginInstance::run(const Vamp::RealTime &blockTime, size_t count)
+DSSIPluginInstance::run(const RealTime &blockTime, int count)
 {
     static snd_seq_event_t localEventBuffer[EVENT_BUFFER_SIZE];
     int evCount = 0;
@@ -1038,13 +1045,11 @@
 	*ev = m_eventBuffer.peekOne();
 	bool accept = true;
 
-	Vamp::RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec);
+	RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec);
 
-        long frameOffset = 0;
+        sv_frame_t frameOffset = 0;
 	if (evTime > blockTime) {
-	    frameOffset = Vamp::RealTime::realTime2Frame
-                (evTime - blockTime,
-                 (unsigned int)m_sampleRate);
+	    frameOffset = RealTime::realTime2Frame(evTime - blockTime, m_sampleRate);
 	}
 
 #ifdef DEBUG_DSSI_PROCESS
@@ -1112,28 +1117,30 @@
  done:
     if (needLock) m_processLock.unlock();
 
-    if (m_audioPortsOut.size() == 0) {
+    int numAudioOuts = int(m_audioPortsOut.size());
+    
+    if (numAudioOuts == 0) {
 	// copy inputs to outputs
-	for (size_t ch = 0; ch < m_idealChannelCount; ++ch) {
-	    size_t sch = ch % m_audioPortsIn.size();
-	    for (size_t i = 0; i < m_blockSize; ++i) {
+	for (int ch = 0; ch < m_idealChannelCount; ++ch) {
+	    int sch = ch % getAudioInputCount();
+	    for (int i = 0; i < m_blockSize; ++i) {
 		m_outputBuffers[ch][i] = m_inputBuffers[sch][i];
 	    }
 	}
-    } else if (m_idealChannelCount < m_audioPortsOut.size()) {
+    } else if (m_idealChannelCount < numAudioOuts) {
 	if (m_idealChannelCount == 1) {
 	    // mix down to mono
-	    for (size_t ch = 1; ch < m_audioPortsOut.size(); ++ch) {
-		for (size_t i = 0; i < m_blockSize; ++i) {
+	    for (int ch = 1; ch < numAudioOuts; ++ch) {
+		for (int i = 0; i < m_blockSize; ++i) {
 		    m_outputBuffers[0][i] += m_outputBuffers[ch][i];
 		}
 	    }
 	}
-    } else if (m_idealChannelCount > m_audioPortsOut.size()) {
+    } else if (m_idealChannelCount > numAudioOuts) {
 	// duplicate
-	for (size_t ch = m_audioPortsOut.size(); ch < m_idealChannelCount; ++ch) {
-	    size_t sch = (ch - m_audioPortsOut.size()) % m_audioPortsOut.size();
-	    for (size_t i = 0; i < m_blockSize; ++i) {
+	for (int ch = numAudioOuts; ch < m_idealChannelCount; ++ch) {
+	    int sch = (ch - numAudioOuts) % numAudioOuts;
+	    for (int i = 0; i < m_blockSize; ++i) {
 		m_outputBuffers[ch][i] = m_outputBuffers[sch][i];
 	    }
 	}
@@ -1144,7 +1151,7 @@
 }
 
 void
-DSSIPluginInstance::runGrouped(const Vamp::RealTime &blockTime)
+DSSIPluginInstance::runGrouped(const RealTime &blockTime)
 {
     // If something else in our group has just been called for this
     // block time (but we haven't) then we should just write out the
@@ -1216,13 +1223,11 @@
 	    *ev = instance->m_eventBuffer.peekOne();
 	    bool accept = true;
 
-	    Vamp::RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec);
+	    RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec);
 
-	    int frameOffset = 0;
+	    sv_frame_t frameOffset = 0;
 	    if (evTime > blockTime) {
-		frameOffset = (int)
-                    Vamp::RealTime::realTime2Frame(evTime - blockTime,
-                                                   (unsigned)m_sampleRate);
+		frameOffset = RealTime::realTime2Frame(evTime - blockTime, m_sampleRate);
 	    }
 
 #ifdef DEBUG_DSSI_PROCESS
@@ -1233,7 +1238,7 @@
 	    if (frameOffset >= int(m_blockSize)) break;
 	    if (frameOffset < 0) frameOffset = 0;
 
-	    ev->time.tick = frameOffset;
+	    ev->time.tick = snd_seq_tick_time_t(frameOffset);
 	    instance->m_eventBuffer.skip(1);
 
 	    if (ev->type == SND_SEQ_EVENT_CONTROLLER) {
--- a/plugin/DSSIPluginInstance.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/DSSIPluginInstance.h	Wed Mar 04 12:01:04 2015 +0000
@@ -54,7 +54,7 @@
     virtual int getPluginVersion() const;
     virtual std::string getCopyright() const;
 
-    virtual void run(const Vamp::RealTime &, size_t count = 0);
+    virtual void run(const RealTime &, int count = 0);
 
     virtual int getParameterCount() const;
     virtual void setParameterValue(int parameter, float value);
@@ -67,18 +67,18 @@
     virtual void setParameter(std::string, float);
 
     virtual std::string configure(std::string key, std::string value);
-    virtual void sendEvent(const Vamp::RealTime &eventTime,
+    virtual void sendEvent(const RealTime &eventTime,
 			   const void *event);
     virtual void clearEvents();
 
-    virtual size_t getBufferSize() const { return m_blockSize; }
-    virtual size_t getAudioInputCount() const { return m_audioPortsIn.size(); }
-    virtual size_t getAudioOutputCount() const { return m_idealChannelCount; }
+    virtual int getBufferSize() const { return m_blockSize; }
+    virtual int getAudioInputCount() const { return (int)m_audioPortsIn.size(); }
+    virtual int getAudioOutputCount() const { return m_idealChannelCount; }
     virtual sample_t **getAudioInputBuffers() { return m_inputBuffers; }
     virtual sample_t **getAudioOutputBuffers() { return m_outputBuffers; }
 
-    virtual size_t getControlOutputCount() const { return m_controlPortsOut.size(); }
-    virtual float getControlOutputValue(size_t n) const;
+    virtual int getControlOutputCount() const { return (int)m_controlPortsOut.size(); }
+    virtual float getControlOutputValue(int n) const;
 
     virtual ProgramList getPrograms() const;
     virtual std::string getCurrentProgram() const;
@@ -89,11 +89,11 @@
     virtual bool isBypassed() const { return m_bypassed; }
     virtual void setBypassed(bool bypassed) { m_bypassed = bypassed; }
 
-    virtual size_t getLatency();
+    virtual sv_frame_t getLatency();
 
     virtual void silence();
     virtual void discardEvents();
-    virtual void setIdealChannelCount(size_t channels); // may re-instantiate
+    virtual void setIdealChannelCount(int channels); // may re-instantiate
 
     virtual bool isInGroup() const { return m_grouped; }
     virtual void detachFromGroup();
@@ -110,13 +110,13 @@
 		       int client,
 		       QString identifier,
 		       int position,
-		       int sampleRate,
-		       size_t blockSize,
+		       sv_samplerate_t sampleRate,
+		       int blockSize,
 		       int idealChannelCount,
 		       const DSSI_Descriptor* descriptor);
     
     void init();
-    void instantiate(int sampleRate);
+    void instantiate(sv_samplerate_t sampleRate);
     void cleanup();
     void activate();
     void deactivate();
@@ -128,7 +128,7 @@
     void checkProgramCache() const;
 
     void initialiseGroupMembership();
-    void runGrouped(const Vamp::RealTime &);
+    void runGrouped(const RealTime &);
 
     // For use in DSSIPluginFactory (set in the DSSI_Host_Descriptor):
     static int requestMidiSend(LADSPA_Handle instance,
@@ -172,22 +172,22 @@
 
     RingBuffer<snd_seq_event_t> m_eventBuffer;
 
-    size_t                    m_blockSize;
+    int                       m_blockSize;
     sample_t                **m_inputBuffers;
     sample_t                **m_outputBuffers;
     bool                      m_ownBuffers;
-    size_t                    m_idealChannelCount;
-    size_t                    m_outputBufferCount;
-    size_t                    m_sampleRate;
+    int                       m_idealChannelCount;
+    int                       m_outputBufferCount;
+    sv_samplerate_t           m_sampleRate;
     float                    *m_latencyPort;
     bool                      m_run;
     
     bool                      m_bypassed;
     std::string               m_program;
     bool                      m_grouped;
-    Vamp::RealTime            m_lastRunTime;
+    RealTime                  m_lastRunTime;
 
-    Vamp::RealTime            m_lastEventSendTime;
+    RealTime                  m_lastEventSendTime;
     bool                      m_haveLastEventSendTime;
 
     QMutex                    m_processLock;
--- a/plugin/FeatureExtractionPluginFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -299,7 +299,7 @@
 
 Vamp::Plugin *
 FeatureExtractionPluginFactory::instantiatePlugin(QString identifier,
-						  float inputSampleRate)
+						  sv_samplerate_t inputSampleRate)
 {
     Profiler profiler("FeatureExtractionPluginFactory::instantiatePlugin");
 
@@ -357,7 +357,7 @@
         goto done;
     }
 
-    plugin = new Vamp::PluginHostAdapter(descriptor, inputSampleRate);
+    plugin = new Vamp::PluginHostAdapter(descriptor, float(inputSampleRate));
 
     if (plugin) {
         m_handleMap[plugin] = libraryHandle;
--- a/plugin/FeatureExtractionPluginFactory.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/FeatureExtractionPluginFactory.h	Wed Mar 04 12:01:04 2015 +0000
@@ -23,6 +23,7 @@
 #include <vamp-hostsdk/Plugin.h>
 
 #include "base/Debug.h"
+#include "base/BaseTypes.h"
 
 class FeatureExtractionPluginFactory
 {
@@ -42,7 +43,7 @@
     // We don't set blockSize or channels on this -- they're
     // negotiated and handled via initialize() on the plugin
     virtual Vamp::Plugin *instantiatePlugin(QString identifier,
-                                            float inputSampleRate);
+                                            sv_samplerate_t inputSampleRate);
 
     /**
      * Get category metadata about a plugin (without instantiating it).
--- a/plugin/LADSPAPluginFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/LADSPAPluginFactory.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -161,7 +161,7 @@
     }
     
     if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
-	minimum *= float(m_sampleRate);
+	minimum = float(minimum * m_sampleRate);
     }
 
     if (LADSPA_IS_HINT_LOGARITHMIC(d)) {
@@ -188,7 +188,7 @@
     }
     
     if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
-	maximum *= float(m_sampleRate);
+	maximum = float(maximum * m_sampleRate);
     }
 
     return maximum;
@@ -331,9 +331,9 @@
 LADSPAPluginFactory::instantiatePlugin(QString identifier,
 				       int instrument,
 				       int position,
-				       unsigned int sampleRate,
-				       unsigned int blockSize,
-				       unsigned int channels)
+				       sv_samplerate_t sampleRate,
+				       int blockSize,
+				       int channels)
 {
     Profiler profiler("LADSPAPluginFactory::instantiatePlugin");
 
--- a/plugin/LADSPAPluginFactory.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/LADSPAPluginFactory.h	Wed Mar 04 12:01:04 2015 +0000
@@ -47,9 +47,9 @@
     virtual RealTimePluginInstance *instantiatePlugin(QString identifier,
 						      int clientId,
 						      int position,
-						      unsigned int sampleRate,
-						      unsigned int blockSize,
-						      unsigned int channels);
+						      sv_samplerate_t sampleRate,
+						      int blockSize,
+						      int channels);
 
     virtual QString getPluginCategory(QString identifier);
 
--- a/plugin/LADSPAPluginInstance.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/LADSPAPluginInstance.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -37,8 +37,8 @@
 					   int clientId,
 					   QString identifier,
                                            int position,
-					   unsigned long sampleRate,
-					   size_t blockSize,
+					   sv_samplerate_t sampleRate,
+					   int blockSize,
 					   int idealChannelCount,
                                            const LADSPA_Descriptor* descriptor) :
     RealTimePluginInstance(factory, identifier),
@@ -289,19 +289,19 @@
     }
 }
 
-size_t
+sv_frame_t
 LADSPAPluginInstance::getLatency()
 {
     if (m_latencyPort) {
 	if (!m_run) {
-            for (size_t i = 0; i < getAudioInputCount(); ++i) {
-                for (size_t j = 0; j < m_blockSize; ++j) {
+            for (int i = 0; i < getAudioInputCount(); ++i) {
+                for (int j = 0; j < m_blockSize; ++j) {
                     m_inputBuffers[i][j] = 0.f;
                 }
             }
             run(Vamp::RealTime::zeroTime);
         }
-	if (*m_latencyPort > 0) return (size_t)*m_latencyPort;
+	if (*m_latencyPort > 0) return (sv_frame_t)*m_latencyPort;
     }
     return 0;
 }
@@ -316,7 +316,7 @@
 }
 
 void
-LADSPAPluginInstance::setIdealChannelCount(size_t channels)
+LADSPAPluginInstance::setIdealChannelCount(int channels)
 {
     if (m_audioPortsIn.size() != 1 || channels == m_instanceCount) {
 	silence();
@@ -378,7 +378,7 @@
 
 
 void
-LADSPAPluginInstance::instantiate(unsigned long sampleRate)
+LADSPAPluginInstance::instantiate(sv_samplerate_t sampleRate)
 {
     if (!m_descriptor) return;
 
@@ -394,9 +394,16 @@
 	return;
     }
 
-    for (size_t i = 0; i < m_instanceCount; ++i) {
+    unsigned long pluginRate = (unsigned long)(sampleRate);
+    if (sampleRate != sv_samplerate_t(pluginRate)) {
+        cerr << "LADSPAPluginInstance: WARNING: Non-integer sample rate "
+             << sampleRate << " presented, rounding to " << pluginRate
+             << endl;
+    }
+    
+    for (int i = 0; i < m_instanceCount; ++i) {
 	m_instanceHandles.push_back
-	    (m_descriptor->instantiate(m_descriptor, sampleRate));
+	    (m_descriptor->instantiate(m_descriptor, pluginRate));
     }
 }
 
@@ -491,7 +498,7 @@
 }
 
 float
-LADSPAPluginInstance::getControlOutputValue(size_t output) const
+LADSPAPluginInstance::getControlOutputValue(int output) const
 {
     if (!in_range_for(m_controlPortsOut, output)) return 0.0;
     return (*m_controlPortsOut[output].second);
@@ -531,7 +538,7 @@
 }
 
 void
-LADSPAPluginInstance::run(const Vamp::RealTime &, size_t count)
+LADSPAPluginInstance::run(const RealTime &, int count)
 {
     if (!m_descriptor || !m_descriptor->run) return;
 
--- a/plugin/LADSPAPluginInstance.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/LADSPAPluginInstance.h	Wed Mar 04 12:01:04 2015 +0000
@@ -51,7 +51,7 @@
     virtual int getPluginVersion() const;
     virtual std::string getCopyright() const;
 
-    virtual void run(const Vamp::RealTime &rt, size_t count = 0);
+    virtual void run(const RealTime &rt, int count = 0);
 
     virtual int getParameterCount() const;
     virtual void setParameterValue(int parameter, float value);
@@ -63,22 +63,22 @@
     virtual float getParameter(std::string) const;
     virtual void setParameter(std::string, float);
 
-    virtual size_t getBufferSize() const { return m_blockSize; }
-    virtual size_t getAudioInputCount() const { return m_instanceCount * m_audioPortsIn.size(); }
-    virtual size_t getAudioOutputCount() const { return m_instanceCount * m_audioPortsOut.size(); }
+    virtual int getBufferSize() const { return m_blockSize; }
+    virtual int getAudioInputCount() const { return int(m_instanceCount * m_audioPortsIn.size()); }
+    virtual int getAudioOutputCount() const { return int(m_instanceCount * m_audioPortsOut.size()); }
     virtual sample_t **getAudioInputBuffers() { return m_inputBuffers; }
     virtual sample_t **getAudioOutputBuffers() { return m_outputBuffers; }
 
-    virtual size_t getControlOutputCount() const { return m_controlPortsOut.size(); }
-    virtual float getControlOutputValue(size_t n) const;
+    virtual int getControlOutputCount() const { return int(m_controlPortsOut.size()); }
+    virtual float getControlOutputValue(int n) const;
 
     virtual bool isBypassed() const { return m_bypassed; }
     virtual void setBypassed(bool bypassed) { m_bypassed = bypassed; }
 
-    virtual size_t getLatency();
+    virtual sv_frame_t getLatency();
 
     virtual void silence();
-    virtual void setIdealChannelCount(size_t channels); // may re-instantiate
+    virtual void setIdealChannelCount(int channels); // may re-instantiate
 
     virtual std::string getType() const { return "LADSPA Real-Time Plugin"; }
 
@@ -92,13 +92,13 @@
 			 int client,
 			 QString identifier,
                          int position,
-			 unsigned long sampleRate,
-			 size_t blockSize,
+			 sv_samplerate_t sampleRate,
+			 int blockSize,
 			 int idealChannelCount,
                          const LADSPA_Descriptor* descriptor);
 
     void init(int idealChannelCount = 0);
-    void instantiate(unsigned long sampleRate);
+    void instantiate(sv_samplerate_t sampleRate);
     void cleanup();
     void activate();
     void deactivate();
@@ -110,7 +110,7 @@
     int                        m_client;
     int                        m_position;
     std::vector<LADSPA_Handle> m_instanceHandles;
-    size_t                     m_instanceCount;
+    int                        m_instanceCount;
     const LADSPA_Descriptor   *m_descriptor;
 
     std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsIn;
@@ -119,11 +119,11 @@
     std::vector<int>          m_audioPortsIn;
     std::vector<int>          m_audioPortsOut;
 
-    size_t                    m_blockSize;
+    int                       m_blockSize;
     sample_t                **m_inputBuffers;
     sample_t                **m_outputBuffers;
     bool                      m_ownBuffers;
-    size_t                    m_sampleRate;
+    sv_samplerate_t           m_sampleRate;
     float                    *m_latencyPort;
     bool                      m_run;
     
--- a/plugin/RealTimePluginFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/RealTimePluginFactory.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -30,7 +30,7 @@
 
 #include <iostream>
 
-int RealTimePluginFactory::m_sampleRate = 48000;
+sv_samplerate_t RealTimePluginFactory::m_sampleRate = 48000;
 
 static LADSPAPluginFactory *_ladspaInstance = 0;
 static LADSPAPluginFactory *_dssiInstance = 0;
--- a/plugin/RealTimePluginFactory.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/RealTimePluginFactory.h	Wed Mar 04 12:01:04 2015 +0000
@@ -26,6 +26,7 @@
 #include <vector>
 
 #include "base/Debug.h"
+#include "base/BaseTypes.h"
 
 class RealTimePluginInstance;
 
@@ -55,7 +56,7 @@
     static std::vector<QString> getAllPluginIdentifiers();
     static void enumerateAllPlugins(std::vector<QString> &);
 
-    static void setSampleRate(int sampleRate) { m_sampleRate = sampleRate; }
+    static void setSampleRate(sv_samplerate_t sampleRate) { m_sampleRate = sampleRate; }
 
     /**
      * Look up the plugin path and find the plugins in it.  Called 
@@ -87,9 +88,9 @@
     virtual RealTimePluginInstance *instantiatePlugin(QString identifier,
 						      int clientId,
 						      int position,
-						      unsigned int sampleRate,
-						      unsigned int blockSize,
-						      unsigned int channels) = 0;
+						      sv_samplerate_t sampleRate,
+						      int blockSize,
+						      int channels) = 0;
 
     /**
      * Get category metadata about a plugin (without instantiating it).
@@ -103,7 +104,7 @@
     virtual void releasePlugin(RealTimePluginInstance *, QString identifier) = 0;
     friend class RealTimePluginInstance;
 
-    static int m_sampleRate;
+    static sv_samplerate_t m_sampleRate;
 };
 
 #endif
--- a/plugin/RealTimePluginInstance.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/plugin/RealTimePluginInstance.h	Wed Mar 04 12:01:04 2015 +0000
@@ -22,7 +22,9 @@
 #define _REALTIME_PLUGIN_INSTANCE_H_
 
 #include <vamp-hostsdk/PluginBase.h>
-#include <vamp-hostsdk/RealTime.h>
+
+#include "base/RealTime.h"
+#include "base/AudioPlaySource.h"
 
 #include <QString>
 #include <QStringList>
@@ -30,8 +32,6 @@
 #include <string>
 #include <map>
 
-#include "base/AudioPlaySource.h"
-
 class RealTimePluginFactory;
 	
 /**
@@ -91,20 +91,20 @@
      * waiting.  Other plugins can ignore it.  The count, if zero,
      * defaults to our fixed buffer size.
      */
-    virtual void run(const Vamp::RealTime &blockStartTime,
-                     size_t count = 0) = 0;
+    virtual void run(const RealTime &blockStartTime,
+                     int count = 0) = 0;
     
-    virtual size_t getBufferSize() const = 0;
+    virtual int getBufferSize() const = 0;
 
-    virtual size_t getAudioInputCount() const = 0;
-    virtual size_t getAudioOutputCount() const = 0;
+    virtual int getAudioInputCount() const = 0;
+    virtual int getAudioOutputCount() const = 0;
 
     virtual sample_t **getAudioInputBuffers() = 0;
     virtual sample_t **getAudioOutputBuffers() = 0;
 
     // Control inputs are known as parameters here
-    virtual size_t getControlOutputCount() const = 0;
-    virtual float getControlOutputValue(size_t n) const = 0;
+    virtual int getControlOutputCount() const = 0;
+    virtual float getControlOutputValue(int n) const = 0;
 
 //     virtual QStringList getPrograms() const { return QStringList(); }
 //     virtual QString getCurrentProgram() const { return QString(); }
@@ -120,7 +120,7 @@
 
     virtual std::string configure(std::string /* key */, std::string /* value */) { return std::string(); }
 
-    virtual void sendEvent(const Vamp::RealTime & /* eventTime */,
+    virtual void sendEvent(const RealTime & /* eventTime */,
 			   const void * /* event */) { }
     virtual void clearEvents() { }
 
@@ -128,11 +128,11 @@
     virtual void setBypassed(bool value) = 0;
 
     // This should be called after setup, but while not actually playing.
-    virtual size_t getLatency() = 0;
+    virtual sv_frame_t getLatency() = 0;
 
     virtual void silence() = 0;
     virtual void discardEvents() { }
-    virtual void setIdealChannelCount(size_t channels) = 0; // must also silence(); may also re-instantiate
+    virtual void setIdealChannelCount(int channels) = 0; // must also silence(); may also re-instantiate
 
     void setFactory(RealTimePluginFactory *f) { m_factory = f; } // ew
 
--- a/rdf/RDFExporter.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/rdf/RDFExporter.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -78,7 +78,7 @@
     Vamp::Plugin::FeatureList features;
     features.push_back(Vamp::Plugin::Feature());
     Vamp::Plugin::Feature &f = features[0];
-    int sr = m_model->getSampleRate();
+    sv_samplerate_t sr = m_model->getSampleRate();
 
     {
         RegionModel *m = dynamic_cast<RegionModel *>(m_model);
@@ -88,8 +88,8 @@
             const RegionModel::PointList &pl(m->getPoints());
             for (RegionModel::PointList::const_iterator i = pl.begin(); 
                  i != pl.end(); ++i) {
-                f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr);
-                f.duration = Vamp::RealTime::frame2RealTime(i->duration, sr);
+                f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
+                f.duration = RealTime::frame2RealTime(i->duration, sr).toVampRealTime();
                 f.values.clear();
                 f.values.push_back(i->value);
                 f.label = i->label.toStdString();
@@ -106,8 +106,8 @@
             const NoteModel::PointList &pl(m->getPoints());
             for (NoteModel::PointList::const_iterator i = pl.begin(); 
                  i != pl.end(); ++i) {
-                f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr);
-                f.duration = Vamp::RealTime::frame2RealTime(i->duration, sr);
+                f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
+                f.duration = RealTime::frame2RealTime(i->duration, sr).toVampRealTime();
                 f.values.clear();
                 f.values.push_back(i->value);
                 f.values.push_back(i->level);
@@ -125,7 +125,7 @@
             const SparseOneDimensionalModel::PointList &pl(m->getPoints());
             for (SparseOneDimensionalModel::PointList::const_iterator i = pl.begin(); 
                  i != pl.end(); ++i) {
-                f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr);
+                f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
                 f.values.clear();
                 f.label = i->label.toStdString();
                 m_fw->write(trackId, transform, output, features, summaryType);
@@ -141,7 +141,7 @@
             const SparseTimeValueModel::PointList &pl(m->getPoints());
             for (SparseTimeValueModel::PointList::const_iterator i = pl.begin(); 
                  i != pl.end(); ++i) {
-                f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr);
+                f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
                 f.values.clear();
                 f.values.push_back(i->value);
                 f.label = i->label.toStdString();
@@ -159,7 +159,7 @@
             m_fw->setFixedEventTypeURI("af:Text");
             for (TextModel::PointList::const_iterator i = pl.begin(); 
                  i != pl.end(); ++i) {
-                f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr);
+                f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
                 f.values.clear();
                 f.values.push_back(i->height);
                 f.label = i->label.toStdString();
--- a/rdf/RDFImporter.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/rdf/RDFImporter.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -50,10 +50,10 @@
 class RDFImporterImpl
 {
 public:
-    RDFImporterImpl(QString url, int sampleRate);
+    RDFImporterImpl(QString url, sv_samplerate_t sampleRate);
     virtual ~RDFImporterImpl();
 
-    void setSampleRate(int sampleRate) { m_sampleRate = sampleRate; }
+    void setSampleRate(sv_samplerate_t sampleRate) { m_sampleRate = sampleRate; }
     
     bool isOK();
     QString getErrorString() const;
@@ -67,7 +67,7 @@
     QString m_uristring;
     QString m_errorString;
     std::map<QString, Model *> m_audioModelMap;
-    int m_sampleRate;
+    sv_samplerate_t m_sampleRate;
 
     std::map<Model *, std::map<QString, float> > m_labelValueMap;
 
@@ -78,7 +78,7 @@
     void getDenseModelTitle(Model *, QString, QString);
 
     void getDenseFeatureProperties(QString featureUri,
-                                   int &sampleRate, int &windowLength,
+                                   sv_samplerate_t &sampleRate, int &windowLength,
                                    int &hopSize, int &width, int &height);
 
     void fillModel(Model *, sv_frame_t, sv_frame_t,
@@ -91,7 +91,7 @@
     return "*.rdf *.n3 *.ttl";
 }
 
-RDFImporter::RDFImporter(QString url, int sampleRate) :
+RDFImporter::RDFImporter(QString url, sv_samplerate_t sampleRate) :
     m_d(new RDFImporterImpl(url, sampleRate)) 
 {
 }
@@ -102,7 +102,7 @@
 }
 
 void
-RDFImporter::setSampleRate(int sampleRate)
+RDFImporter::setSampleRate(sv_samplerate_t sampleRate)
 {
     m_d->setSampleRate(sampleRate);
 }
@@ -125,7 +125,7 @@
     return m_d->getDataModels(r);
 }
 
-RDFImporterImpl::RDFImporterImpl(QString uri, int sampleRate) :
+RDFImporterImpl::RDFImporterImpl(QString uri, sv_samplerate_t sampleRate) :
     m_store(new BasicStore),
     m_uristring(uri),
     m_sampleRate(sampleRate)
@@ -310,7 +310,7 @@
         
         if (type == "" || value == "") continue;
 
-        int sampleRate = 0;
+        sv_samplerate_t sampleRate = 0;
         int windowLength = 0;
         int hopSize = 0;
         int width = 0;
@@ -417,7 +417,7 @@
 
 void
 RDFImporterImpl::getDenseFeatureProperties(QString featureUri,
-                                           int &sampleRate, int &windowLength,
+                                           sv_samplerate_t &sampleRate, int &windowLength,
                                            int &hopSize, int &width, int &height)
 {
     Node dim = m_store->complete
@@ -468,7 +468,7 @@
     PropertyObject po(m_store, "tl:", map);
 
     if (po.hasProperty("sampleRate")) {
-        sampleRate = po.getProperty("sampleRate").toInt();
+        sampleRate = po.getProperty("sampleRate").toDouble();
     }
     if (po.hasProperty("hopSize")) {
         hopSize = po.getProperty("hopSize").toInt();
--- a/rdf/RDFImporter.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/rdf/RDFImporter.h	Wed Mar 04 12:01:04 2015 +0000
@@ -21,6 +21,8 @@
 
 #include <vector>
 
+#include "base/BaseTypes.h"
+
 class Model;
 class RDFImporterImpl;
 class ProgressReporter;
@@ -37,10 +39,10 @@
      */
     static QString getKnownExtensions();
 
-    RDFImporter(QString url, int sampleRate = 0);
+    RDFImporter(QString url, sv_samplerate_t sampleRate = 0);
     virtual ~RDFImporter();
 
-    void setSampleRate(int sampleRate);
+    void setSampleRate(sv_samplerate_t sampleRate);
 
     bool isOK();
     QString getErrorString() const;
--- a/transform/FeatureExtractionModelTransformer.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/transform/FeatureExtractionModelTransformer.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -100,7 +100,7 @@
         return false;
     }
 
-    m_plugin = factory->instantiatePlugin(pluginId, float(input->getSampleRate()));
+    m_plugin = factory->instantiatePlugin(pluginId, input->getSampleRate());
     if (!m_plugin) {
         m_message = tr("Failed to instantiate plugin \"%1\"").arg(pluginId);
 	return false;
@@ -249,7 +249,7 @@
         haveExtents = true;
     }
 
-    int modelRate = input->getSampleRate();
+    sv_samplerate_t modelRate = input->getSampleRate();
     int modelResolution = 1;
 
     if (m_descriptors[n]->sampleType != 
@@ -264,8 +264,7 @@
 
     case Vamp::Plugin::OutputDescriptor::VariableSampleRate:
 	if (m_descriptors[n]->sampleRate != 0.0) {
-	    modelResolution = int(round(float(modelRate) /
-                                        m_descriptors[n]->sampleRate));
+	    modelResolution = int(round(modelRate / m_descriptors[n]->sampleRate));
 	}
 	break;
 
@@ -282,8 +281,7 @@
         if (m_descriptors[n]->sampleRate > input->getSampleRate()) {
             modelResolution = 1;
         } else {
-            modelResolution = int(round(float(modelRate) /
-                                        m_descriptors[n]->sampleRate));
+            modelResolution = int(round(modelRate / m_descriptors[n]->sampleRate));
         }
 	break;
     }
@@ -574,7 +572,7 @@
     }
     if (m_abandoned) return;
 
-    int sampleRate = input->getSampleRate();
+    sv_samplerate_t sampleRate = input->getSampleRate();
 
     int channelCount = input->getChannelCount();
     if ((int)m_plugin->getMaxChannelCount() < channelCount) {
@@ -617,16 +615,16 @@
         }
     }
 
-    long startFrame = m_input.getModel()->getStartFrame();
-    long   endFrame = m_input.getModel()->getEndFrame();
+    sv_frame_t startFrame = m_input.getModel()->getStartFrame();
+    sv_frame_t endFrame = m_input.getModel()->getEndFrame();
 
     RealTime contextStartRT = primaryTransform.getStartTime();
     RealTime contextDurationRT = primaryTransform.getDuration();
 
-    long contextStart =
+    sv_frame_t contextStart =
         RealTime::realTime2Frame(contextStartRT, sampleRate);
 
-    long contextDuration =
+    sv_frame_t contextDuration =
         RealTime::realTime2Frame(contextDurationRT, sampleRate);
 
     if (contextStart == 0 || contextStart < startFrame) {
@@ -705,7 +703,7 @@
         if (m_abandoned) break;
 
 	Vamp::Plugin::FeatureSet features = m_plugin->process
-	    (buffers, Vamp::RealTime::frame2RealTime(blockFrame, sampleRate));
+	    (buffers, RealTime::frame2RealTime(blockFrame, sampleRate).toVampRealTime());
 
         if (m_abandoned) break;
 
@@ -821,7 +819,7 @@
                                               sv_frame_t blockFrame,
                                               const Vamp::Plugin::Feature &feature)
 {
-    int inputRate = m_input.getModel()->getSampleRate();
+    sv_samplerate_t inputRate = m_input.getModel()->getSampleRate();
 
 //    cerr << "FeatureExtractionModelTransformer::addFeature: blockFrame = "
 //              << blockFrame << ", hasTimestamp = " << feature.hasTimestamp
@@ -841,7 +839,7 @@
 		<< endl;
 	    return;
 	} else {
-	    frame = Vamp::RealTime::realTime2Frame(feature.timestamp, inputRate);
+	    frame = RealTime::realTime2Frame(feature.timestamp, inputRate);
 	}
 
     } else if (m_descriptors[n]->sampleType ==
@@ -927,7 +925,7 @@
 
         sv_frame_t duration = 1;
         if (feature.hasDuration) {
-            duration = Vamp::RealTime::realTime2Frame(feature.duration, inputRate);
+            duration = RealTime::realTime2Frame(feature.duration, inputRate);
         } else {
             if (in_range_for(feature.values, index)) {
                 duration = lrintf(feature.values[index++]);
--- a/transform/ModelTransformerFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/transform/ModelTransformerFactory.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -107,7 +107,7 @@
 
         RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(id);
 
-        int sampleRate = inputModel->getSampleRate();
+        sv_samplerate_t sampleRate = inputModel->getSampleRate();
         int blockSize = 1024;
         int channels = 1;
         if (source) {
--- a/transform/RealTimeEffectModelTransformer.cpp	Tue Mar 03 17:09:19 2015 +0000
+++ b/transform/RealTimeEffectModelTransformer.cpp	Wed Mar 04 12:01:04 2015 +0000
@@ -137,7 +137,7 @@
 
     if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) return;
 
-    int sampleRate = input->getSampleRate();
+    sv_samplerate_t sampleRate = input->getSampleRate();
     int channelCount = input->getChannelCount();
     if (!wwfm && m_input.getChannel() != -1) channelCount = 1;
 
@@ -235,7 +235,7 @@
         }
 */
 
-        m_plugin->run(Vamp::RealTime::frame2RealTime(blockFrame, sampleRate));
+        m_plugin->run(RealTime::frame2RealTime(blockFrame, sampleRate));
 
         if (stvm) {