changeset 203:11e107062a2b

* Fix apparent (but not actual) failure to save session file * Fix doofusness in FFT model (N/2 vs N/2+1) -- need to review use of this model in spectrogram
author Chris Cannam
date Fri, 08 Dec 2006 18:17:29 +0000
parents 91fdc752e540
children 29b70bdaacdc
files data/fft/FFTDataServer.cpp data/fileio/BZipFileDevice.cpp
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp	Fri Nov 17 16:27:39 2006 +0000
+++ b/data/fft/FFTDataServer.cpp	Fri Dec 08 18:17:29 2006 +0000
@@ -344,7 +344,7 @@
     size_t end = m_model->getEndFrame();
 
     m_width = (end - start) / m_windowIncrement + 1;
-    m_height = m_fftSize / 2;
+    m_height = m_fftSize / 2 + 1; // DC == 0, Nyquist == fftsize/2
 
     size_t maxCacheSize = 20 * 1024 * 1024;
     size_t columnSize = m_height * sizeof(fftsample) * 2 + sizeof(fftsample);
@@ -401,10 +401,10 @@
         fftwf_malloc(fftSize * sizeof(fftsample));
 
     m_fftOutput = (fftwf_complex *)
-        fftwf_malloc(fftSize * sizeof(fftwf_complex));
+        fftwf_malloc((fftSize/2 + 1) * sizeof(fftwf_complex));
 
     m_workbuffer = (float *)
-        fftwf_malloc(fftSize * sizeof(float));
+        fftwf_malloc((fftSize+2) * sizeof(float));
 
     m_fftPlan = fftwf_plan_dft_r2c_1d(m_fftSize,
                                       m_fftInput,
@@ -784,7 +784,7 @@
 
     fftsample factor = 0.0;
 
-    for (size_t i = 0; i < m_fftSize/2; ++i) {
+    for (size_t i = 0; i <= m_fftSize/2; ++i) {
 
 	fftsample mag = sqrtf(m_fftOutput[i][0] * m_fftOutput[i][0] +
                               m_fftOutput[i][1] * m_fftOutput[i][1]);
@@ -796,12 +796,12 @@
 	phase = princargf(phase);
 
         m_workbuffer[i] = mag;
-        m_workbuffer[i + m_fftSize/2] = phase;
+        m_workbuffer[i + m_fftSize/2+1] = phase;
     }
 
     cache->setColumnAt(col,
                        m_workbuffer,
-                       m_workbuffer + m_fftSize/2,
+                       m_workbuffer + m_fftSize/2+1,
                        factor);
 
     if (m_suspended) {
--- a/data/fileio/BZipFileDevice.cpp	Fri Nov 17 16:27:39 2006 +0000
+++ b/data/fileio/BZipFileDevice.cpp	Fri Dec 08 18:17:29 2006 +0000
@@ -36,6 +36,8 @@
 bool
 BZipFileDevice::open(OpenMode mode)
 {
+    setErrorString("");
+
     if (m_bzFile) {
         setErrorString(tr("File is already open"));
         return false;