Basic Audio Signal Processing Library

Dependents:   unzen_sample_nucleo_f746 skeleton_unzen_nucleo_f746 ifmag_noise_canceller synthesizer_f746

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

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

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

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

hysteresis.cpp

Committer:
shorie
Date:
2017-02-18
Revision:
8:1fa224c83cfa
Parent:
3:a8dc30ed3e8a

File content as of revision 8:1fa224c83cfa:

#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;
}