changeset 908:166e3fc1e962 tony_integration

Merge from default branch
author Chris Cannam
date Wed, 07 May 2014 15:18:45 +0100
parents aa2257796931 (current diff) a589d2201a0c (diff)
children c48b07b34cb3
files data/fft/FFTDataServer.cpp data/sv.pch
diffstat 5 files changed, 37 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp	Wed May 07 15:14:17 2014 +0100
+++ b/data/fft/FFTDataServer.cpp	Wed May 07 15:18:45 2014 +0100
@@ -868,7 +868,7 @@
     // and previous cache readers)
     int deleteCandidate = c - 2;
     if (deleteCandidate < 0) deleteCandidate = c + 2;
-    if (deleteCandidate >= m_caches.size()) {
+    if (deleteCandidate >= (int)m_caches.size()) {
         return true;
     }
 
--- a/data/fileio/CSVFileReader.cpp	Wed May 07 15:14:17 2014 +0100
+++ b/data/fileio/CSVFileReader.cpp	Wed May 07 15:18:45 2014 +0100
@@ -22,6 +22,7 @@
 #include "model/SparseTimeValueModel.h"
 #include "model/EditableDenseThreeDimensionalModel.h"
 #include "model/RegionModel.h"
+#include "model/NoteModel.h"
 #include "DataFileReaderFactory.h"
 
 #include <QFile>
@@ -85,7 +86,7 @@
                                 size_t windowSize) const
 {
     QRegExp nonNumericRx("[^0-9eE.,+-]");
-    unsigned int warnLimit = 10;
+    int warnLimit = 10;
 
     CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits();
 
@@ -156,6 +157,7 @@
     SparseOneDimensionalModel *model1 = 0;
     SparseTimeValueModel *model2 = 0;
     RegionModel *model2a = 0;
+    NoteModel *model2b = 0;
     EditableDenseThreeDimensionalModel *model3 = 0;
     Model *model = 0;
 
@@ -173,6 +175,7 @@
 
     bool haveAnyValue = false;
     bool haveEndTime = false;
+    bool pitchLooksLikeMIDI = true;
 
     size_t startFrame = 0; // for calculation of dense model resolution
     bool firstEverValue = true;
@@ -202,7 +205,7 @@
         QString chunk = in.readLine();
         QStringList lines = chunk.split('\r', QString::SkipEmptyParts);
         
-        for (size_t li = 0; li < lines.size(); ++li) {
+        for (int li = 0; li < lines.size(); ++li) {
 
             QString line = lines[li];
 
@@ -228,6 +231,11 @@
                     model = model2a;
                     break;
 		
+                case CSVFormat::TwoDimensionalModelWithDurationAndPitch:
+                    model2b = new NoteModel(sampleRate, windowSize, false);
+                    model = model2b;
+                    break;
+		
                 case CSVFormat::ThreeDimensionalModel:
                     model3 = new EditableDenseThreeDimensionalModel
                         (sampleRate,
@@ -240,6 +248,7 @@
             }
 
             float value = 0.f;
+            float pitch = 0.f;
             QString label = "";
 
             duration = 0.f;
@@ -274,6 +283,13 @@
                     haveAnyValue = true;
                     break;
 
+                case CSVFormat::ColumnPitch:
+                    pitch = s.toFloat();
+                    if (pitch < 0.f || pitch > 127.f) {
+                        pitchLooksLikeMIDI = false;
+                    }
+                    break;
+
                 case CSVFormat::ColumnLabel:
                     label = s;
                     ++labelCountMap[label];
@@ -302,6 +318,12 @@
                 RegionModel::Point point(frameNo, value, duration, label);
                 model2a->addPoint(point);
 
+            } else if (modelType == CSVFormat::TwoDimensionalModelWithDurationAndPitch) {
+
+                float level = ((value >= 0.f && value <= 1.f) ? value : 1.f);
+                NoteModel::Point point(frameNo, pitch, duration, level, label);
+                model2b->addPoint(point);
+
             } else if (modelType == CSVFormat::ThreeDimensionalModel) {
 
                 DenseThreeDimensionalModel::Column values;
@@ -400,6 +422,14 @@
         }
     }
                 
+    if (model2b) {
+        if (pitchLooksLikeMIDI) {
+            model2b->setScaleUnits("MIDI Pitch");
+        } else {
+            model2b->setScaleUnits("Hz");
+        }
+    }
+
     if (modelType == CSVFormat::ThreeDimensionalModel) {
 	model3->setMinimumLevel(min);
 	model3->setMaximumLevel(max);
--- a/data/fileio/CSVFormat.cpp	Wed May 07 15:14:17 2014 +0100
+++ b/data/fileio/CSVFormat.cpp	Wed May 07 15:18:45 2014 +0100
@@ -66,7 +66,7 @@
         QString chunk = in.readLine();
         QStringList lines = chunk.split('\r', QString::SkipEmptyParts);
 
-        for (size_t li = 0; li < lines.size(); ++li) {
+        for (int li = 0; li < lines.size(); ++li) {
 
             QString line = lines[li];
             if (line.startsWith("#") || line == "") continue;
@@ -86,7 +86,7 @@
 CSVFormat::guessSeparator(QString line)
 {
     char candidates[] = { ',', '\t', ' ', '|', '/', ':' };
-    for (int i = 0; i < sizeof(candidates)/sizeof(candidates[0]); ++i) {
+    for (int i = 0; i < int(sizeof(candidates)/sizeof(candidates[0])); ++i) {
         if (StringBits::split(line, candidates[i], m_allowQuoting).size() >= 2) {
             m_separator = candidates[i];
             return;
--- a/data/fileio/CSVFormat.h	Wed May 07 15:14:17 2014 +0100
+++ b/data/fileio/CSVFormat.h	Wed May 07 15:18:45 2014 +0100
@@ -26,6 +26,7 @@
 	OneDimensionalModel,
 	TwoDimensionalModel,
         TwoDimensionalModelWithDuration,
+        TwoDimensionalModelWithDurationAndPitch,
 	ThreeDimensionalModel
     };
     
@@ -46,6 +47,7 @@
         ColumnEndTime,
         ColumnDuration,
         ColumnValue,
+        ColumnPitch,
         ColumnLabel
     };
 
--- a/data/sv.pch	Wed May 07 15:14:17 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-../sv.pch
\ No newline at end of file