Synthesizer based on the Unzen / Nucleo F746ZG
Dependencies: amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746
Fork of skeleton_unzen_nucleo_f746 by
雲仙フレームワークのテストとして作っているプロジェクトです。中身はどんどん変っていきます。 説明はDSP空挺団の「シンセサイザー」カテゴリーを参照してください。初回は「ドッグフードを食べる」です。
Diff: svfilter.cpp
- Revision:
- 22:dc2cbe8db9d9
- Parent:
- 21:dcfbe6d2a6d3
- Child:
- 25:d15dd7b9101c
--- a/svfilter.cpp Sat Feb 04 15:05:44 2017 +0000 +++ b/svfilter.cpp Sun Feb 05 06:16:49 2017 +0000 @@ -52,16 +52,32 @@ for ( int i= 0; i<blockSize; i++ ) { + // calc the filter bp = this->d1; lp = bp * this->f + this->d2; hp = pSrc[i] - this->q * bp - lp; + // update delay this->d1 += hp * this->f; this->d2 = lp; + + // mode dependent output + switch ( this->mode ) + { + case lpf : + pDst[i] = lp; + break; + case hpf : + pDst[i] = hp; + break; + case bpf : + pDst[i] = bp; + break; + }; } } - + // Q can be [0.1,inf] void SVFilter::set_Q( float32_t Q ) { if ( Q < 0.1f ) @@ -76,18 +92,19 @@ this->Fs = new_Fs; this->update_parameters(); } - + + // fc is control frequency. void SVFilter::set_fc( int new_fc ) // Hz { this->fc = new_fc; - this->f = 2.0f * sin( 3.141592f * this->fc / this->Fs ); + this->update_parameters(); } - + // fc * f_factor must be less then Fs/6 void SVFilter::set_f_factor( float32_t new_f_factor ) { this->f_factor = new_f_factor; - this->f = 2.0f * sin( 3.141592f * this->fc / this->Fs ); + this->update_parameters(); } void SVFilter::set_mode( svf_mode new_mode )