Synthesizer based on the Unzen / Nucleo F746ZG

Dependencies:   amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746

Fork of skeleton_unzen_nucleo_f746 by seiichi horie

雲仙フレームワークのテストとして作っているプロジェクトです。中身はどんどん変っていきます。 説明はDSP空挺団の「シンセサイザー」カテゴリーを参照してください。初回は「ドッグフードを食べる」です。

dcblocker.cpp

Committer:
shorie
Date:
2017-02-03
Revision:
19:f5e785fe50b1
Child:
25:d15dd7b9101c

File content as of revision 19:f5e785fe50b1:

#include "signal_processing.h"

/*
* Related Link
* https://www.dsprelated.com/freebooks/filters/DC_Blocker.html
* https://ccrma.stanford.edu/~jos/fp/DC_Blocker.html
*/

DCBlocker::DCBlocker(  uint32_t blockSize ) : amakusa::AbstractFilter ( blockSize )
{
    this->x_last = 0;
    this->y_last = 0;
}

void DCBlocker::run( float32_t *pSrc, float32_t *pDst, uint32_t blockSize )
{
        // if the parameter is non-zero, take it. If the parameter is zero, use default.
    if ( blockSize == 0 )
        blockSize = this->blockSize;
    
    for ( int i = 0; i < blockSize; i++ )
    {
            // y = x - x * z^-1 + 0.995 * y * z^-1
        pDst[ i ] = pSrc[ i ] - this->x_last + 0.995f * this->y_last;
        this->x_last = pSrc[ i ];
        this->y_last = pDst[ i ];
    }
    
}