![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Vowel synthesizer using digital resonators. This program can run without LCD display. ディジタル共振器を使った合成母音ジェネレータ.LCD表示器なしでも動く.
Dependencies: UITDSP_ADDA UIT_ACM1602NI UIT_AQM1602 mbed
Resonator.cpp@0:6c67a9387981, 2014-12-02 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Dec 02 00:06:08 2014 +0000
- Revision:
- 0:6c67a9387981
- Child:
- 4:dd2ec72068d0
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:6c67a9387981 | 1 | //------------------------------------------------------------------------------ |
MikamiUitOpen | 0:6c67a9387981 | 2 | // 音声合成で使う共振器 |
MikamiUitOpen | 0:6c67a9387981 | 3 | // 作成者:三上直樹,2013/11/27 作成,(c)三上直樹 2013 |
MikamiUitOpen | 0:6c67a9387981 | 4 | //------------------------------------------------------------------------------ |
MikamiUitOpen | 0:6c67a9387981 | 5 | |
MikamiUitOpen | 0:6c67a9387981 | 6 | #include "Resonator.hpp" |
MikamiUitOpen | 0:6c67a9387981 | 7 | |
MikamiUitOpen | 0:6c67a9387981 | 8 | namespace Mikami |
MikamiUitOpen | 0:6c67a9387981 | 9 | { |
MikamiUitOpen | 0:6c67a9387981 | 10 | // コンストラクタに共通な初期化 |
MikamiUitOpen | 0:6c67a9387981 | 11 | void Resonator::Initialize(float fr, float bw, float fs) |
MikamiUitOpen | 0:6c67a9387981 | 12 | { |
MikamiUitOpen | 0:6c67a9387981 | 13 | if (piT_ == 0) piT_ = 3.14159265f/fs; |
MikamiUitOpen | 0:6c67a9387981 | 14 | Set(fr, bw); |
MikamiUitOpen | 0:6c67a9387981 | 15 | Clear(); |
MikamiUitOpen | 0:6c67a9387981 | 16 | } |
MikamiUitOpen | 0:6c67a9387981 | 17 | |
MikamiUitOpen | 0:6c67a9387981 | 18 | // 共振器のパラメータの設定 |
MikamiUitOpen | 0:6c67a9387981 | 19 | void Resonator::Set(float fr, float bw) |
MikamiUitOpen | 0:6c67a9387981 | 20 | { |
MikamiUitOpen | 0:6c67a9387981 | 21 | a1_ = 2.0f*exp(-piT_*bw)*cos(2.0f*piT_*fr); |
MikamiUitOpen | 0:6c67a9387981 | 22 | a2_ = -exp(-2.0f*piT_*bw); |
MikamiUitOpen | 0:6c67a9387981 | 23 | b0_ = 1.0f - a1_ - a2_; |
MikamiUitOpen | 0:6c67a9387981 | 24 | } |
MikamiUitOpen | 0:6c67a9387981 | 25 | |
MikamiUitOpen | 0:6c67a9387981 | 26 | // 共振器に対応する処理の実行 |
MikamiUitOpen | 0:6c67a9387981 | 27 | float Resonator::Execute(float xin) |
MikamiUitOpen | 0:6c67a9387981 | 28 | { |
MikamiUitOpen | 0:6c67a9387981 | 29 | float ym = a1_*yn1_ + a2_*yn2_ + b0_*xin; |
MikamiUitOpen | 0:6c67a9387981 | 30 | yn2_ = yn1_; // 遅延器のデータの移動 |
MikamiUitOpen | 0:6c67a9387981 | 31 | yn1_ = ym; // 遅延器のデータの移動 |
MikamiUitOpen | 0:6c67a9387981 | 32 | return ym; |
MikamiUitOpen | 0:6c67a9387981 | 33 | } |
MikamiUitOpen | 0:6c67a9387981 | 34 | |
MikamiUitOpen | 0:6c67a9387981 | 35 | // "π/標本化周波数" の値に対応する実体 |
MikamiUitOpen | 0:6c67a9387981 | 36 | float Resonator::piT_ = 0; |
MikamiUitOpen | 0:6c67a9387981 | 37 | } |
MikamiUitOpen | 0:6c67a9387981 | 38 | |
MikamiUitOpen | 0:6c67a9387981 | 39 |