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
DoubleBufferMatrix.hpp
00001 //-------------------------------------------------------- 00002 // ダブル・バッファの template クラス 00003 // バッファに2次元配列(Matrix クラス)を使用 00004 // 00005 // 2019/11/22, Copyright (c) 2019 MIKAMI, Naoki 00006 //-------------------------------------------------------- 00007 00008 #ifndef DOUBLE_BUFFER_MATRIX_HPP 00009 #define DOUBLE_BUFFER_MATRIX_HPP 00010 00011 #include "Matrix.hpp" 00012 using namespace Mikami; 00013 00014 template<class T> class DoubleBuffer 00015 { 00016 public: 00017 // コンストラクタ 00018 explicit DoubleBuffer(int size, T initialValue = 0) 00019 : N_(size), buf_(2, size, initialValue), ping_(0), pong_(1), 00020 index_(0), full_(false) {} 00021 00022 // データを格納 00023 void Store(T data) { buf_[ping_][index_++] = data; } 00024 00025 // 出力バッファからデータの取り出し 00026 T Get(int n) const { return buf_[pong_][n]; } 00027 00028 // バッファが満杯でバッファを切り替える 00029 bool IsFullSwitch() 00030 { 00031 if (index_ < N_) return false; 00032 00033 ping_ ^= 0x1; // バッファ切換えのため 00034 pong_ ^= 0x1; // バッファ切換えのため 00035 index_ = 0; 00036 full_ = true; 00037 return true; 00038 } 00039 00040 // バッファが満杯で,true を返す 00041 bool IsFull() 00042 { 00043 bool temp = full_; 00044 if (full_) full_ = false; 00045 return temp; 00046 } 00047 00048 private: 00049 const int N_; // バッファのサイズ 00050 Matrix<T> buf_; // バッファ 00051 int ping_, pong_; // バッファ切替用 00052 int index_; // 入力データのカウンタ 00053 bool full_; // 満杯の場合 true 00054 00055 // コピー・コンストラクタおよび代入演算子の禁止のため 00056 DoubleBuffer(const DoubleBuffer&); 00057 DoubleBuffer& operator=(const DoubleBuffer&); 00058 }; 00059 #endif // DOUBLE_BUFFER_MATRIX_HPP
Generated on Mon Jul 25 2022 07:38:49 by 1.7.2