changeset 15:203551cbad47

* FIRFilter now has three output options - take all output elements, first lengthOfInput outputs, or take first lengthOfInput output after group delay
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Thu, 14 Aug 2014 11:09:43 +0100
parents c11367df624d
children 3e4ddfbfeb81
files FIRFilter.cpp FIRFilter.h NoveltyCurveProcessor.cpp TempogramPlugin.cpp
diffstat 4 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/FIRFilter.cpp	Thu Aug 14 10:31:49 2014 +0100
+++ b/FIRFilter.cpp	Thu Aug 14 11:09:43 2014 +0100
@@ -57,8 +57,9 @@
 }
 
 void
-FIRFilter::process(const float* pInput, const float* pCoefficients, float* pOutput)
+FIRFilter::process(const float* pInput, const float* pCoefficients, float* pOutput, OutputTypeArgument outputType)
 {
+    
     //Copy to same length FFT buffers
     for(unsigned int i = 0; i < m_lengthFIRFFT; i++){
         m_pFftInput[i] = i < m_lengthInput ? pInput[i] : 0.0;
@@ -77,9 +78,13 @@
     FFT::inverse(m_lengthFIRFFT, m_pFftFilteredReal, m_pFftFilteredImag, m_pFftOutputReal, m_pFftOutputImag);
     
     //copy to output
-    int offset = ceil(m_numberOfCoefficients/2);
-    //int offset = 0;
-    for (unsigned int i = 0; i < m_lengthInput; i++){
+    int offset = 0;
+    unsigned int outputLength = m_lengthInput;
+    if (outputType == all) outputLength = m_lengthFIRFFT;
+    else if (outputType == middle) offset = floor((float)m_numberOfCoefficients/2);
+    else if (outputType != first) cerr << "FIRFilter::process(params) - " << outputType << " is not a valid argument. outputType is set to first." << endl;
+    
+    for (unsigned int i = 0; i < outputLength; i++){
         pOutput[i] = m_pFftOutputReal[i + offset];
     }
 }
--- a/FIRFilter.h	Thu Aug 14 10:31:49 2014 +0100
+++ b/FIRFilter.h	Thu Aug 14 11:09:43 2014 +0100
@@ -12,12 +12,19 @@
 #include <cmath>
 #include <vamp-sdk/FFT.h>
 #include <assert.h>
+#include <iostream>
 
 class FIRFilter{
 public:
+    enum OutputTypeArgument{
+        first = 0,
+        middle,
+        all
+    };
+    
     FIRFilter(const size_t &lengthInput, const size_t &numberOfCoefficients);
     ~FIRFilter();
-    void process(const float *pInput, const float *pCoefficients, float * pOutput);
+    void process(const float *pInput, const float *pCoefficients, float * pOutput, OutputTypeArgument outputType = first);
 private:
     size_t m_lengthInput;
     size_t m_numberOfCoefficients;
--- a/NoveltyCurveProcessor.cpp	Thu Aug 14 10:31:49 2014 +0100
+++ b/NoveltyCurveProcessor.cpp	Thu Aug 14 11:09:43 2014 +0100
@@ -77,7 +77,7 @@
     WindowFunction::hanning(m_hannWindow, smoothLength, true);
     
     FIRFilter filter(m_numberOfBlocks, smoothLength);
-    filter.process(&noveltyCurve[0], m_hannWindow, &localAverage[0]);
+    filter.process(&noveltyCurve[0], m_hannWindow, &localAverage[0], FIRFilter::middle);
     
     assert(noveltyCurve.size() == m_numberOfBlocks);
     for (unsigned int i = 0; i < m_numberOfBlocks; i++){
@@ -104,7 +104,7 @@
     FIRFilter smoothFilter(m_numberOfBlocks, smoothLength);
     
     for (unsigned int i = 0; i < m_blockSize; i++){
-        smoothFilter.process(&spectrogram[i][0], diffHannWindow, &spectrogram[i][0]);
+        smoothFilter.process(&spectrogram[i][0], diffHannWindow, &spectrogram[i][0], FIRFilter::middle);
     }
 }
 
--- a/TempogramPlugin.cpp	Thu Aug 14 10:31:49 2014 +0100
+++ b/TempogramPlugin.cpp	Thu Aug 14 11:09:43 2014 +0100
@@ -135,7 +135,7 @@
 
     ParameterDescriptor d1;
     d1.identifier = "C";
-    d1.name = "C";
+    d1.name = "Novelty Curve Spectrogram Compression Constant";
     d1.description = "Spectrogram compression constant, C, used when retrieving the novelty curve from the audio.";
     d1.unit = "";
     d1.minValue = 2;
@@ -191,7 +191,7 @@
     
     ParameterDescriptor d5;
     d5.identifier = "minBPM";
-    d5.name = "Minimum BPM";
+    d5.name = "Tempogram Minimum BPM";
     d5.description = "The minimum BPM of the tempogram output bins.";
     d5.unit = "";
     d5.minValue = 0;
@@ -203,7 +203,7 @@
     
     ParameterDescriptor d6;
     d6.identifier = "maxBPM";
-    d6.name = "Maximum BPM";
+    d6.name = "Tempogram Maximum BPM";
     d6.description = "The minimum BPM of the tempogram output bins.";
     d6.unit = "";
     d6.minValue = 30;