Basic Audio Signal Processing Library

Dependents:   unzen_sample_nucleo_f746 skeleton_unzen_nucleo_f746 ifmag_noise_canceller synthesizer_f746

オーディオ信号処理用のライブラリです。

mbed-dspのフィルタ群向けに作ったクラス・ラッパーのほか、以下のクラスを用意しています。

  • ヒステリシス
  • sin/cosオシレータ
  • リミッター

クラスは全て名前空間amakusaに含まれます。

Committer:
shorie
Date:
Sat Jan 21 07:16:37 2017 +0000
Revision:
2:fbdf03b330ae
update with hysterisis

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shorie 2:fbdf03b330ae 1 #include "amakusa.h"
shorie 2:fbdf03b330ae 2
shorie 2:fbdf03b330ae 3 #define ROUND_OFFSET 0x2
shorie 2:fbdf03b330ae 4
shorie 2:fbdf03b330ae 5 amakusa::Hysteresis::Hysteresis( int32_t min_input, int32_t max_input )
shorie 2:fbdf03b330ae 6 {
shorie 2:fbdf03b330ae 7 this->min = min_input;
shorie 2:fbdf03b330ae 8 this->max = max_input;
shorie 2:fbdf03b330ae 9 this->last_value = 0;
shorie 2:fbdf03b330ae 10 }
shorie 2:fbdf03b330ae 11
shorie 2:fbdf03b330ae 12 int32_t amakusa::Hysteresis::run(int32_t in_data)
shorie 2:fbdf03b330ae 13 {
shorie 2:fbdf03b330ae 14 if ( in_data == this->last_value )
shorie 2:fbdf03b330ae 15 ; // do nothing;
shorie 2:fbdf03b330ae 16 else
shorie 2:fbdf03b330ae 17 this->last_value = ( in_data + ROUND_OFFSET + ( in_data > this->last_value ? - 1 : 1 ) ) & 0xFFFFFFFC;
shorie 2:fbdf03b330ae 18
shorie 2:fbdf03b330ae 19 if ( this->last_value > this->max )
shorie 2:fbdf03b330ae 20 this->last_value = this->max;
shorie 2:fbdf03b330ae 21 else if ( this->last_value < this->min )
shorie 2:fbdf03b330ae 22 this->last_value = this->min;
shorie 2:fbdf03b330ae 23
shorie 2:fbdf03b330ae 24 return this->last_value;
shorie 2:fbdf03b330ae 25 }