changeset 11:366f678dea8c

* tidy etc
author Chris Cannam
date Mon, 14 Jun 2010 11:44:00 +0100
parents 25580443645c
children 500cc94c3475
files Makefile devuvuzelator-ladspa.cpp devuvuzelator.cpp
diffstat 3 files changed, 13 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Mon Jun 14 09:25:01 2010 +0100
+++ b/Makefile	Mon Jun 14 11:44:00 2010 +0100
@@ -5,13 +5,13 @@
 OBJECTS		:= devuvuzelator.o devuvuzelator-ladspa.o fft.o
 HEADERS		:= devuvuzelator-ladspa.h params.h median.h
 
-devuvuzelator.so:	$(SOURCES)
+devuvuzelator.so:	$(OBJECTS)
 	$(CXX) $^ $(CXXFLAGS) -shared -o $@
 
 clean:		
 	rm -f $(OBJECTS)
 
-devuvuzelator.cpp:	$(HEADERS)
-devuvuzelator-ladspa.cpp:	$(HEADERS)
-fft.cpp:	$(HEADERS)
+devuvuzelator.o:	$(HEADERS)
+devuvuzelator-ladspa.o:	$(HEADERS)
+fft.o:	$(HEADERS)
 
--- a/devuvuzelator-ladspa.cpp	Mon Jun 14 09:25:01 2010 +0100
+++ b/devuvuzelator-ladspa.cpp	Mon Jun 14 11:44:00 2010 +0100
@@ -59,7 +59,7 @@
     properties,
     "Devuvuzelator", // Name
     "Queen Mary, University of London", // Maker
-    "All Rights Reserved", // Copyright
+    "BSD", // Copyright
     PortCount,
     ports,
     portNames,
--- a/devuvuzelator.cpp	Mon Jun 14 09:25:01 2010 +0100
+++ b/devuvuzelator.cpp	Mon Jun 14 11:44:00 2010 +0100
@@ -13,27 +13,21 @@
 void
 Devuvuzelator::processSpectralFrame()
 {
-    const int hs = m_fftsize/2 + 1;
-    double *mags = (double *)alloca(hs * sizeof(double));
-    for (int i = 0; i < hs; ++i) {
-        mags[i] = sqrt(m_real[i] * m_real[i] + m_imag[i] * m_imag[i]);
-    }
-
     double lowfun = m_fundamental - m_bandwidth/2;
     double highfun = m_fundamental + m_bandwidth/2;
 
-    int ix = 0;
-
     for (int h = 1; h <= m_harmonics; ++h) {
 
         double lowfreq = lowfun * h;
         double highfreq = highfun * h;
 
-        int lowbin = 0.5 + (m_fftsize * lowfreq) / m_sampleRate;
-        int highbin = 0.5 + (m_fftsize * highfreq) / m_sampleRate;
+        int lowbin = int(0.5 + (m_fftsize * lowfreq) / m_sampleRate);
+        int highbin = int(0.5 + (m_fftsize * highfreq) / m_sampleRate);
 
         for (int i = lowbin; i <= highbin; ++i) {
 
+            double mag = sqrt(m_real[i] * m_real[i] + m_imag[i] * m_imag[i]);
+
             if (!m_medians[i]) {
                 // allocation in RT context, sorry! but this happens only
                 // the first time through
@@ -41,36 +35,18 @@
                 m_medians[i] = new MedianFilter<double>(filterlen);
             }
 
-            m_medians[i]->push(mags[i]);
+            m_medians[i]->push(mag);
             double threshold = m_medians[i]->getAt(m_reduction);
 
-//            if (ix == 2) {
-                std::cerr << "at freq " << (float(i) * m_sampleRate) / m_fftsize
-                          << ", threshold = " << threshold << std::endl;
-//            }
-
-//            if (ix == 2) {
-                std::cerr << "changing from (" << m_real[i] << ","
-                          << m_imag[i] << ") to ";
-//            }
-
-            if (mags[i] > threshold && mags[i] > 0.0) {
-                double target = mags[i] - threshold;
-                double ratio = (target / mags[i]);
+            if (mag > threshold && mag > 0.0) {
+                double target = mag - threshold;
+                double ratio = (target / mag);
                 m_real[i] *= ratio;
                 m_imag[i] *= ratio;
             } else {
                 m_real[i] = 0.0;
                 m_imag[i] = 0.0;
             }
-
-//            if (ix == 2) {
-                std::cerr << "(" << m_real[i] << ","
-                          << m_imag[i] << ")" << std::endl;
-//            }
-
-            ++ix;
         }
     }
 }
-