Realtime spectrum analyzer. Using FFT, linear prediction, or cepstrum smoothing. Version using MEMS microphone and CODEC, named "F746_RealtimeSpectrumAnalyzer_MEMS_Mic" is registered. リアルタイム スペクトル解析器.解析の手法:FFT,線形予測法,ケプストラムによる平滑化の3種類.このプログラムの説明は,CQ出版社のインターフェース誌,2016年4月号に掲載.外付けのマイクまたは他の信号源等を A0 に接続する.線形予測法,ケプストラムは,スペクトル解析の対象を音声信号に想定してパラメータを設定している.MEMS マイクと CODEC を使ったバージョンを "F746_RealtimeSpectrumAnalyzer_MEMS_Mic" として登録.
Dependencies: BSP_DISCO_F746NG BUTTON_GROUP LCD_DISCO_F746NG TS_DISCO_F746NG UIT_FFT_Real mbed
MyClasses/Sampler.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2015-12-31
- Revision:
- 11:a8420871920e
- Parent:
- 8:1f4bc859bc84
- Child:
- 14:cd4534fb34e7
File content as of revision 11:a8420871920e:
//------------------------------------------------ // Class for sampling input signal (Header) // // 2015/12/31, Copyright (c) 2015 MIKAMI, Naoki //------------------------------------------------ #ifndef F746_SAMPLER_HPP #define F746_SAMPLER_HPP #include "mbed.h" namespace Mikami { class Sampler { public: Sampler(PinName pin, int fs, int nData); ~Sampler(); // Start sampling void Start(bool onOff); // Stop sampling void Stop() { timer_.detach(); } bool Filled() { return filled_; } // Get pointer for sampled data int16_t* Get() { return sn_; } private: const int TS_; // sampling period const int N_DATA_; // number of 1 frame data AnalogIn aIn_; // Object for ADC Ticker timer_; // Object of Ticker bool trigger_; bool filled_; int count_; int16_t xnM1_; int16_t* const sn_; // data to be analyzed int16_t* const buffer_; // for input buffer // For input int16_t (Sampler::*Rd)(); int16_t ReadNorm() { return aIn_.read_u16() - 32767; } int16_t ReadInv() { return 32767 - aIn_.read_u16(); } // Set inverting on or off void Invert(bool onOff) { Rd = onOff ? &Sampler::ReadInv // Inverted : &Sampler::ReadNorm; // Non-inverted } // Interrupt service routine for Ticker void Isr(); // disallow copy constructor and assignment operator Sampler(const Sampler& ); Sampler& operator=(const Sampler& ); }; } #endif // F746_SAMPLER_HPP