不韋 呂
/
UIT2_ReverbCombClass
Reverb system using single comb filter class for ST Nucleo F401RE.
Diff: main.cpp
- Revision:
- 0:47e72130375e
- Child:
- 1:b3a60a05da72
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 31 07:37:36 2014 +0000 @@ -0,0 +1,44 @@ +//-------------------------------------------------------------- +// Reverb system using comb filter +// 2014/10/31, Copyright (c) 2014 MIKAMI, Naoki +//-------------------------------------------------------------- + +#include "mbed.h" + +#include "ADC_Base.hpp" // for ADC not using interrupt +#include "DAC_MCP4922.hpp" // for DAC MCP4922 +#include "ScfClockTim3.hpp" // for clock supplied to SCF + +#include "comb_filter.hpp" + +using namespace Mikami; + +const int FS_ = 12000; // Sampling frequency: 12 kHz +ADC_Base adc_(A0, FS_); // for AD +DAC_MCP4922 myDac_; // for DA + +const float G_C_ = 0.8f; +const float G0_ = 1.0f - G_C_; +CombFilter<1153> comb_(G_C_); + +DigitalIn sw_(D2, PullDown); + +int main() +{ + + + ScfClockTim3(500000); // cutoff frequency: 5 kHz + while (true) + { + float xn = adc_.Read(); // Read from A0 + //----------------------------------------------- + + float yn; + if (sw_.read() == 1) yn = comb_.Execute(G0_*xn); + else yn = xn; + + //----------------------------------------------- + myDac_.Write(yn); // Write to DAC + } +} +