diff --git a/UI.cpp b/UI.cpp index a1bfd2d..b5a10d0 100644 --- a/UI.cpp +++ b/UI.cpp @@ -292,57 +292,60 @@ void handle_ui(void) switch (ui_main_state) { case UI_MAIN_FILTER_FRQ: -/* if (enc[i].read() <= 0) + if (enc[i].read() <= 0) enc[i].write(0); else if (enc[i].read() > ENC_FILTER_FRQ_STEPS) enc[i].write(ENC_FILTER_FRQ_STEPS); effect_filter_frq = enc[i].read(); - if (effect_filter_frq == ENC_FILTER_FRQ_STEPS) - { + /* + if (effect_filter_frq == ENC_FILTER_FRQ_STEPS) + { // turn "off" filter mixer1.gain(0, 0.0); // filtered signal off mixer1.gain(3, 1.0); // original signal on - } - else - { + } + else + { // turn "on" filter mixer1.gain(0, 1.0); // filtered signal on mixer1.gain(3, 0.0); // original signal off - } - filter1.frequency(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0); -#ifdef DEBUG - Serial.print(F("Setting filter frequency to: ")); - Serial.println(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0, DEC); -#endif -*/ + } + filter1.frequency(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0); + #ifdef DEBUG + Serial.print(F("Setting filter frequency to: ")); + Serial.println(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0, DEC); + #endif + */ break; case UI_MAIN_FILTER_RES: -/* if (enc[i].read() <= 0) + if (enc[i].read() <= 0) enc[i].write(0); else if (enc[i].read() > ENC_FILTER_RES_STEPS) enc[i].write(ENC_FILTER_RES_STEPS); effect_filter_resonance = enc[i].read(); - //filter1.resonance(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)); - filter1.resonance(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61); - -#ifdef DEBUG - Serial.print(F("Setting filter resonance to: ")); - Serial.println(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61, 2); -#endif -*/ + /* + //filter1.resonance(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)); + filter1.resonance(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61); + + #ifdef DEBUG + Serial.print(F("Setting filter resonance to: ")); + Serial.println(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61, 2); + #endif + */ break; case UI_MAIN_FILTER_OCT: -/* if (enc[i].read() <= 0) + if (enc[i].read() <= 0) enc[i].write(0); else if (enc[i].read() > ENC_FILTER_OCT_STEPS) enc[i].write(ENC_FILTER_OCT_STEPS); effect_filter_octave = enc[i].read(); - filter1.octaveControl(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0)); -#ifdef DEBUG - Serial.print(F("Setting filter octave control to: ")); - Serial.println(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0), 2); -#endif -*/ + /* + filter1.octaveControl(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0)); + #ifdef DEBUG + Serial.print(F("Setting filter octave control to: ")); + Serial.println(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0), 2); + #endif + */ break; } ui_show_effects_filter(); diff --git a/dexed.cpp b/dexed.cpp index 7634fce..16a830d 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -152,7 +152,7 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer) int32_t clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9; #endif - float f = static_cast(clip_val >> REDUCE_LOUDNESS) / 0x8000; + float f = static_cast(clip_val >> REDUCE_LOUDNESS) / 0x7fff; if (f > 1.0) { f = 1.0; @@ -173,7 +173,7 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer) fx.process(sumbuf, n_samples); for (i = 0; i < n_samples; ++i) - buffer[i] = static_cast(sumbuf[i] * 0x8000); + buffer[i] = static_cast(sumbuf[i] * 0x7fff); } void Dexed::keydown(uint8_t pitch, uint8_t velo) {