Demo program of digital signal processing: Variable LPF/HPF, Vocal canceller, Pitch shifter, Reverbrator. ディジタル信号処理のデモプログラム. 遮断周波数可変 LPF/HPF,ボーカルキャンセラ,ピッチシフタ,残響生成器.

Dependencies:   Array_Matrix F446_AD_DA UIT_AQM1602 mbed

Committer:
MikamiUitOpen
Date:
Tue Feb 21 13:14:47 2017 +0000
Revision:
6:96b4f6ce2dc9
Parent:
3:e223a1b4e8c2
7

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 3:e223a1b4e8c2 1 //--------------------------------------------------------------------
MikamiUitOpen 3:e223a1b4e8c2 2 // STM32F446 と信号処理用ボードによるデモプログラムで使うグローバル関数
MikamiUitOpen 3:e223a1b4e8c2 3 //
MikamiUitOpen 3:e223a1b4e8c2 4 // 2017/01/30, Copyright (c) 2017 MIKAMI, Naoki
MikamiUitOpen 3:e223a1b4e8c2 5 //--------------------------------------------------------------------
MikamiUitOpen 3:e223a1b4e8c2 6
MikamiUitOpen 3:e223a1b4e8c2 7 #include "SignalProcessing.hpp" // 信号処理の抽象基底クラスなど
MikamiUitOpen 3:e223a1b4e8c2 8 #include "AQM1602.hpp"
MikamiUitOpen 3:e223a1b4e8c2 9 using namespace Mikami;
MikamiUitOpen 3:e223a1b4e8c2 10
MikamiUitOpen 3:e223a1b4e8c2 11 extern SignalProcessing *spPtr_; // 処理に対応するポインタ
MikamiUitOpen 3:e223a1b4e8c2 12
MikamiUitOpen 3:e223a1b4e8c2 13 // 機能の割り当てと表示
MikamiUitOpen 3:e223a1b4e8c2 14 void AssignDisplay(SignalProcessing &func, Aqm1602 &lcd,
MikamiUitOpen 3:e223a1b4e8c2 15 char str[], float val = -1)
MikamiUitOpen 3:e223a1b4e8c2 16 {
MikamiUitOpen 3:e223a1b4e8c2 17 spPtr_ = &func; // 機能の割り当て
MikamiUitOpen 3:e223a1b4e8c2 18
MikamiUitOpen 3:e223a1b4e8c2 19 // 表示
MikamiUitOpen 3:e223a1b4e8c2 20 lcd.ClearLine(0);
MikamiUitOpen 3:e223a1b4e8c2 21 lcd.ClearLine(1);
MikamiUitOpen 3:e223a1b4e8c2 22 printf("%s", str);
MikamiUitOpen 3:e223a1b4e8c2 23 lcd.WriteStringXY(str, 0, 0);
MikamiUitOpen 3:e223a1b4e8c2 24
MikamiUitOpen 3:e223a1b4e8c2 25 if (val != -1)
MikamiUitOpen 3:e223a1b4e8c2 26 {
MikamiUitOpen 3:e223a1b4e8c2 27 printf(", %4.0f Hz", val);
MikamiUitOpen 3:e223a1b4e8c2 28 lcd.WriteValueXY("%4.0f Hz", val, 0, 1);
MikamiUitOpen 3:e223a1b4e8c2 29 }
MikamiUitOpen 3:e223a1b4e8c2 30 printf("\r\n");
MikamiUitOpen 3:e223a1b4e8c2 31 }
MikamiUitOpen 3:e223a1b4e8c2 32
MikamiUitOpen 3:e223a1b4e8c2 33 // 周波数変化が基準値より大きい場合に true を返す
MikamiUitOpen 3:e223a1b4e8c2 34 // min <= frq <= max
MikamiUitOpen 3:e223a1b4e8c2 35 // th : 基準値
MikamiUitOpen 3:e223a1b4e8c2 36 bool FrChange(AnalogIn &aIn, float min, float max, float th, float &frq)
MikamiUitOpen 3:e223a1b4e8c2 37 {
MikamiUitOpen 3:e223a1b4e8c2 38 static float frqCurrent = 0;
MikamiUitOpen 3:e223a1b4e8c2 39 frq = (max - min)*aIn.read() + min;
MikamiUitOpen 3:e223a1b4e8c2 40 if (fabs(frq - frqCurrent) > th)
MikamiUitOpen 3:e223a1b4e8c2 41 {
MikamiUitOpen 3:e223a1b4e8c2 42 frqCurrent = frq;
MikamiUitOpen 3:e223a1b4e8c2 43 return true;
MikamiUitOpen 3:e223a1b4e8c2 44 }
MikamiUitOpen 3:e223a1b4e8c2 45 else
MikamiUitOpen 3:e223a1b4e8c2 46 return false;
MikamiUitOpen 3:e223a1b4e8c2 47 }