Takahiro Tanaka
/
mbed_effector
Guitar Effector using "mbed application board".
Diff: main.cpp
- Revision:
- 3:1666e2d5bd46
- Parent:
- 2:25adc1277b3e
--- a/main.cpp Fri Sep 04 16:50:36 2015 +0000 +++ b/main.cpp Fri Sep 18 16:57:32 2015 +0000 @@ -1,10 +1,8 @@ //============================================================================= // @author vaifreak // @brief Guitar Effector for "mbed application board" -// https://developer.mbed.org/cookbook/mbed-application-board //============================================================================= #include "mbed.h" -#include "C12832.h" #include <new> #include <list> @@ -22,8 +20,8 @@ AnalogOut a_out(p18); AnalogIn a_in(p17); -Filter *filter_pre; -Filter *filter_post; +Filter *low_pass; +Filter *high_pass; Drive *drive; Delay *delay; @@ -67,18 +65,18 @@ set_new_handler(no_memory); // new handler function // create effect unit - filter_pre = new Filter(); - filter_post = new Filter(); + low_pass = new Filter( Filter::LPF ); + high_pass = new Filter( Filter::HPF ); drive = new Drive(); delay = new Delay(); // add to effect processing list - g_EffectList.push_back(filter_pre); - g_EffectList.push_back(filter_post); + g_EffectList.push_back(low_pass); + g_EffectList.push_back(high_pass); g_EffectList.push_back(drive); g_EffectList.push_back(delay); - menu.Init( g_sample_rate, filter_pre, filter_post, drive, delay ); + menu.Init( g_sample_rate, low_pass, high_pass, drive, delay ); process_ticker.attach( &process, 1.0/g_sample_rate ); menu_ticker.attach( &update_display, 0.1 ); @@ -95,24 +93,19 @@ void process() { float val = (a_in * 2.0f) - 1.0f; //convert [0.0 ~ 1.0] to [-1.0 ~ 1.0] - //val = val * 10.0f; //TEST: input gain - - level_meter.Update( fabsf(val) ); // LED level meter. - + val = val * menu.inputGain; + level_meter.Update( fabsf(val) ); // LED level meter.(for Input) //---- effect process ---- + list<EffectUnitBase*>::iterator it = g_EffectList.begin(); + while( it != g_EffectList.end() ) { - list<EffectUnitBase*>::iterator it = g_EffectList.begin(); - while( it != g_EffectList.end() ) - { - val = (*it)->Process( val ); - ++it; - } - - //master volume - val = val * menu.masterVolume; + val = (*it)->Process( val ); + ++it; } + val = val * menu.masterVolume; + //level_meter.Update( fabsf(val) ); // LED level meter.(for Output) val = (val + 1.0f) * 0.5f; //convert [-1.0 ~ 1.0] to [0.0 ~ 1.0] //clipping. just to be safe. @@ -120,7 +113,6 @@ else if(val < 0.0f) val =0.0f; a_out = val; - } //---------------------------------------------