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@7:5ba884060d3b, 2019-11-24 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sun Nov 24 11:14:01 2019 +0000
- Revision:
- 7:5ba884060d3b
- Parent:
- 6:c38ec7939609
8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:a539141b9dec | 1 | //------------------------------------------------------- |
MikamiUitOpen | 0:a539141b9dec | 2 | // Base abstract class for spectrum analysis |
MikamiUitOpen | 0:a539141b9dec | 3 | // |
MikamiUitOpen | 6:c38ec7939609 | 4 | // 2018/11/04, Copyright (c) 2018 MIKAMI, Naoki |
MikamiUitOpen | 0:a539141b9dec | 5 | //------------------------------------------------------- |
MikamiUitOpen | 0:a539141b9dec | 6 | |
MikamiUitOpen | 0:a539141b9dec | 7 | #include "AnalyzerBase.hpp" |
MikamiUitOpen | 0:a539141b9dec | 8 | |
MikamiUitOpen | 0:a539141b9dec | 9 | namespace Mikami |
MikamiUitOpen | 0:a539141b9dec | 10 | { |
MikamiUitOpen | 0:a539141b9dec | 11 | AnalyzerBase::AnalyzerBase(int nData, int nFft, int nUse) |
MikamiUitOpen | 0:a539141b9dec | 12 | : N_DATA_(nData), N_FFT_(nFft), |
MikamiUitOpen | 0:a539141b9dec | 13 | fft_(nFft), wHm_(nData-1, nUse), b1_(1.0f), |
MikamiUitOpen | 0:a539141b9dec | 14 | xData_(nUse), wData_(nUse) {} |
MikamiUitOpen | 0:a539141b9dec | 15 | |
MikamiUitOpen | 0:a539141b9dec | 16 | void AnalyzerBase::Execute(const float xn[], float db[]) |
MikamiUitOpen | 0:a539141b9dec | 17 | { |
MikamiUitOpen | 0:a539141b9dec | 18 | // 高域強調 |
MikamiUitOpen | 0:a539141b9dec | 19 | for (int n=0; n<N_DATA_-1; n++) |
MikamiUitOpen | 0:a539141b9dec | 20 | xData_[n] = xn[n+1] - b1_*xn[n]; |
MikamiUitOpen | 6:c38ec7939609 | 21 | |
MikamiUitOpen | 6:c38ec7939609 | 22 | // 直流分を除去 |
MikamiUitOpen | 6:c38ec7939609 | 23 | float sum = 0; |
MikamiUitOpen | 6:c38ec7939609 | 24 | for (int n=0; n<N_FFT_; n++) sum = sum + xData_[n]; |
MikamiUitOpen | 6:c38ec7939609 | 25 | float ave = sum/N_FFT_; |
MikamiUitOpen | 6:c38ec7939609 | 26 | for (int n=0; n<N_FFT_; n++) xData_[n] = xData_[n] - ave; |
MikamiUitOpen | 6:c38ec7939609 | 27 | |
MikamiUitOpen | 0:a539141b9dec | 28 | // 窓掛け |
MikamiUitOpen | 0:a539141b9dec | 29 | wHm_.Execute(xData_, wData_); |
MikamiUitOpen | 0:a539141b9dec | 30 | |
MikamiUitOpen | 0:a539141b9dec | 31 | Analyze(wData_, db); |
MikamiUitOpen | 0:a539141b9dec | 32 | } |
MikamiUitOpen | 0:a539141b9dec | 33 | } |