changeset 1039:b14064bd1f97 cxx11

This code now compiles. Main problem: sample rate types
author Chris Cannam
date Tue, 03 Mar 2015 17:09:19 +0000
parents cc27f35aa75c
children a1cd5abcb38b
files base/Scavenger.h data/model/FlexiNoteModel.h plugin/DSSIPluginInstance.cpp plugin/LADSPAPluginFactory.cpp plugin/LADSPAPluginInstance.cpp plugin/LADSPAPluginInstance.h plugin/plugins/SamplePlayer.cpp rdf/RDFFeatureWriter.cpp rdf/RDFImporter.cpp system/System.cpp transform/CSVFeatureWriter.cpp transform/FeatureExtractionModelTransformer.cpp transform/FeatureExtractionModelTransformer.h transform/ModelTransformerFactory.cpp transform/RealTimeEffectModelTransformer.cpp transform/TransformFactory.cpp
diffstat 16 files changed, 157 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/base/Scavenger.h	Tue Mar 03 15:18:24 2015 +0000
+++ b/base/Scavenger.h	Tue Mar 03 17:09:19 2015 +0000
@@ -61,17 +61,17 @@
     void scavenge(bool clearNow = false);
 
 protected:
-    typedef std::pair<T *, int> ObjectTimePair;
+    typedef std::pair<T *, time_t> ObjectTimePair;
     typedef std::vector<ObjectTimePair> ObjectTimeList;
     ObjectTimeList m_objects;
-    int m_sec;
+    time_t m_sec;
 
     typedef std::list<T *> ObjectList;
     ObjectList m_excess;
-    int m_lastExcess;
+    time_t m_lastExcess;
     QMutex m_excessMutex;
     void pushExcess(T *);
-    void clearExcess(int);
+    void clearExcess(time_t);
 
     unsigned int m_claimed;
     unsigned int m_scavenged;
@@ -129,7 +129,7 @@
 
     struct timeval tv;
     (void)gettimeofday(&tv, 0);
-    int sec = tv.tv_sec;
+    time_t sec = tv.tv_sec;
 
     for (size_t i = 0; i < m_objects.size(); ++i) {
 	ObjectTimePair &pair = m_objects[i];
@@ -156,7 +156,7 @@
     
     struct timeval tv;
     (void)gettimeofday(&tv, 0);
-    int sec = tv.tv_sec;
+    time_t sec = tv.tv_sec;
 
     for (size_t i = 0; i < m_objects.size(); ++i) {
 	ObjectTimePair &pair = m_objects[i];
@@ -188,7 +188,7 @@
 
 template <typename T>
 void
-Scavenger<T>::clearExcess(int sec)
+Scavenger<T>::clearExcess(time_t sec)
 {
     m_excessMutex.lock();
     for (typename ObjectList::iterator i = m_excess.begin();
--- a/data/model/FlexiNoteModel.h	Tue Mar 03 15:18:24 2015 +0000
+++ b/data/model/FlexiNoteModel.h	Tue Mar 03 17:09:19 2015 +0000
@@ -42,15 +42,15 @@
 struct FlexiNote
 {
 public:
-    FlexiNote(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { }
-    FlexiNote(long _frame, float _value, int _duration, float _level, QString _label) :
+    FlexiNote(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { }
+    FlexiNote(sv_frame_t _frame, float _value, sv_frame_t _duration, float _level, QString _label) :
 	frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { }
 
     int getDimensions() const { return 3; }
 
-    long frame;
+    sv_frame_t frame;
     float value;
-    int duration;
+    sv_frame_t duration;
     float level;
     QString label;
 
@@ -208,7 +208,7 @@
         command->deletePoint(point);
 
         switch (column) {
-        case 4: point.level = value.toDouble(); break;
+        case 4: point.level = float(value.toDouble()); break;
         case 5: point.label = value.toString(); break;
         }
 
@@ -231,20 +231,20 @@
         return getNotesWithin(getStartFrame(), getEndFrame());
     }
 
-    NoteList getNotesWithin(int startFrame, int endFrame) const 
+    NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const 
     {    
     	PointList points = getPoints(startFrame, endFrame);
         NoteList notes;
         for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) {
-    	    int duration = pli->duration;
+    	    sv_frame_t duration = pli->duration;
             if (duration == 0 || duration == 1) {
                 duration = getSampleRate() / 20;
             }
-            int pitch = lrintf(pli->value);
+            int pitch = int(lrintf(pli->value));
 
             int velocity = 100;
             if (pli->level > 0.f && pli->level <= 1.f) {
-                velocity = lrintf(pli->level * 127);
+                velocity = int(lrintf(pli->level * 127));
             }
 
             NoteData note(pli->frame, duration, pitch, velocity);
--- a/plugin/DSSIPluginInstance.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/plugin/DSSIPluginInstance.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -1062,7 +1062,7 @@
 	    }
 	}
 
-	ev->time.tick = frameOffset;
+	ev->time.tick = (snd_seq_tick_time_t)frameOffset;
 	m_eventBuffer.skip(1);
 
 	if (ev->type == SND_SEQ_EVENT_CONTROLLER) {
@@ -1184,8 +1184,8 @@
 #endif
 
     size_t index = 0;
-    int *counts = (int *)
-	alloca(m_groupLocalEventBufferCount * sizeof(int));
+    unsigned long *counts = (unsigned long *)
+	alloca(m_groupLocalEventBufferCount * sizeof(unsigned long));
     LADSPA_Handle *instances = (LADSPA_Handle *)
 	alloca(m_groupLocalEventBufferCount * sizeof(LADSPA_Handle));
 
@@ -1220,7 +1220,9 @@
 
 	    int frameOffset = 0;
 	    if (evTime > blockTime) {
-		frameOffset = Vamp::RealTime::realTime2Frame(evTime - blockTime, m_sampleRate);
+		frameOffset = (int)
+                    Vamp::RealTime::realTime2Frame(evTime - blockTime,
+                                                   (unsigned)m_sampleRate);
 	    }
 
 #ifdef DEBUG_DSSI_PROCESS
@@ -1270,7 +1272,7 @@
 void
 DSSIPluginInstance::midiSend(LADSPA_Handle /* instance */,
 			     snd_seq_event_t * /* events */,
-			     unsignd long /* eventCount */)
+			     unsigned long /* eventCount */)
 {
     // This is likely to be called from an RT context
 
--- a/plugin/LADSPAPluginFactory.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/plugin/LADSPAPluginFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -104,7 +104,7 @@
 
 	list.push_back(QString("%1").arg(descriptor->PortCount));
 
-	for (unsigned long p = 0; p < descriptor->PortCount; ++p) {
+	for (int p = 0; p < (int)descriptor->PortCount; ++p) {
 
 	    int type = 0;
 	    if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) {
@@ -150,18 +150,18 @@
     LADSPA_PortRangeHintDescriptor d =
 	descriptor->PortRangeHints[port].HintDescriptor;
 
-    float minimum = 0.0;
+    float minimum = 0.f;
 		
     if (LADSPA_IS_HINT_BOUNDED_BELOW(d)) {
 	float lb = descriptor->PortRangeHints[port].LowerBound;
 	minimum = lb;
     } else if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) {
 	float ub = descriptor->PortRangeHints[port].UpperBound;
-	minimum = std::min(0.0, ub - 1.0);
+	minimum = std::min(0.f, ub - 1.f);
     }
     
     if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
-	minimum *= m_sampleRate;
+	minimum *= float(m_sampleRate);
     }
 
     if (LADSPA_IS_HINT_LOGARITHMIC(d)) {
@@ -177,18 +177,18 @@
     LADSPA_PortRangeHintDescriptor d =
 	descriptor->PortRangeHints[port].HintDescriptor;
 
-    float maximum = 1.0;
+    float maximum = 1.f;
     
     if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) {
 	float ub = descriptor->PortRangeHints[port].UpperBound;
 	maximum = ub;
     } else {
 	float lb = descriptor->PortRangeHints[port].LowerBound;
-	maximum = lb + 1.0;
+	maximum = lb + 1.f;
     }
     
     if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
-	maximum *= m_sampleRate;
+	maximum *= float(m_sampleRate);
     }
 
     return maximum;
@@ -240,25 +240,25 @@
     } else if (LADSPA_IS_HINT_DEFAULT_LOW(d)) {
 	
 	if (logarithmic) {
-	    deft = powf(10, logmin * 0.75 + logmax * 0.25);
+	    deft = powf(10, logmin * 0.75f + logmax * 0.25f);
 	} else {
-	    deft = minimum * 0.75 + maximum * 0.25;
+	    deft = minimum * 0.75f + maximum * 0.25f;
 	}
 	
     } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(d)) {
 	
 	if (logarithmic) {
-	    deft = powf(10, logmin * 0.5 + logmax * 0.5);
+	    deft = powf(10, logmin * 0.5f + logmax * 0.5f);
 	} else {
-	    deft = minimum * 0.5 + maximum * 0.5;
+	    deft = minimum * 0.5f + maximum * 0.5f;
 	}
 	
     } else if (LADSPA_IS_HINT_DEFAULT_HIGH(d)) {
 	
 	if (logarithmic) {
-	    deft = powf(10, logmin * 0.25 + logmax * 0.75);
+	    deft = powf(10, logmin * 0.25f + logmax * 0.75f);
 	} else {
-	    deft = minimum * 0.25 + maximum * 0.75;
+	    deft = minimum * 0.25f + maximum * 0.75f;
 	}
 	
     } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(d)) {
@@ -280,7 +280,7 @@
     } else if (LADSPA_IS_HINT_DEFAULT_440(d)) {
 	
 //	deft = 440.0;
-        deft = Preferences::getInstance()->getTuningFrequency();
+        deft = (float)Preferences::getInstance()->getTuningFrequency();
 	
     } else {
 	
@@ -303,8 +303,8 @@
 {
     int displayHint = getPortDisplayHint(descriptor, port);
     if (displayHint & PortHint::Toggled) {
-        return lrintf(getPortMaximum(descriptor, port)) - 
-            lrintf(getPortMinimum(descriptor, port));
+        return float(lrintf(getPortMaximum(descriptor, port)) - 
+                     lrintf(getPortMinimum(descriptor, port)));
     }
     if (displayHint & PortHint::Integer) {
         return 1.0;
@@ -754,7 +754,7 @@
 
 	unsigned int controlPortNumber = 1;
 	
-	for (unsigned long i = 0; i < descriptor->PortCount; i++) {
+	for (int i = 0; i < (int)descriptor->PortCount; i++) {
 	    
 	    if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) {
 		
@@ -774,7 +774,7 @@
 	}
 #endif // HAVE_LRDF
 
-	for (unsigned long i = 0; i < descriptor->PortCount; i++) {
+	for (int i = 0; i < (int)descriptor->PortCount; i++) {
 	    if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) {
                 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) {
                     ++rtd->parameterCount;
--- a/plugin/LADSPAPluginInstance.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/plugin/LADSPAPluginInstance.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -156,12 +156,12 @@
             if (defaults) {
                 if (defaults->count > 0) {
                     std::map<int, std::string> values;
-                    size_t v = 0;
+                    int v = 0;
                     for (size_t i = 0; i < defaults->count; ++i) {
-                        v = size_t(lrintf(fabsf(defaults->items[i].value)));
+                        v = int(lrintf(fabsf(defaults->items[i].value)));
                         values[v] = defaults->items[i].label;
                     }
-                    for (size_t i = 0; i <= v; ++i) {
+                    for (int i = 0; i <= v; ++i) {
                         pd.valueNames.push_back(values[i]);
                     }
                     haveLabels = true;
@@ -227,7 +227,7 @@
 
     // Discover ports numbers and identities
     //
-    for (unsigned long i = 0; i < m_descriptor->PortCount; ++i) {
+    for (int i = 0; i < (int)m_descriptor->PortCount; ++i) {
 
         if (LADSPA_IS_PORT_AUDIO(m_descriptor->PortDescriptors[i])) {
 
@@ -464,16 +464,16 @@
     }
 }
 
-unsigned int
+int
 LADSPAPluginInstance::getParameterCount() const
 {
-    return m_controlPortsIn.size();
+    return (int)m_controlPortsIn.size();
 }
 
 void
-LADSPAPluginInstance::setParameterValue(unsigned int parameter, float value)
+LADSPAPluginInstance::setParameterValue(int parameter, float value)
 {
-    if (parameter >= m_controlPortsIn.size()) return;
+    if (!in_range_for(m_controlPortsIn, parameter)) return;
 
     unsigned int portNumber = m_controlPortsIn[parameter].first;
 
@@ -493,21 +493,21 @@
 float
 LADSPAPluginInstance::getControlOutputValue(size_t output) const
 {
-    if (output > m_controlPortsOut.size()) return 0.0;
+    if (!in_range_for(m_controlPortsOut, output)) return 0.0;
     return (*m_controlPortsOut[output].second);
 }
 
 float
-LADSPAPluginInstance::getParameterValue(unsigned int parameter) const
+LADSPAPluginInstance::getParameterValue(int parameter) const
 {
-    if (parameter >= m_controlPortsIn.size()) return 0.0;
+    if (!in_range_for(m_controlPortsIn, parameter)) return 0.0;
     return (*m_controlPortsIn[parameter].second);
 }
 
 float
-LADSPAPluginInstance::getParameterDefault(unsigned int parameter) const
+LADSPAPluginInstance::getParameterDefault(int parameter) const
 {
-    if (parameter >= m_controlPortsIn.size()) return 0.0;
+    if (!in_range_for(m_controlPortsIn, parameter)) return 0.0;
 
     LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory);
     if (f) {
@@ -518,9 +518,9 @@
 }
 
 int
-LADSPAPluginInstance::getParameterDisplayHint(unsigned int parameter) const
+LADSPAPluginInstance::getParameterDisplayHint(int parameter) const
 {
-    if (parameter >= m_controlPortsIn.size()) return 0.0;
+    if (!in_range_for(m_controlPortsIn, parameter)) return 0.0;
 
     LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory);
     if (f) {
--- a/plugin/LADSPAPluginInstance.h	Tue Mar 03 15:18:24 2015 +0000
+++ b/plugin/LADSPAPluginInstance.h	Tue Mar 03 17:09:19 2015 +0000
@@ -27,6 +27,7 @@
 
 #include "api/ladspa.h"
 #include "RealTimePluginInstance.h"
+#include "base/BaseTypes.h"
 
 // LADSPA plugin instance.  LADSPA is a variable block size API, but
 // for one reason and another it's more convenient to use a fixed
@@ -52,11 +53,11 @@
 
     virtual void run(const Vamp::RealTime &rt, size_t count = 0);
 
-    virtual unsigned int getParameterCount() const;
-    virtual void setParameterValue(unsigned int parameter, float value);
-    virtual float getParameterValue(unsigned int parameter) const;
-    virtual float getParameterDefault(unsigned int parameter) const;
-    virtual int getParameterDisplayHint(unsigned int parameter) const;
+    virtual int getParameterCount() const;
+    virtual void setParameterValue(int parameter, float value);
+    virtual float getParameterValue(int parameter) const;
+    virtual float getParameterDefault(int parameter) const;
+    virtual int getParameterDisplayHint(int parameter) const;
     
     virtual ParameterList getParameterDescriptors() const;
     virtual float getParameter(std::string) const;
@@ -112,8 +113,8 @@
     size_t                     m_instanceCount;
     const LADSPA_Descriptor   *m_descriptor;
 
-    std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsIn;
-    std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsOut;
+    std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsIn;
+    std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsOut;
 
     std::vector<int>          m_audioPortsIn;
     std::vector<int>          m_audioPortsOut;
--- a/plugin/plugins/SamplePlayer.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/plugin/plugins/SamplePlayer.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -69,7 +69,7 @@
     { LADSPA_HINT_DEFAULT_MINIMUM | LADSPA_HINT_INTEGER |
       LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 0, 1 },
     { LADSPA_HINT_DEFAULT_MINIMUM | LADSPA_HINT_LOGARITHMIC |
-      LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 0.001, 2.0 }
+      LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE, 0.001f, 2.0f }
 };
 
 const LADSPA_Properties
@@ -156,7 +156,7 @@
 	return 0;
     }
 
-    SamplePlayer *player = new SamplePlayer(rate);
+    SamplePlayer *player = new SamplePlayer(int(rate));
 	// std::cerr << "Instantiated sample player " << std::endl;
 
     if (hostDescriptor->request_non_rt_thread(player, workThreadCallback)) {
@@ -282,7 +282,7 @@
 			    unsigned long program)
 {
     SamplePlayer *player = (SamplePlayer *)handle;
-    player->m_pendingProgramChange = program;
+    player->m_pendingProgramChange = (int)program;
 }
 
 int
@@ -415,7 +415,7 @@
     if (info.samplerate != m_sampleRate) {
 	
 	double ratio = (double)m_sampleRate / (double)info.samplerate;
-	size_t target = (size_t)(info.frames * ratio);
+	size_t target = (size_t)(double(info.frames) * ratio);
 	SRC_DATA data;
 
 	tmpResamples = (float *)malloc(target * info.channels * sizeof(float));
@@ -572,7 +572,7 @@
             ratio *= *m_concertA / 440.f;
         }
 	if (m_basePitch && n != *m_basePitch) {
-	    ratio *= powf(1.059463094f, n - *m_basePitch);
+	    ratio *= powf(1.059463094f, float(n) - *m_basePitch);
 	}
     }
 
@@ -585,8 +585,8 @@
 	 ++i, ++s) {
 
 	float         lgain = gain;
-	float         rs = s * ratio;
-	unsigned long rsi = lrintf(floor(rs));
+	float         rs = float(s) * ratio;
+	unsigned long rsi = lrintf(floorf(rs));
 
 	if (rsi >= m_sampleCount) {
 #ifdef DEBUG_SAMPLE_PLAYER
@@ -604,7 +604,7 @@
 
 	    unsigned long releaseFrames = 200;
 	    if (m_release) {
-		releaseFrames = long(*m_release * m_sampleRate + 0.0001);
+		releaseFrames = long(*m_release * float(m_sampleRate) + 0.0001f);
 	    }
 
 	    if (dist > releaseFrames) {
--- a/rdf/RDFFeatureWriter.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/rdf/RDFFeatureWriter.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -751,8 +751,10 @@
         RealTime startrt = transform.getStartTime();
         RealTime durationrt = transform.getDuration();
 
-        int start = RealTime::realTime2Frame(startrt, sampleRate) / stepSize;
-        int duration = RealTime::realTime2Frame(durationrt, sampleRate) / stepSize;
+        sv_frame_t start = RealTime::realTime2Frame
+            (startrt, int(lrintf(sampleRate))) / stepSize;
+        sv_frame_t duration = RealTime::realTime2Frame
+            (durationrt, int(lrintf(sampleRate))) / stepSize;
 
         if (start != 0) {
             stream << "\n        tl:start \"" << start << "\"^^xsd:int ;";
--- a/rdf/RDFImporter.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/rdf/RDFImporter.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -81,7 +81,8 @@
                                    int &sampleRate, int &windowLength,
                                    int &hopSize, int &width, int &height);
 
-    void fillModel(Model *, long, long, bool, std::vector<float> &, QString);
+    void fillModel(Model *, sv_frame_t, sv_frame_t,
+                   bool, std::vector<float> &, QString);
 };
 
 QString
@@ -686,8 +687,8 @@
                 model = modelMap[timeline][type][dimensions][haveDuration];
 
                 if (model) {
-                    long ftime = RealTime::realTime2Frame(time, m_sampleRate);
-                    long fduration = RealTime::realTime2Frame(duration, m_sampleRate);
+                    sv_frame_t ftime = RealTime::realTime2Frame(time, m_sampleRate);
+                    sv_frame_t fduration = RealTime::realTime2Frame(duration, m_sampleRate);
                     fillModel(model, ftime, fduration, haveDuration, values, label);
                 }
             }
@@ -697,8 +698,8 @@
 
 void
 RDFImporterImpl::fillModel(Model *model,
-                           long ftime,
-                           long fduration,
+                           sv_frame_t ftime,
+                           sv_frame_t fduration,
                            bool haveDuration,
                            std::vector<float> &values,
                            QString label)
@@ -757,7 +758,8 @@
                     }
                 }
             }
-            NoteModel::Point point(ftime, value, duration, level, label);
+            NoteModel::Point point(ftime, value, sv_frame_t(lrintf(duration)),
+                                   level, label);
             nm->addPoint(point);
         }
         return;
@@ -789,7 +791,8 @@
                     duration = values[1];
                 }
             }
-            RegionModel::Point point(ftime, value, duration, label);
+            RegionModel::Point point(ftime, value,
+                                     sv_frame_t(lrintf(duration)), label);
             rm->addPoint(point);
         }
         return;
--- a/system/System.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/system/System.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -323,5 +323,5 @@
 float modf(float x, float y) { return x - (y * floorf(x / y)); }
 
 double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; }
-float princargf(float a) { return modf(a + M_PI, -2 * M_PI) + M_PI; }
+float princargf(float a) { return float(princarg(a)); }
 
--- a/transform/CSVFeatureWriter.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/transform/CSVFeatureWriter.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -133,7 +133,7 @@
 
     QTextStream &stream = *sptr;
 
-    int n = features.size();
+    int n = (int)features.size();
 
     if (n == 0) return;
 
@@ -223,7 +223,7 @@
 
     if (m_sampleTiming) {
 
-        float rate = transform.getSampleRate();
+        int rate = int(lrintf(transform.getSampleRate()));
 
         stream << Vamp::RealTime::realTime2Frame(f.timestamp, rate);
 
--- a/transform/FeatureExtractionModelTransformer.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/transform/FeatureExtractionModelTransformer.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -100,7 +100,7 @@
         return false;
     }
 
-    m_plugin = factory->instantiatePlugin(pluginId, input->getSampleRate());
+    m_plugin = factory->instantiatePlugin(pluginId, float(input->getSampleRate()));
     if (!m_plugin) {
         m_message = tr("Failed to instantiate plugin \"%1\"").arg(pluginId);
 	return false;
@@ -235,7 +235,7 @@
     bool haveBinCount = m_descriptors[n]->hasFixedBinCount;
 
     if (haveBinCount) {
-	binCount = m_descriptors[n]->binCount;
+	binCount = (int)m_descriptors[n]->binCount;
     }
 
     m_needAdditionalModels[n] = false;
@@ -264,7 +264,8 @@
 
     case Vamp::Plugin::OutputDescriptor::VariableSampleRate:
 	if (m_descriptors[n]->sampleRate != 0.0) {
-	    modelResolution = int(modelRate / m_descriptors[n]->sampleRate + 0.001);
+	    modelResolution = int(round(float(modelRate) /
+                                        m_descriptors[n]->sampleRate));
 	}
 	break;
 
@@ -281,8 +282,8 @@
         if (m_descriptors[n]->sampleRate > input->getSampleRate()) {
             modelResolution = 1;
         } else {
-            modelResolution = int(round(input->getSampleRate() /
-                                           m_descriptors[n]->sampleRate));
+            modelResolution = int(round(float(modelRate) /
+                                        m_descriptors[n]->sampleRate));
         }
 	break;
     }
@@ -639,7 +640,7 @@
         contextDuration = endFrame - contextStart;
     }
 
-    long blockFrame = contextStart;
+    sv_frame_t blockFrame = contextStart;
 
     long prevCompletion = 0;
 
@@ -670,15 +671,15 @@
 //		  << blockFrame << ", endFrame " << endFrame << ", blockSize "
 //                  << blockSize << endl;
 
-	long completion =
-	    (((blockFrame - contextStart) / stepSize) * 99) /
-	    (contextDuration / stepSize + 1);
+	int completion = int
+	    ((((blockFrame - contextStart) / stepSize) * 99) /
+             (contextDuration / stepSize + 1));
 
 	// channelCount is either m_input.getModel()->channelCount or 1
 
         if (frequencyDomain) {
             for (int ch = 0; ch < channelCount; ++ch) {
-                int column = (blockFrame - startFrame) / stepSize;
+                int column = int((blockFrame - startFrame) / stepSize);
                 if (fftModels[ch]->getValuesAt(column, reals, imaginaries)) {
                     for (int i = 0; i <= blockSize/2; ++i) {
                         buffers[ch][i*2] = reals[i];
@@ -756,14 +757,15 @@
 
 void
 FeatureExtractionModelTransformer::getFrames(int channelCount,
-                                             long startFrame, long size,
+                                             sv_frame_t startFrame,
+                                             sv_frame_t size,
                                              float **buffers)
 {
-    long offset = 0;
+    sv_frame_t offset = 0;
 
     if (startFrame < 0) {
         for (int c = 0; c < channelCount; ++c) {
-            for (int i = 0; i < size && startFrame + i < 0; ++i) {
+            for (sv_frame_t i = 0; i < size && startFrame + i < 0; ++i) {
                 buffers[c][i] = 0.0f;
             }
         }
@@ -776,7 +778,7 @@
     DenseTimeValueModel *input = getConformingInput();
     if (!input) return;
     
-    long got = 0;
+    sv_frame_t got = 0;
 
     if (channelCount == 1) {
 
@@ -786,7 +788,7 @@
         if (m_input.getChannel() == -1 && input->getChannelCount() > 1) {
             // use mean instead of sum, as plugin input
             float cc = float(input->getChannelCount());
-            for (long i = 0; i < size; ++i) {
+            for (sv_frame_t i = 0; i < size; ++i) {
                 buffers[0][i + offset] /= cc;
             }
         }
@@ -816,7 +818,7 @@
 
 void
 FeatureExtractionModelTransformer::addFeature(int n,
-                                              int blockFrame,
+                                              sv_frame_t blockFrame,
                                               const Vamp::Plugin::Feature &feature)
 {
     int inputRate = m_input.getModel()->getSampleRate();
@@ -827,7 +829,7 @@
 //              << feature.hasDuration << ", duration = " << feature.duration
 //              << endl;
 
-    int frame = blockFrame;
+    sv_frame_t frame = blockFrame;
 
     if (m_descriptors[n]->sampleType ==
 	Vamp::Plugin::OutputDescriptor::VariableSampleRate) {
@@ -849,7 +851,7 @@
             ++m_fixedRateFeatureNos[n];
         } else {
             RealTime ts(feature.timestamp.sec, feature.timestamp.nsec);
-            m_fixedRateFeatureNos[n] =
+            m_fixedRateFeatureNos[n] = (int)
                 lrint(ts.toDouble() * m_descriptors[n]->sampleRate);
         }
 
@@ -857,8 +859,9 @@
 //             << ", m_descriptor->sampleRate = " << m_descriptor->sampleRate
 //             << ", inputRate = " << inputRate
 //             << " giving frame = ";
-        frame = lrintf((m_fixedRateFeatureNos[n] / m_descriptors[n]->sampleRate)
-                       * int(inputRate));
+        frame = lrint((double(m_fixedRateFeatureNos[n])
+                       / m_descriptors[n]->sampleRate)
+                      * inputRate);
     }
 
     if (frame < 0) {
@@ -922,12 +925,12 @@
             value = feature.values[index++];
         }
 
-        float duration = 1;
+        sv_frame_t duration = 1;
         if (feature.hasDuration) {
             duration = Vamp::RealTime::realTime2Frame(feature.duration, inputRate);
         } else {
-            if ((int)feature.values.size() > index) {
-                duration = feature.values[index++];
+            if (in_range_for(feature.values, index)) {
+                duration = lrintf(feature.values[index++]);
             }
         }
 
@@ -942,10 +945,11 @@
 
             FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>(n);
             if (!model) return;
-            model->addPoint(FlexiNoteModel::Point(frame, value, // value is pitch
-                                             lrintf(duration),
-                                             velocity / 127.f,
-                                             feature.label.c_str()));
+            model->addPoint(FlexiNoteModel::Point(frame,
+                                                  value, // value is pitch
+                                                  duration,
+                                                  velocity / 127.f,
+                                                  feature.label.c_str()));
 			// GF: end -- added for flexi note model
         } else  if (isOutput<NoteModel>(n)) {
 
@@ -959,7 +963,7 @@
             NoteModel *model = getConformingOutput<NoteModel>(n);
             if (!model) return;
             model->addPoint(NoteModel::Point(frame, value, // value is pitch
-                                             lrintf(duration),
+                                             duration,
                                              velocity / 127.f,
                                              feature.label.c_str()));
         } else {
@@ -978,14 +982,16 @@
                         label = QString("[%1] %2").arg(i+1).arg(label);
                     }
 
-                    model->addPoint(RegionModel::Point(frame, value,
-                                                       lrintf(duration),
+                    model->addPoint(RegionModel::Point(frame,
+                                                       value,
+                                                       duration,
                                                        label));
                 }
             } else {
             
-                model->addPoint(RegionModel::Point(frame, value,
-                                                   lrintf(duration),
+                model->addPoint(RegionModel::Point(frame,
+                                                   value,
+                                                   duration,
                                                    feature.label.c_str()));
             }
         }
@@ -1005,7 +1011,7 @@
         if (!feature.hasTimestamp && m_fixedRateFeatureNos[n] >= 0) {
             model->setColumn(m_fixedRateFeatureNos[n], values);
         } else {
-            model->setColumn(frame / model->getResolution(), values);
+            model->setColumn(int(frame / model->getResolution()), values);
         }
 
     } else {
--- a/transform/FeatureExtractionModelTransformer.h	Tue Mar 03 15:18:24 2015 +0000
+++ b/transform/FeatureExtractionModelTransformer.h	Tue Mar 03 17:09:19 2015 +0000
@@ -66,12 +66,12 @@
     SparseTimeValueModel *getAdditionalModel(int transformNo, int binNo);
 
     void addFeature(int n,
-                    int blockFrame,
+                    sv_frame_t blockFrame,
 		    const Vamp::Plugin::Feature &feature);
 
     void setCompletion(int, int);
 
-    void getFrames(int channelCount, long startFrame, long size,
+    void getFrames(int channelCount, sv_frame_t startFrame, sv_frame_t size,
                    float **buffer);
 
     // just casts
--- a/transform/ModelTransformerFactory.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/transform/ModelTransformerFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -99,7 +99,7 @@
 
         Vamp::Plugin *vp =
             FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin
-            (id, inputModel->getSampleRate());
+            (id, float(inputModel->getSampleRate()));
 
         plugin = vp;
 
--- a/transform/RealTimeEffectModelTransformer.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/transform/RealTimeEffectModelTransformer.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -82,7 +82,7 @@
 
     if (m_outputNo == -1) {
 
-        int outputChannels = m_plugin->getAudioOutputCount();
+        int outputChannels = (int)m_plugin->getAudioOutputCount();
         if (outputChannels > input->getChannelCount()) {
             outputChannels = input->getChannelCount();
         }
@@ -141,22 +141,22 @@
     int channelCount = input->getChannelCount();
     if (!wwfm && m_input.getChannel() != -1) channelCount = 1;
 
-    long blockSize = m_plugin->getBufferSize();
+    sv_frame_t blockSize = m_plugin->getBufferSize();
 
     float **inbufs = m_plugin->getAudioInputBuffers();
 
-    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();
 
     Transform transform = m_transforms[0];
     
     RealTime contextStartRT = transform.getStartTime();
     RealTime contextDurationRT = transform.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) {
@@ -174,20 +174,20 @@
         wwfm->setStartFrame(contextStart);
     }
 
-    long blockFrame = contextStart;
+    sv_frame_t blockFrame = contextStart;
 
-    long prevCompletion = 0;
+    int prevCompletion = 0;
 
-    long latency = m_plugin->getLatency();
+    sv_frame_t latency = m_plugin->getLatency();
 
     while (blockFrame < contextStart + contextDuration + latency &&
            !m_abandoned) {
 
-	long completion =
-	    (((blockFrame - contextStart) / blockSize) * 99) /
-	    (1 + ((contextDuration) / blockSize));
+	int completion = int
+	    ((((blockFrame - contextStart) / blockSize) * 99) /
+             (1 + ((contextDuration) / blockSize)));
 
-	long got = 0;
+	sv_frame_t got = 0;
 
 	if (channelCount == 1) {
             if (inbufs && inbufs[0]) {
@@ -197,7 +197,7 @@
                     inbufs[0][got++] = 0.0;
                 }          
                 for (int ch = 1; ch < (int)m_plugin->getAudioInputCount(); ++ch) {
-                    for (long i = 0; i < blockSize; ++i) {
+                    for (sv_frame_t i = 0; i < blockSize; ++i) {
                         inbufs[ch][i] = inbufs[0][i];
                     }
                 }
@@ -214,7 +214,7 @@
                     ++got;
                 }
                 for (int ch = channelCount; ch < (int)m_plugin->getAudioInputCount(); ++ch) {
-                    for (long i = 0; i < blockSize; ++i) {
+                    for (sv_frame_t i = 0; i < blockSize; ++i) {
                         inbufs[ch][i] = inbufs[ch % channelCount][i];
                     }
                 }
@@ -241,7 +241,7 @@
 
             float value = m_plugin->getControlOutputValue(m_outputNo);
 
-            long pointFrame = blockFrame;
+            sv_frame_t pointFrame = blockFrame;
             if (pointFrame > latency) pointFrame -= latency;
             else pointFrame = 0;
 
@@ -255,13 +255,13 @@
             if (outbufs) {
 
                 if (blockFrame >= latency) {
-                    long writeSize = std::min
+                    sv_frame_t writeSize = std::min
                         (blockSize,
                          contextStart + contextDuration + latency - blockFrame);
                     wwfm->addSamples(outbufs, writeSize);
                 } else if (blockFrame + blockSize >= latency) {
-                    long offset = latency - blockFrame;
-                    long count = blockSize - offset;
+                    sv_frame_t offset = latency - blockFrame;
+                    sv_frame_t count = blockSize - offset;
                     float **tmp = new float *[channelCount];
                     for (int c = 0; c < channelCount; ++c) {
                         tmp[c] = outbufs[c] + offset;
--- a/transform/TransformFactory.cpp	Tue Mar 03 15:18:24 2015 +0000
+++ b/transform/TransformFactory.cpp	Tue Mar 03 17:09:19 2015 +0000
@@ -754,7 +754,7 @@
 {
     Transform t;
     t.setIdentifier(id);
-    if (rate != 0) t.setSampleRate(rate);
+    if (rate != 0) t.setSampleRate(float(rate));
 
     Vamp::PluginBase *plugin = instantiateDefaultPluginFor(id, rate);
 
@@ -772,7 +772,7 @@
 TransformFactory::instantiatePluginFor(const Transform &transform)
 {
     Vamp::PluginBase *plugin = instantiateDefaultPluginFor
-        (transform.getIdentifier(), transform.getSampleRate());
+        (transform.getIdentifier(), int(lrintf(transform.getSampleRate())));
 
     if (plugin) {
         setPluginParameters(transform, plugin);
@@ -797,7 +797,7 @@
             FeatureExtractionPluginFactory::instanceFor(pluginId);
 
         if (factory) {
-            plugin = factory->instantiatePlugin(pluginId, rate);
+            plugin = factory->instantiatePlugin(pluginId, float(rate));
         }
 
     } else {
@@ -913,8 +913,8 @@
             instantiatePlugin(id, 44100);
         if (!plugin) return false;
 
-        min = plugin->getMinChannelCount();
-        max = plugin->getMaxChannelCount();
+        min = (int)plugin->getMinChannelCount();
+        max = (int)plugin->getMaxChannelCount();
         delete plugin;
 
         return true;
@@ -1040,10 +1040,10 @@
     } else {
         Vamp::Plugin::InputDomain domain = vp->getInputDomain();
         if (!transform.getStepSize()) {
-            transform.setStepSize(vp->getPreferredStepSize());
+            transform.setStepSize((int)vp->getPreferredStepSize());
         }
         if (!transform.getBlockSize()) {
-            transform.setBlockSize(vp->getPreferredBlockSize());
+            transform.setBlockSize((int)vp->getPreferredBlockSize());
         }
         if (!transform.getBlockSize()) {
             transform.setBlockSize(1024);