//-------------------------------------------------------
//  Base abstract class for spectrum analysis
//
//  2017/03/30, Copyright (c) 2017 MIKAMI, Naoki
//-------------------------------------------------------

#include "AnalysisBase.hpp"

namespace Mikami
{
    AnalyzerBase::AnalyzerBase(int nData, int nFft, int nUse)
        : N_DATA_(nData), N_FFT_(nFft),
          fft_(nFft), wHm_(nData-1, nUse),
          xData_(nUse), wData_(nUse) {}

    void AnalyzerBase::Execute(const float xn[], float db[])
    {
        // Differencing
        for (int n=0; n<N_DATA_-1; n++)
            xData_[n] = xn[n+1] - 0.8f*xn[n];
            
        // Windowing
        wHm_.Execute(xData_, wData_);

        Analyze(wData_, db);
    }
}
