changeset 331:e39307a8d22d

Use sv samplerate/frame types, fixing compiler warnings
author Chris Cannam
date Tue, 12 Jun 2018 10:14:22 +0100
parents 4819abbd24bb
children b7825e35b5b7
files runner/FeatureExtractionManager.cpp runner/FeatureExtractionManager.h runner/LabFeatureWriter.cpp runner/MIDIFeatureWriter.cpp runner/MIDIFeatureWriter.h
diffstat 5 files changed, 34 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/runner/FeatureExtractionManager.cpp	Tue Jun 12 10:11:29 2018 +0100
+++ b/runner/FeatureExtractionManager.cpp	Tue Jun 12 10:14:22 2018 +0100
@@ -94,7 +94,7 @@
     m_channels = channels;
 }
 
-void FeatureExtractionManager::setDefaultSampleRate(int sampleRate)
+void FeatureExtractionManager::setDefaultSampleRate(sv_samplerate_t sampleRate)
 {
     m_defaultSampleRate = sampleRate;
 }
@@ -281,13 +281,13 @@
             if (transform.getStepSize() != 0) {
                 pba->setPluginStepSize(transform.getStepSize());
             } else {
-                transform.setStepSize(pluginStepSize);
+                transform.setStepSize(int(pluginStepSize));
             }
 
             if (transform.getBlockSize() != 0) {
                 pba->setPluginBlockSize(transform.getBlockSize());
             } else {
-                transform.setBlockSize(pluginBlockSize);
+                transform.setBlockSize(int(pluginBlockSize));
             }
 
             plugin = new PluginChannelAdapter(plugin);
@@ -311,8 +311,8 @@
             size_t actualStepSize = 0;
             size_t actualBlockSize = 0;
             pba->getActualStepAndBlockSizes(actualStepSize, actualBlockSize);
-            transform.setStepSize(actualStepSize);
-            transform.setBlockSize(actualBlockSize);
+            transform.setStepSize(int(actualStepSize));
+            transform.setBlockSize(int(actualBlockSize));
 
             Plugin::OutputList outputs = plugin->getOutputDescriptors();
             for (int i = 0; i < (int)outputs.size(); ++i) {
@@ -351,10 +351,10 @@
                         pba->getActualStepAndBlockSizes(actualStepSize,
                                                         actualBlockSize);
                         if (transform.getStepSize() == 0) {
-                            transform.setStepSize(actualStepSize);
+                            transform.setStepSize(int(actualStepSize));
                         }
                         if (transform.getBlockSize() == 0) {
-                            transform.setBlockSize(actualBlockSize);
+                            transform.setBlockSize(int(actualBlockSize));
                         }
                     }
                 }
@@ -754,12 +754,12 @@
     };
     LifespanMgr lifemgr(reader, m_channels, data);
 
-    size_t frameCount = reader->getFrameCount();
+    sv_frame_t frameCount = reader->getFrameCount();
     
     SVDEBUG << "FeatureExtractionManager: file has " << frameCount << " frames" << endl;
 
-    int earliestStartFrame = 0;
-    int latestEndFrame = frameCount;
+    sv_frame_t earliestStartFrame = 0;
+    sv_frame_t latestEndFrame = frameCount;
     bool haveExtents = false;
 
     foreach (Plugin *plugin, m_orderedPlugins) {
@@ -774,9 +774,9 @@
 
             const Transform &transform = ti->first;
 
-            int startFrame = RealTime::realTime2Frame
+            sv_frame_t startFrame = RealTime::realTime2Frame
                 (transform.getStartTime(), m_sampleRate);
-            int duration = RealTime::realTime2Frame
+            sv_frame_t duration = RealTime::realTime2Frame
                 (transform.getDuration(), m_sampleRate);
             if (duration == 0) {
                 duration = frameCount - startFrame;
@@ -823,8 +823,8 @@
         }
     }
     
-    int startFrame = earliestStartFrame;
-    int endFrame = latestEndFrame;
+    sv_frame_t startFrame = earliestStartFrame;
+    sv_frame_t endFrame = latestEndFrame;
     
     foreach (Plugin *plugin, m_orderedPlugins) {
 
@@ -849,7 +849,7 @@
     ProgressPrinter extractionProgress("Extracting and writing features...");
     int progress = 0;
 
-    for (int i = startFrame; i < endFrame; i += m_blockSize) {
+    for (sv_frame_t i = startFrame; i < endFrame; i += m_blockSize) {
         
         //!!! inefficient, although much of the inefficiency may be
         // susceptible to compiler optimisation
@@ -880,7 +880,7 @@
                 }
             }
             for (int j = 0; j < m_blockSize; ++j) {
-                data[0][j] /= rc;
+                data[0][j] /= float(rc);
             }
         } else {                
             for (int c = 0; c < m_channels; ++c) {
@@ -896,8 +896,7 @@
             }
         }                
 
-        Vamp::RealTime timestamp = Vamp::RealTime::frame2RealTime
-            (i, m_sampleRate);
+        RealTime timestamp = RealTime::frame2RealTime(i, m_sampleRate);
         
         foreach (Plugin *plugin, m_orderedPlugins) {
 
@@ -910,7 +909,7 @@
             bool inRange = false;
             for (TransformWriterMap::const_iterator ti = pi->second.begin();
                  ti != pi->second.end(); ++ti) {
-                int startFrame = RealTime::realTime2Frame
+                sv_frame_t startFrame = RealTime::realTime2Frame
                     (ti->first.getStartTime(), m_sampleRate);
                 if (i >= startFrame || i + m_blockSize > startFrame) {
                     inRange = true;
@@ -921,7 +920,8 @@
                 continue;
             }
 
-            Plugin::FeatureSet featureSet = plugin->process(data, timestamp);
+            Plugin::FeatureSet featureSet =
+                plugin->process(data, timestamp.toVampRealTime());
 
             if (!m_summariesOnly) {
                 writeFeatures(audioSource, plugin, featureSet);
@@ -929,7 +929,8 @@
         }
 
         int pp = progress;
-        progress = int(((i - startFrame) * 100.0) / (endFrame - startFrame) + 0.1);
+        progress = int((double(i - startFrame) * 100.0) /
+                       double(endFrame - startFrame) + 0.1);
         if (progress > pp && m_verbose) extractionProgress.setProgress(progress);
     }
 
@@ -939,7 +940,6 @@
         
     foreach (Plugin *plugin, m_orderedPlugins) {
 
-        PluginMap::iterator pi = m_plugins.find(plugin);
         Plugin::FeatureSet featureSet = plugin->getRemainingFeatures();
 
         if (!m_summariesOnly) {
--- a/runner/FeatureExtractionManager.h	Tue Jun 12 10:11:29 2018 +0100
+++ b/runner/FeatureExtractionManager.h	Tue Jun 12 10:14:22 2018 +0100
@@ -42,7 +42,7 @@
     virtual ~FeatureExtractionManager();
 
     void setChannels(int channels);
-    void setDefaultSampleRate(int sampleRate);
+    void setDefaultSampleRate(sv_samplerate_t sampleRate);
     void setNormalise(bool normalise);
 
     bool setSummaryTypes(const set<string> &summaryTypes,
@@ -136,8 +136,8 @@
     void finish();
 
     int m_blockSize;
-    int m_defaultSampleRate;
-    int m_sampleRate;
+    sv_samplerate_t m_defaultSampleRate;
+    sv_samplerate_t m_sampleRate;
     int m_channels;
     bool m_normalise;
 
--- a/runner/LabFeatureWriter.cpp	Tue Jun 12 10:11:29 2018 +0100
+++ b/runner/LabFeatureWriter.cpp	Tue Jun 12 10:14:22 2018 +0100
@@ -108,7 +108,7 @@
 
     QTextStream &stream = *sptr;
 
-    int n = features.size();
+    int n = int(features.size());
 
     if (n == 0) return;
 
--- a/runner/MIDIFeatureWriter.cpp	Tue Jun 12 10:11:29 2018 +0100
+++ b/runner/MIDIFeatureWriter.cpp	Tue Jun 12 10:14:22 2018 +0100
@@ -76,7 +76,7 @@
 	throw FailedToOpenOutputStream(trackId, transformId);
     }
 
-    int sampleRate = transform.getSampleRate();
+    sv_samplerate_t sampleRate = transform.getSampleRate();
 
     if (m_rates.find(filename) == m_rates.end()) {
         m_rates[filename] = sampleRate;
@@ -104,12 +104,13 @@
 
         const Plugin::Feature &feature(features[i]);
 
-        Vamp::RealTime timestamp = feature.timestamp;
-        int frame = Vamp::RealTime::realTime2Frame(timestamp, sampleRate);
+        RealTime timestamp(feature.timestamp);
+        sv_frame_t frame = RealTime::realTime2Frame(timestamp, sampleRate);
 
-        int duration = 1;
+        sv_frame_t duration = 1;
         if (feature.hasDuration) {
-            duration = Vamp::RealTime::realTime2Frame(feature.duration, sampleRate);
+            RealTime rduration(feature.duration);
+            duration = RealTime::realTime2Frame(rduration, sampleRate);
         }
 
 #ifdef DEBUG_MIDI_FEATURE_WRITER
@@ -152,7 +153,7 @@
 
 	QString filename = i->first;
 	NoteList notes = i->second;
-	float rate = m_rates[filename];
+	sv_samplerate_t rate = m_rates[filename];
 
 	TrivialNoteExportable exportable(notes);
 
--- a/runner/MIDIFeatureWriter.h	Tue Jun 12 10:11:29 2018 +0100
+++ b/runner/MIDIFeatureWriter.h	Tue Jun 12 10:14:22 2018 +0100
@@ -66,7 +66,7 @@
     typedef map<QString, set<Transform> > FileTransformMap;
     FileTransformMap m_fileTransforms;
 
-    typedef map<QString, float> SampleRateMap; // NoteData uses sample timing
+    typedef map<QString, sv_samplerate_t> SampleRateMap; // NoteData uses sample timing
     SampleRateMap m_rates;
 
     typedef map<Transform, int> ChannelMap;