Basic Audio Signal Processing Library
Dependents: unzen_sample_nucleo_f746 skeleton_unzen_nucleo_f746 ifmag_noise_canceller synthesizer_f746
オーディオ信号処理用のライブラリです。
mbed-dspのフィルタ群向けに作ったクラス・ラッパーのほか、以下のクラスを用意しています。
- ヒステリシス
- sin/cosオシレータ
- リミッター
クラスは全て名前空間amakusaに含まれます。
Diff: hysteresis.txt
- Revision:
- 2:fbdf03b330ae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hysteresis.txt Sat Jan 21 07:16:37 2017 +0000 @@ -0,0 +1,25 @@ +#include "amakusa.h" + +#define ROUND_OFFSET 0x2 + +amakusa::Hysteresis::Hysteresis( int32_t min_input, int32_t max_input ) +{ + this->min = min_input; + this->max = max_input; + this->last_value = 0; +} + +int32_t amakusa::Hysteresis::run(int32_t in_data) +{ + if ( in_data == this->last_value ) + ; // do nothing; + else + this->last_value = ( in_data + ROUND_OFFSET + ( in_data > this->last_value ? - 1 : 1 ) ) & 0xFFFFFFFC; + + if ( this->last_value > this->max ) + this->last_value = this->max; + else if ( this->last_value < this->min ) + this->last_value = this->min; + + return this->last_value; +} \ No newline at end of file