changeset 1045:1a73618b0b67 cxx11

More type fixes, primarily in the spectrogram
author Chris Cannam
date Tue, 10 Mar 2015 10:31:27 +0000
parents 31f01931b781
children 2f49be7d4264
files data/fft/FFTDataServer.cpp data/fft/FFTDataServer.h data/model/FFTModel.cpp data/model/FFTModel.h
diffstat 4 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/data/fft/FFTDataServer.cpp	Tue Mar 10 10:31:27 2015 +0000
@@ -55,7 +55,7 @@
                            int fftSize,
                            bool polar,
                            StorageAdviser::Criteria criteria,
-                           int fillFromColumn)
+                           sv_frame_t fillFromFrame)
 {
     QString n = generateFileBasename(model,
                                      channel,
@@ -95,7 +95,7 @@
                                    fftSize,
                                    polar,
                                    criteria,
-                                   fillFromColumn);
+                                   fillFromFrame);
     } catch (InsufficientDiscSpace) {
         delete server;
         server = 0;
@@ -117,7 +117,7 @@
                                 int fftSize,
                                 bool polar,
                                 StorageAdviser::Criteria criteria,
-                                int fillFromColumn)
+                                sv_frame_t fillFromFrame)
 {
     // Fuzzy matching:
     // 
@@ -223,7 +223,7 @@
                        fftSize,
                        polar,
                        criteria,
-                       fillFromColumn);
+                       fillFromFrame);
 }
 
 FFTDataServer *
@@ -490,7 +490,7 @@
 			     int fftSize,
                              bool polar,
                              StorageAdviser::Criteria criteria,
-                             int fillFromColumn) :
+                             sv_frame_t fillFromFrame) :
     m_fileBaseName(fileBaseName),
     m_model(model),
     m_channel(channel),
@@ -587,7 +587,7 @@
         throw(0);
     }
 
-    m_fillThread = new FillThread(*this, fillFromColumn);
+    m_fillThread = new FillThread(*this, fillFromFrame);
 }
 
 FFTDataServer::~FFTDataServer()
--- a/data/fft/FFTDataServer.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/data/fft/FFTDataServer.h	Tue Mar 10 10:31:27 2015 +0000
@@ -49,7 +49,7 @@
                                       bool polar,
                                       StorageAdviser::Criteria criteria =
                                           StorageAdviser::NoCriteria,
-                                      int fillFromColumn = 0);
+                                      sv_frame_t fillFromFrame = 0);
 
     static FFTDataServer *getFuzzyInstance(const DenseTimeValueModel *model,
                                            int channel,
@@ -60,7 +60,7 @@
                                            bool polar,
                                            StorageAdviser::Criteria criteria =
                                                StorageAdviser::NoCriteria,
-                                           int fillFromColumn = 0);
+                                           sv_frame_t fillFromFrame = 0);
 
     static void claimInstance(FFTDataServer *);
     static void releaseInstance(FFTDataServer *);
@@ -120,7 +120,7 @@
                   int fftSize,
                   bool polar,
                   StorageAdviser::Criteria criteria,
-                  int fillFromColumn = 0);
+                  sv_frame_t fillFromFrame = 0);
 
     virtual ~FFTDataServer();
 
@@ -241,9 +241,9 @@
     class FillThread : public Thread
     {
     public:
-        FillThread(FFTDataServer &server, int fillFromColumn) :
+        FillThread(FFTDataServer &server, sv_frame_t fillFromFrame) :
             m_server(server), m_extent(0), m_completion(0),
-            m_fillFrom(fillFromColumn) { }
+            m_fillFrom(fillFromFrame) { }
 
         sv_frame_t getExtent() const { return m_extent; }
         int getCompletion() const { return m_completion ? m_completion : 1; }
--- a/data/model/FFTModel.cpp	Mon Mar 09 12:02:10 2015 +0000
+++ b/data/model/FFTModel.cpp	Tue Mar 10 10:31:27 2015 +0000
@@ -36,7 +36,7 @@
                    int fftSize,
                    bool polar,
                    StorageAdviser::Criteria criteria,
-                   int fillFromColumn) :
+                   sv_frame_t fillFromFrame) :
     //!!! ZoomConstraint!
     m_server(0),
     m_xshift(0),
@@ -52,7 +52,7 @@
                          fftSize,
                          polar,
                          criteria,
-                         fillFromColumn);
+                         fillFromFrame);
 
     if (!m_server) return; // caller should check isOK()
 
@@ -110,7 +110,7 @@
                     int fftSize,
                     bool polar,
                     StorageAdviser::Criteria criteria,
-                    int fillFromColumn)
+                    sv_frame_t fillFromFrame)
 {
     // Obviously, an FFT model of channel C (where C != -1) of an
     // aggregate model is the same as the FFT model of the appropriate
@@ -142,7 +142,7 @@
                              fftSize,
                              polar,
                              criteria,
-                             fillFromColumn);
+                             fillFromFrame);
         }
     }
 
@@ -156,7 +156,7 @@
                                            fftSize,
                                            polar,
                                            criteria,
-                                           fillFromColumn);
+                                           fillFromFrame);
 }
 
 sv_samplerate_t
@@ -205,14 +205,14 @@
 }
 
 bool
-FFTModel::estimateStableFrequency(int x, int y, float &frequency)
+FFTModel::estimateStableFrequency(int x, int y, double &frequency)
 {
     if (!isOK()) return false;
 
     sv_samplerate_t sampleRate = m_server->getModel()->getSampleRate();
 
     int fftSize = m_server->getFFTSize() >> m_yshift;
-    frequency = float((y * sampleRate) / fftSize);
+    frequency = double(y * sampleRate) / fftSize;
 
     if (x+1 >= getWidth()) return false;
 
@@ -240,8 +240,8 @@
     // from assuming the "native" frequency of this bin
 
     frequency =
-        float((sampleRate * (expectedPhase + phaseError - oldPhase)) /
-              (2 * M_PI * incr));
+        (sampleRate * (expectedPhase + phaseError - oldPhase)) /
+        (2.0 * M_PI * incr);
 
     return true;
 }
@@ -430,7 +430,7 @@
             / (2 * M_PI * incr);
 //        bool stable = (fabsf(phaseError) < (1.1f * (incr * M_PI) / fftSize));
 //        if (stable)
-        peaks[*i] = float(frequency);
+        peaks[*i] = frequency;
         ++phaseIndex;
     }
 
--- a/data/model/FFTModel.h	Mon Mar 09 12:02:10 2015 +0000
+++ b/data/model/FFTModel.h	Tue Mar 10 10:31:27 2015 +0000
@@ -63,7 +63,7 @@
              int fftSize,
              bool polar,
              StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria,
-             int fillFromColumn = 0);
+             sv_frame_t fillFromFrame = 0);
     ~FFTModel();
 
     inline float getMagnitudeAt(int x, int y) {
@@ -151,7 +151,7 @@
      * bin, using phase unwrapping.  This will be completely wrong if
      * the signal is not stable here.
      */
-    virtual bool estimateStableFrequency(int x, int y, float &frequency);
+    virtual bool estimateStableFrequency(int x, int y, double &frequency);
 
     enum PeakPickType
     {
@@ -161,7 +161,7 @@
     };
 
     typedef std::set<int> PeakLocationSet; // bin
-    typedef std::map<int, float> PeakSet; // bin -> freq
+    typedef std::map<int, double> PeakSet; // bin -> freq
 
     /**
      * Return locations of peak bins in the range [ymin,ymax].  If
@@ -200,7 +200,7 @@
 
     FFTDataServer *getServer(const DenseTimeValueModel *,
                              int, WindowType, int, int, int,
-                             bool, StorageAdviser::Criteria, int);
+                             bool, StorageAdviser::Criteria, sv_frame_t);
 
     int getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate,
                               int bin, float &percentile) const;