不韋 呂 / Mbed 2 deprecated F746_VowelSinger

Dependencies:   BSP_DISCO_F746NG_patch_fixed BUTTON_GROUP LCD_DISCO_F746NG TS_DISCO_F746NG mbed

Revision:
0:a98746e7a170
diff -r 000000000000 -r a98746e7a170 MyClasses_Functions/Resonator.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyClasses_Functions/Resonator.cpp	Wed Feb 24 13:00:12 2016 +0000
@@ -0,0 +1,34 @@
+//------------------------------------------------------------------------------
+//  音声合成で使う共振器
+//      作成者:三上直樹,2013/11/27 作成,(c)三上直樹 2013
+//------------------------------------------------------------------------------
+
+#include "Resonator.hpp"
+
+// コンストラクタに共通な初期化
+void Resonator::Initialize(float fr, float bw, float fs)
+{
+    if (piT_ == 0) piT_ = 3.14159265f/fs;
+    Set(fr, bw);
+    Clear();
+}
+
+// 共振器のパラメータの設定
+void Resonator::Set(float fr, float bw)
+{
+    a1_ = 2.0f*expf(-piT_*bw)*cosf(2.0f*piT_*fr);
+    a2_ = -expf(-2.0f*piT_*bw);
+    b0_ = 1.0f - a1_ - a2_;
+}
+
+// 共振器に対応する処理の実行
+float Resonator::Execute(float xin)
+{
+    float ym = a1_*yn1_ + a2_*yn2_ + b0_*xin;
+    yn2_ = yn1_;    // 遅延器のデータの移動
+    yn1_ = ym;      // 遅延器のデータの移動
+    return ym;
+}
+
+// π/標本化周波数" の値に対応する実体
+float Resonator::piT_ = 0;
\ No newline at end of file