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

Revision:
8:1f4bc859bc84
Parent:
7:6598a9b70e5a
Child:
11:a8420871920e
Child:
12:e5367ab82460
--- a/MyClasses/Sampler.hpp	Sun Dec 20 13:38:22 2015 +0000
+++ b/MyClasses/Sampler.hpp	Mon Dec 28 08:20:34 2015 +0000
@@ -1,7 +1,7 @@
 //------------------------------------------------
 //  Class for sampling input signal (Header)
 //
-//  2015/12/20, Copyright (c) 2015 MIKAMI, Naoki
+//  2015/12/28, Copyright (c) 2015 MIKAMI, Naoki
 //------------------------------------------------
 
 #ifndef F746_SAMPLER_HPP
@@ -18,38 +18,41 @@
                 
         ~Sampler();
 
-        void Start();
+        // Start sampling
+        void Start(bool onOff);
 
         bool Filled() { return filled_; }
 
-        void InvertEnable(bool onOff)
-        {   sw_ = onOff ? 1 : 0; }
-
         // Get pointer for sampled data
-        int16_t* Get() { return xn_; }
+        int16_t* Get() { return sn_; }
 
     private:
         const int TS_;      // sampling period
         const int N_DATA_;  // number of 1 frame data
 
-        AnalogIn aIn_;      // Object of ADC
+        AnalogIn aIn_;      // Object for ADC
         Ticker timer_;      // Object of Ticker
 
         bool trigger_;
         bool filled_;
         int count_;
         int16_t xnM1_;
-        int sw_;
-        int16_t* const xn_;     // data to be analyzed
+        int16_t* const sn_;     // data to be analyzed
         int16_t* const buffer_; // for input buffer
 
         // For input
-        int16_t (Sampler::*Rd[2])();
+        int16_t (Sampler::*Rd)();
         int16_t ReadNorm() { return aIn_.read_u16() - 32767; }
         int16_t ReadInv()  { return 32767 - aIn_.read_u16(); }
 
-        void Set(bool tf);
-
+        // 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();