Realtime sound spectrogram using FFT or linear prediction. Spectrogram is displayed on the display of PC. リアルタイム・スペクトログラム.解析の手法:FFT,線形予測法.スペクトログラムは PC のディスプレー装置に表示される.PC 側のプログラム:F446_Spectrogram.

Dependencies:   Array_Matrix mbed SerialTxRxIntr F446_AD_DA UIT_FFT_Real

MySpectrogram/AnalyzerBase.cpp

Committer:
MikamiUitOpen
Date:
2018-11-04
Revision:
6:c38ec7939609
Parent:
0:a539141b9dec

File content as of revision 6:c38ec7939609:

//-------------------------------------------------------
//  Base abstract class for spectrum analysis
//
//  2018/11/04, Copyright (c) 2018 MIKAMI, Naoki
//-------------------------------------------------------

#include "AnalyzerBase.hpp"

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

    void AnalyzerBase::Execute(const float xn[], float db[])
    {
        // 高域強調
        for (int n=0; n<N_DATA_-1; n++)
            xData_[n] = xn[n+1] - b1_*xn[n];

        // 直流分を除去
        float sum = 0;
        for (int n=0; n<N_FFT_; n++) sum = sum + xData_[n];
        float ave = sum/N_FFT_;
        for (int n=0; n<N_FFT_; n++) xData_[n] = xData_[n] - ave;

        // 窓掛け
        wHm_.Execute(xData_, wData_);
            
        Analyze(wData_, db);
    }
}