changeset 1108:16574eea3229 simple-fft-model

Merge
author Chris Cannam
date Tue, 30 Jun 2015 10:26:23 +0100
parents 393134235fa0 (diff) bead35921256 (current diff)
children a65328f0c450 457a1a619c5f
files
diffstat 6 files changed, 38 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/base/StorageAdviser.cpp	Tue Jun 30 10:25:32 2015 +0100
+++ b/base/StorageAdviser.cpp	Tue Jun 30 10:26:23 2015 +0100
@@ -22,7 +22,7 @@
 
 #include <iostream>
 
-#define DEBUG_STORAGE_ADVISER 1
+//#define DEBUG_STORAGE_ADVISER 1
 
 size_t StorageAdviser::m_discPlanned = 0;
 size_t StorageAdviser::m_memoryPlanned = 0;
@@ -91,7 +91,7 @@
     ssize_t maxmb = ssize_t(maximumSize / 1024 + 1);
 
     if (memoryFree == -1) memoryStatus = Unknown;
-    else if (memoryFree < memoryTotal / 3) memoryStatus = Insufficient;
+    else if (memoryFree < memoryTotal / 3 && memoryFree < 512) memoryStatus = Insufficient;
     else if (minmb > (memoryFree * 3) / 4) memoryStatus = Insufficient;
     else if (maxmb > (memoryFree * 3) / 4) memoryStatus = Marginal;
     else if (minmb > (memoryFree / 3)) memoryStatus = Marginal;
--- a/data/fileio/AudioFileSizeEstimator.cpp	Tue Jun 30 10:25:32 2015 +0100
+++ b/data/fileio/AudioFileSizeEstimator.cpp	Tue Jun 30 10:26:23 2015 +0100
@@ -18,6 +18,8 @@
 
 #include <QFile>
 
+//#define DEBUG_AUDIO_FILE_SIZE_ESTIMATOR 1
+
 sv_frame_t
 AudioFileSizeEstimator::estimate(FileSource source,
 				 sv_samplerate_t targetRate)
@@ -61,7 +63,9 @@
 	{
 	    QFile f(source.getLocalFilename());
 	    if (f.open(QFile::ReadOnly)) {
+#ifdef DEBUG_AUDIO_FILE_SIZE_ESTIMATOR
 		cerr << "opened file, size is "  << f.size() << endl;
+#endif
 		sz = f.size();
 		f.close();
 	    }
@@ -90,11 +94,14 @@
 	    estimate = sv_frame_t(double(sz) * 1.2 * rateRatio);
 	}
 
+#ifdef DEBUG_AUDIO_FILE_SIZE_ESTIMATOR
 	cerr << "AudioFileSizeEstimator: for extension " << extension << ", estimate = " << estimate << endl;
-    
+#endif
     }
 
+#ifdef DEBUG_AUDIO_FILE_SIZE_ESTIMATOR
     cerr << "estimate = " << estimate << endl;
+#endif
     
     return estimate;
 }
--- a/data/fileio/CodedAudioFileReader.cpp	Tue Jun 30 10:25:32 2015 +0100
+++ b/data/fileio/CodedAudioFileReader.cpp	Tue Jun 30 10:26:23 2015 +0100
@@ -467,7 +467,7 @@
     if (m_normalised) {
         for (auto &f: frames) f *= m_gain;
     }
-    
+
     return frames;
 }
 
--- a/data/fileio/WavFileReader.cpp	Tue Jun 30 10:25:32 2015 +0100
+++ b/data/fileio/WavFileReader.cpp	Tue Jun 30 10:26:23 2015 +0100
@@ -157,7 +157,6 @@
     sv_frame_t n = count * m_fileInfo.channels;
     data.resize(n);
 
-    m_buffer = data;
     m_lastStart = start;
     m_lastCount = count;
     
@@ -166,6 +165,7 @@
         return {};
     }
 
+    m_buffer = data;
     return data;
 }
 
--- a/data/model/test/TestFFTModel.h	Tue Jun 30 10:25:32 2015 +0100
+++ b/data/model/test/TestFFTModel.h	Tue Jun 30 10:26:23 2015 +0100
@@ -168,6 +168,31 @@
              { { {}, {}, {}, {}, {} } }, 4);
     }
     
+    void twochan_simple_rect() {
+	MockWaveModel mwm({ Sine, Cosine }, 16, 4);
+        // Test that the two channels are read and converted separately
+        test(&mwm, RectangularWindow, 8, 8, 8, 0,
+             {
+                 { {}, {}, {}, {}, {} },
+                 { {}, {}, {}, {}, {} }
+             }, 4);
+        test(&mwm, RectangularWindow, 8, 8, 8, 1,
+             {
+                 { {}, {  0.f, 2.f }, {}, {}, {} },
+                 { {}, { -2.f, 0.f }, {}, {}, {} }
+             }, 4);
+        test(&mwm, RectangularWindow, 8, 8, 8, 2,
+             {
+                 { {}, {  0.f, 2.f }, {}, {}, {} },
+                 { {}, { -2.f, 0.f }, {}, {}, {} }
+             }, 4);
+        test(&mwm, RectangularWindow, 8, 8, 8, 3,
+             {
+                 { {}, {}, {}, {}, {} },
+                 { {}, {}, {}, {}, {} }
+             }, 4);
+    }
+    
     void nyquist_simple_rect() {
 	MockWaveModel mwm({ Nyquist }, 16, 4);
         // Again, the sign is flipped. This has the same amount of
--- a/data/model/test/test.pro	Tue Jun 30 10:25:32 2015 +0100
+++ b/data/model/test/test.pro	Tue Jun 30 10:26:23 2015 +0100
@@ -61,7 +61,7 @@
 
 !win32 {
     !macx* {
-        QMAKE_POST_LINK=valgrind ./$${TARGET}
+        QMAKE_POST_LINK=./$${TARGET}
     }
     macx* {
         QMAKE_POST_LINK=./$${TARGET}.app/Contents/MacOS/$${TARGET}