|
|
|
@ -30,89 +30,93 @@ |
|
|
|
|
#include <SD.h> |
|
|
|
|
#include <MIDI.h> |
|
|
|
|
#include <EEPROM.h> |
|
|
|
|
#include "UI.hpp" |
|
|
|
|
#include "EEPROMAnything.h" |
|
|
|
|
#include "midi_devices.hpp" |
|
|
|
|
#include "dexed.h" |
|
|
|
|
#include "dexed_sysex.h" |
|
|
|
|
#include "effect_modulated_delay.h" |
|
|
|
|
#include "effect_stereo_mono.h" |
|
|
|
|
#include "PluginFx.h" |
|
|
|
|
#include "SoftenValue.hpp" |
|
|
|
|
#include "UI.hpp" |
|
|
|
|
|
|
|
|
|
AudioPlayQueue queue1; |
|
|
|
|
AudioAnalyzePeak peak1; |
|
|
|
|
AudioEffectDelay delay1; |
|
|
|
|
#ifdef USE_REVERB |
|
|
|
|
AudioEffectFreeverbStereo freeverbs1; |
|
|
|
|
#endif |
|
|
|
|
AudioEffectModulatedDelay modchorus; |
|
|
|
|
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
|
|
AudioFilterBiquad modchorus_filter; |
|
|
|
|
#endif |
|
|
|
|
AudioSynthWaveform modulator; |
|
|
|
|
AudioMixer4 chorus_mixer; |
|
|
|
|
AudioMixer4 delay_mixer; |
|
|
|
|
AudioMixer4 delay_fb_mixer; |
|
|
|
|
AudioMixer4 reverb_mixer_r; |
|
|
|
|
AudioMixer4 reverb_mixer_l; |
|
|
|
|
AudioMixer4 master_mixer_r; |
|
|
|
|
AudioMixer4 master_mixer_l; |
|
|
|
|
AudioAmplifier volume_r; |
|
|
|
|
AudioAmplifier volume_l; |
|
|
|
|
#if defined(AUDIO_DEVICE_USB) |
|
|
|
|
AudioOutputUSB usb1; |
|
|
|
|
#endif |
|
|
|
|
AudioEffectStereoMono stereomono1; |
|
|
|
|
AudioConnection patchCord0(queue1, peak1); |
|
|
|
|
AudioConnection patchCord1(queue1, 0, chorus_mixer, 0); |
|
|
|
|
AudioConnection patchCord3(queue1, 0, delay_mixer, 0); |
|
|
|
|
AudioConnection patchCord4(queue1, 0, delay_fb_mixer, 0); |
|
|
|
|
#ifdef USE_REVERB |
|
|
|
|
AudioConnection patchCord5(queue1, 0, reverb_mixer_r, 0); |
|
|
|
|
AudioConnection patchCord6(queue1, 0, reverb_mixer_l, 0); |
|
|
|
|
#endif |
|
|
|
|
AudioConnection patchCord7(queue1, 0, modchorus, 0); |
|
|
|
|
AudioConnection patchCord8(modulator, 0, modchorus, 1); |
|
|
|
|
AudioConnection patchCord1(queue1, 0, delay_fb_mixer, 0); |
|
|
|
|
AudioConnection patchCord2(queue1, 0, modchorus, 0); |
|
|
|
|
AudioConnection patchCord3(queue1, 0 , master_mixer_r, 0); |
|
|
|
|
AudioConnection patchCord4(queue1, 0 , master_mixer_l, 0); |
|
|
|
|
AudioConnection patchCord5(modulator, 0, modchorus, 1); |
|
|
|
|
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
|
|
AudioConnection patchCord9(modchorus, modchorus_filter); |
|
|
|
|
AudioConnection patchCord10(modchorus_filter, 0, chorus_mixer, 1); |
|
|
|
|
#else |
|
|
|
|
AudioConnection patchCord9(modchorus, 0, chorus_mixer, 1); |
|
|
|
|
#endif |
|
|
|
|
AudioConnection patchCord11(chorus_mixer, 0, delay_mixer, 1); |
|
|
|
|
AudioConnection patchCord12(delay_fb_mixer, 0, delay_mixer, 1); |
|
|
|
|
AudioConnection patchCord13(delay_mixer, 0, reverb_mixer_r, 0); |
|
|
|
|
AudioConnection patchCord14(delay_mixer, 0, reverb_mixer_l, 0); |
|
|
|
|
AudioConnection patchCord15(delay1, 0, delay_mixer, 2); |
|
|
|
|
AudioConnection patchCord16(delay_fb_mixer, delay1); |
|
|
|
|
#ifdef USE_REVERB |
|
|
|
|
AudioConnection patchCord17(delay_mixer, 0, freeverbs1, 0); |
|
|
|
|
AudioConnection patchCord18(delay_mixer, 0, freeverbs1, 1); |
|
|
|
|
AudioConnection patchCord19(freeverbs1, 0, reverb_mixer_r, 1); |
|
|
|
|
AudioConnection patchCord20(freeverbs1, 1, reverb_mixer_l, 1); |
|
|
|
|
AudioConnection patchCord21(reverb_mixer_r, volume_r); |
|
|
|
|
AudioConnection patchCord22(reverb_mixer_l, volume_l); |
|
|
|
|
AudioFilterBiquad modchorus_filter; |
|
|
|
|
AudioConnection patchCord6(modchorus, modchorus_filter); |
|
|
|
|
AudioConnection patchCord7(modchorus_filter, 0, master_mixer_r, 3); |
|
|
|
|
AudioConnection patchCord8(modchorus_filter, 0, master_mixer_l, 3); |
|
|
|
|
#else |
|
|
|
|
AudioConnection patchCord17(delay_mixer, volume_r); |
|
|
|
|
AudioConnection patchCord18(delay_mixer, volume_l); |
|
|
|
|
AudioConnection patchCord9(modchorus, 0, master_mixer_r, 3); |
|
|
|
|
AudioConnection patchCord10(modchorus, 0, master_mixer_l, 3); |
|
|
|
|
#endif |
|
|
|
|
#if defined(AUDIO_DEVICE_USB) |
|
|
|
|
AudioConnection patchCord23(volume_r, 0, usb1, 0); |
|
|
|
|
AudioConnection patchCord24(volume_l, 0, usb1, 1); |
|
|
|
|
#if defined(USE_REVERB) |
|
|
|
|
AudioEffectFreeverbStereo freeverbs1; |
|
|
|
|
AudioConnection patchCord11(queue1, 0, freeverbs1, 0); |
|
|
|
|
AudioConnection patchCord12(queue1, 0, freeverbs1, 1); |
|
|
|
|
AudioConnection patchCord13(freeverbs1, 0, master_mixer_r, 1); |
|
|
|
|
AudioConnection patchCord14(freeverbs1, 1, master_mixer_l, 1); |
|
|
|
|
#endif |
|
|
|
|
#if defined(TEENSY_AUDIO_BOARD) || defined (I2S_AUDIO_ONLY) |
|
|
|
|
AudioOutputI2S i2s1; |
|
|
|
|
AudioConnection patchCord25(volume_r, 0, i2s1, 0); |
|
|
|
|
AudioConnection patchCord26(volume_l, 0, i2s1, 1); |
|
|
|
|
AudioConnection patchCord15(delay_fb_mixer, delay1); |
|
|
|
|
AudioConnection patchCord16(delay1, 0, delay_fb_mixer, 1); |
|
|
|
|
AudioConnection patchCord17(delay1, 0, master_mixer_r, 2); |
|
|
|
|
AudioConnection patchCord18(delay1, 0, master_mixer_l, 2); |
|
|
|
|
AudioConnection patchCord19(master_mixer_r, volume_r); |
|
|
|
|
AudioConnection patchCord20(master_mixer_l, volume_l); |
|
|
|
|
|
|
|
|
|
AudioConnection patchCord21(volume_r, 0, stereomono1, 0); |
|
|
|
|
AudioConnection patchCord22(volume_l, 0, stereomono1, 1); |
|
|
|
|
#ifdef AUDIO_DEVICE_USB |
|
|
|
|
AudioConnection patchCord23(stereomono1, 0, usb1, 0); |
|
|
|
|
AudioConnection patchCord24(stereomono1, 1, usb1, 1); |
|
|
|
|
#endif |
|
|
|
|
#if defined(TEENSY_AUDIO_BOARD) |
|
|
|
|
AudioOutputI2S i2s1; |
|
|
|
|
AudioConnection patchCord25(stereomono1, 0, i2s1, 0); |
|
|
|
|
AudioConnection patchCord26(stereomono1, 0, i2s1, 1); |
|
|
|
|
AudioControlSGTL5000 sgtl5000_1; |
|
|
|
|
#elif defined (I2S_AUDIO_ONLY) |
|
|
|
|
AudioOutputI2S i2s1; |
|
|
|
|
AudioConnection patchCord27(stereomono1, 0, i2s1, 0); |
|
|
|
|
AudioConnection patchCord28(stereomono1, 0, i2s1, 1); |
|
|
|
|
#elif defined(TGA_AUDIO_BOARD) |
|
|
|
|
AudioOutputI2S i2s1; |
|
|
|
|
AudioConnection patchCord27(volume_r, 0, i2s1, 0); |
|
|
|
|
AudioConnection patchCord28(volume_l, 0, i2s1, 1); |
|
|
|
|
AudioConnection patchCord29(stereomono1, 0, i2s1, 0); |
|
|
|
|
AudioConnection patchCord30(stereomono1, 1, i2s1, 1); |
|
|
|
|
AudioControlWM8731master wm8731_1; |
|
|
|
|
#elif !defined(I2S_AUDIO_ONLY) |
|
|
|
|
#elif defined(PT8211_AUDIO) |
|
|
|
|
AudioOutputPT8211 pt8211_1; |
|
|
|
|
AudioConnection patchCord29(volume_r, 0, pt8211_1, 0); |
|
|
|
|
AudioConnection patchCord30(volume_l, 0, pt8211_1, 1); |
|
|
|
|
AudioConnection patchCord31(stereomono1, 0, pt8211_1, 0); |
|
|
|
|
AudioConnection patchCord32(stereomono1, 1, pt8211_1, 1); |
|
|
|
|
#elif defined(TEENSY_DAC_SYMMETRIC) |
|
|
|
|
AudioOutputAnalogStereo dacOut; |
|
|
|
|
AudioMixer4 invMixer; |
|
|
|
|
AudioConnection patchCord33(stereomono1, 0, dacOut , 0); |
|
|
|
|
AudioConnection patchCord34(stereomono1, 1, invMixer, 0); |
|
|
|
|
AudioConnection patchCord35(invMixer, 0, dacOut , 1); |
|
|
|
|
#else |
|
|
|
|
AudioOutputAnalogStereo dacOut; |
|
|
|
|
AudioConnection patchCord36(stereomono1, 0, dacOut, 0); |
|
|
|
|
AudioConnection patchCord37(stereomono1, 1, dacOut, 1); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
Dexed* MicroDexed[NUM_DEXED]; |
|
|
|
@ -132,26 +136,35 @@ uint8_t midi_timing_counter = 0; // 24 per qarter |
|
|
|
|
elapsedMillis midi_timing_timestep; |
|
|
|
|
uint16_t midi_timing_quarter = 0; |
|
|
|
|
elapsedMillis long_button_pressed; |
|
|
|
|
//SoftenValue <uint8_t> effect_filter_volume[NUM_DEXED](SOFTEN_VALUE_CHANGE_STEPS);
|
|
|
|
|
//SoftenValue <uint8_t> soften_filter_res[NUM_DEXED](SOFTEN_VALUE_CHANGE_STEPS);
|
|
|
|
|
//SoftenValue <uint8_t> soften_filter_cut[NUM_DEXED](SOFTEN_VALUE_CHANGE_STEPS);
|
|
|
|
|
uint8_t effect_filter_cutoff = 0; |
|
|
|
|
uint8_t effect_filter_resonance = 0; |
|
|
|
|
uint8_t effect_delay_time = 0; |
|
|
|
|
uint8_t effect_delay_feedback = 0; |
|
|
|
|
uint8_t effect_delay_volume = 0; |
|
|
|
|
bool effect_delay_sync = 0; |
|
|
|
|
SoftenValue <uint8_t> soften_volume; |
|
|
|
|
SoftenValue <uint8_t> soften_filter_res[NUM_DEXED]; |
|
|
|
|
SoftenValue <uint8_t> soften_filter_cut[NUM_DEXED]; |
|
|
|
|
elapsedMicros fill_audio_buffer; |
|
|
|
|
elapsedMillis control_rate; |
|
|
|
|
uint8_t active_voices = 0; |
|
|
|
|
#ifdef SHOW_CPU_LOAD_MSEC |
|
|
|
|
elapsedMillis cpu_mem_millis; |
|
|
|
|
#endif |
|
|
|
|
config_t configuration = {0xffff, 0, 0, VOLUME, 0.5f, 0, DEFAULT_MIDI_CHANNEL}; |
|
|
|
|
config_t configuration = { |
|
|
|
|
0xffff, |
|
|
|
|
SYSEXBANK_DEFAULT, |
|
|
|
|
SYSEXSOUND_DEFAULT, |
|
|
|
|
VOLUME_DEFAULT, |
|
|
|
|
PANORAMA_DEFAULT, // pan
|
|
|
|
|
MONO_DEFAULT, // mono
|
|
|
|
|
DEFAULT_MIDI_CHANNEL, |
|
|
|
|
REVERB_ROOMSIZE_DEFAULT, |
|
|
|
|
REVERB_DAMPING_DEFAULT, |
|
|
|
|
REVERB_LEVEL_DEFAULT, |
|
|
|
|
CHORUS_FREQUENCY_DEFAULT, |
|
|
|
|
CHORUS_WAVEFORM_DEFAULT, |
|
|
|
|
CHORUS_DEPTH_DEFAULT, |
|
|
|
|
CHORUS_LEVEL_DEFAULT, |
|
|
|
|
FILTER_CUTOFF_DEFAULT, |
|
|
|
|
FILTER_RESONANCE_DEFAULT, |
|
|
|
|
LOUDNESS_DEFAULT |
|
|
|
|
}; |
|
|
|
|
bool eeprom_update_flag = false; |
|
|
|
|
value_change_t soften_volume = {0.0, 0}; |
|
|
|
|
value_change_t soften_filter_res = {0.0, 0}; |
|
|
|
|
value_change_t soften_filter_cut = {0.0, 0}; |
|
|
|
|
|
|
|
|
|
// Allocate the delay lines for left and right channels
|
|
|
|
|
short delayline[MOD_DELAY_SAMPLE_BUFFER]; |
|
|
|
@ -211,7 +224,7 @@ void setup() |
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
|
|
|
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
|
#if defined(TEENSY_AUDIO_BOARD) |
|
|
|
|
sgtl5000_1.enable(); |
|
|
|
|
sgtl5000_1.dacVolumeRamp(); |
|
|
|
|
//sgtl5000_1.dacVolumeRampLinear();
|
|
|
|
@ -246,8 +259,13 @@ void setup() |
|
|
|
|
Serial.println(F("TGA board enabled.")); |
|
|
|
|
#elif defined(I2S_AUDIO_ONLY) |
|
|
|
|
Serial.println(F("I2S enabled.")); |
|
|
|
|
#else |
|
|
|
|
#elif defined(PT8211_AUDIO) |
|
|
|
|
Serial.println(F("PT8211 enabled.")); |
|
|
|
|
#elif defined(TEENSY_DAC_SYMMETRIC) |
|
|
|
|
invMixer.gain(0, -1.f); |
|
|
|
|
Serial.println(F("Internal DAC using symmetric outputs enabled.")); |
|
|
|
|
#else |
|
|
|
|
Serial.println(F("Internal DAC enabled.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// start SD card
|
|
|
|
@ -309,6 +327,21 @@ void setup() |
|
|
|
|
Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC); |
|
|
|
|
Serial.println(F(" samples")); |
|
|
|
|
#endif |
|
|
|
|
master_mixer_r.gain(0, 1.0); |
|
|
|
|
master_mixer_l.gain(0, 1.0); |
|
|
|
|
|
|
|
|
|
freeverbs1.roomsize(configuration.reverb_roomsize / 100.0); |
|
|
|
|
freeverbs1.damping(configuration.reverb_damping / 100.0); |
|
|
|
|
master_mixer_r.gain(1, 0.0); |
|
|
|
|
master_mixer_l.gain(1, 0.0); |
|
|
|
|
|
|
|
|
|
delay1.delay(0, 0.0); |
|
|
|
|
// delay_fb_mixer is the feedback-adding mixer
|
|
|
|
|
delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signal
|
|
|
|
|
delay_fb_mixer.gain(1, configuration.delay_feedback / 100.0); // amount of feedback
|
|
|
|
|
master_mixer_r.gain(2, 0.0); |
|
|
|
|
master_mixer_l.gain(2, 0.0); |
|
|
|
|
|
|
|
|
|
modulator.begin(MOD_WAVEFORM); |
|
|
|
|
modulator.phase(0); |
|
|
|
|
modulator.amplitude(0.5); |
|
|
|
@ -327,32 +360,21 @@ void setup() |
|
|
|
|
modchorus_filter.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54); |
|
|
|
|
modchorus_filter.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
chorus_mixer.gain(0, 1.0); |
|
|
|
|
chorus_mixer.gain(1, 0.0); |
|
|
|
|
|
|
|
|
|
delay1.delay(0, mapfloat(effect_delay_feedback, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME)); |
|
|
|
|
// delay_fb_mixer is the feedback-adding mixer, delay_mixer_r the whole delay (with/without feedback) mixer
|
|
|
|
|
delay_fb_mixer.gain(0, 1.0); // original signal
|
|
|
|
|
delay_fb_mixer.gain(1, mapfloat(effect_delay_feedback, 0, ENC_DELAY_FB_STEPS, 0.0, 1.0)); // amount of feedback
|
|
|
|
|
delay_mixer.gain(0, 1.0 - mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // original signal
|
|
|
|
|
delay_mixer.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delayed signal (including feedback)
|
|
|
|
|
delay_mixer.gain(2, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // only delayed signal (without feedback)
|
|
|
|
|
|
|
|
|
|
reverb_mixer_r.gain(0, 1.0); |
|
|
|
|
reverb_mixer_l.gain(0, 1.0); |
|
|
|
|
reverb_mixer_r.gain(1, 0.0); |
|
|
|
|
reverb_mixer_l.gain(1, 0.0); |
|
|
|
|
master_mixer_r.gain(3, 0.0); |
|
|
|
|
master_mixer_l.gain(3, 0.0); |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
soften_filter_res[i].init(1.0, 0.0, 1.0); |
|
|
|
|
soften_filter_cut[i].init(1.0, 0.0, 1.0); |
|
|
|
|
MicroDexed[i]->fx.Gain = 1.0; |
|
|
|
|
MicroDexed[i]->fx.Reso = 1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS; |
|
|
|
|
MicroDexed[i]->fx.Cutoff = 1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS; |
|
|
|
|
MicroDexed[i]->fx.Reso = 1.0; |
|
|
|
|
MicroDexed[i]->fx.Cutoff = 1.0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// set initial volume and pan (read from EEPROM)
|
|
|
|
|
set_volume(configuration.vol, configuration.pan); |
|
|
|
|
soften_volume.init(configuration.vol, VOLUME_MIN, VOLUME_MAX); |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
@ -412,10 +434,6 @@ void loop() |
|
|
|
|
if (peak1.read() > 0.99) |
|
|
|
|
peak++; |
|
|
|
|
} |
|
|
|
|
#ifndef TEENSY_AUDIO_BOARD |
|
|
|
|
for (uint8_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
|
audio_buffer[i] *= configuration.vol; |
|
|
|
|
#endif |
|
|
|
|
queue1.playBuffer(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -445,62 +463,56 @@ void loop() |
|
|
|
|
#endif |
|
|
|
|
control_rate = 0; |
|
|
|
|
|
|
|
|
|
// Shutdown unused voices
|
|
|
|
|
// check for value changes and unused voices
|
|
|
|
|
soften_volume.tick(); |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
active_voices = MicroDexed[i]->getNumNotesPlaying(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// check for value changes
|
|
|
|
|
if (soften_volume.steps > 0) |
|
|
|
|
{ |
|
|
|
|
// soften volume value
|
|
|
|
|
soften_volume.steps--; |
|
|
|
|
set_volume(configuration.vol + soften_volume.diff, configuration.pan); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Volume: ")); |
|
|
|
|
Serial.print(configuration.vol, 5); |
|
|
|
|
Serial.print(F(" Volume step: ")); |
|
|
|
|
Serial.print(soften_volume.steps); |
|
|
|
|
Serial.print(F(" Volume diff: ")); |
|
|
|
|
Serial.println(soften_volume.diff, 5); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
if (soften_filter_res.steps > 0) |
|
|
|
|
soften_filter_res[i].tick(); |
|
|
|
|
soften_filter_cut[i].tick(); |
|
|
|
|
|
|
|
|
|
if (soften_filter_res[i].running()) |
|
|
|
|
{ |
|
|
|
|
// soften filter resonance value
|
|
|
|
|
soften_filter_res.steps--; |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->fx.Reso = MicroDexed[i]->fx.Reso + soften_filter_res.diff; |
|
|
|
|
MicroDexed[i]->fx.Reso = soften_filter_res[i].value(); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Filter-Resonance: ")); |
|
|
|
|
Serial.print(MicroDexed[i]->fx.Reso, 5); |
|
|
|
|
Serial.print(F(" Filter-Resonance step: ")); |
|
|
|
|
Serial.print(soften_filter_res.steps); |
|
|
|
|
Serial.print(soften_filter_res[i].steps()); |
|
|
|
|
Serial.print(F(" Filter-Resonance diff: ")); |
|
|
|
|
Serial.println(soften_filter_res.diff, 5); |
|
|
|
|
Serial.println(soften_filter_res[i].diff(), 5); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (soften_filter_cut.steps > 0) |
|
|
|
|
{ |
|
|
|
|
// soften filter cutoff value
|
|
|
|
|
soften_filter_cut.steps--; |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
if (soften_filter_cut[i].running()) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->fx.Cutoff = MicroDexed[i]->fx.Cutoff + soften_filter_cut.diff; |
|
|
|
|
MicroDexed[i]->fx.Cutoff = soften_filter_cut[i].value(); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Filter-Cutoff: ")); |
|
|
|
|
Serial.print(MicroDexed[i]->fx.Cutoff, 5); |
|
|
|
|
Serial.print(F(" Filter-Cutoff step: ")); |
|
|
|
|
Serial.print(soften_filter_cut.steps); |
|
|
|
|
Serial.print(soften_filter_cut[i].steps()); |
|
|
|
|
Serial.print(F(" Filter-Cutoff diff: ")); |
|
|
|
|
Serial.println(soften_filter_cut.diff, 5); |
|
|
|
|
Serial.println(soften_filter_cut[i].diff(), 5); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (soften_volume.running()) |
|
|
|
|
{ |
|
|
|
|
set_volume(soften_volume.value(), configuration.pan); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Volume: ")); |
|
|
|
|
Serial.print(configuration.vol, DEC); |
|
|
|
|
Serial.print(F(" step: ")); |
|
|
|
|
Serial.print(soften_volume.steps()); |
|
|
|
|
Serial.print(F(" diff: ")); |
|
|
|
|
Serial.println(soften_volume.diff(), 5); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
@ -551,73 +563,107 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
MicroDexed[0]->controllers.modwheel_cc = inValue; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.modwheel_cc = inValue; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
MicroDexed[0]->controllers.breath_cc = inValue; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.breath_cc = inValue; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
MicroDexed[0]->controllers.foot_cc = inValue; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.foot_cc = inValue; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 7: // Volume
|
|
|
|
|
configuration.vol = float(inValue) / 0x7f; |
|
|
|
|
set_volume(configuration.vol, configuration.pan); |
|
|
|
|
configuration.vol = map(inValue, 0, 0x7f, VOLUME_MIN, VOLUME_MAX); |
|
|
|
|
soften_volume.update(configuration.vol, SOFTEN_VALUE_CHANGE_STEPS); |
|
|
|
|
break; |
|
|
|
|
case 10: // Pan
|
|
|
|
|
configuration.pan = float(inValue) / 128; |
|
|
|
|
configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX); |
|
|
|
|
set_volume(configuration.vol, configuration.pan); |
|
|
|
|
break; |
|
|
|
|
case 32: // BankSelect LSB
|
|
|
|
|
configuration.bank = inValue; |
|
|
|
|
break; |
|
|
|
|
case 64: |
|
|
|
|
MicroDexed[0]->setSustain(inValue > 63); |
|
|
|
|
if (!MicroDexed[0]->getSustain()) { |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->setSustain(inValue > 63); |
|
|
|
|
if (!MicroDexed[i]->getSustain()) { |
|
|
|
|
for (uint8_t note = 0; note < MicroDexed[0]->getMaxNotes(); note++) { |
|
|
|
|
if (MicroDexed[0]->voices[note].sustained && !MicroDexed[0]->voices[note].keydown) { |
|
|
|
|
MicroDexed[0]->voices[note].dx7_note->keyup(); |
|
|
|
|
MicroDexed[0]->voices[note].sustained = false; |
|
|
|
|
if (MicroDexed[i]->voices[note].sustained && !MicroDexed[i]->voices[note].keydown) { |
|
|
|
|
MicroDexed[i]->voices[note].dx7_note->keyup(); |
|
|
|
|
MicroDexed[i]->voices[note].sustained = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 103: // CC 103: filter resonance
|
|
|
|
|
effect_filter_resonance = map(inValue, 0, 127, 0, ENC_FILTER_RES_STEPS); |
|
|
|
|
MicroDexed[0]->fx.Reso = 1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS; |
|
|
|
|
configuration.filter_resonance = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->fx.Reso = configuration.filter_resonance / 100.0; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 104: // CC 104: filter cutoff
|
|
|
|
|
effect_filter_cutoff = map(inValue, 0, 127, 0, ENC_FILTER_CUT_STEPS); |
|
|
|
|
MicroDexed[0]->fx.Cutoff = 1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS; |
|
|
|
|
configuration.filter_cutoff = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->fx.Cutoff = configuration.filter_cutoff / 100.0; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 105: // CC 105: delay time
|
|
|
|
|
effect_delay_time = map(inValue, 0, 127, 0, ENC_DELAY_TIME_STEPS); |
|
|
|
|
////delay.delay(0, mapfloat(effect_delay_time, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
|
|
|
|
|
break; |
|
|
|
|
configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX); |
|
|
|
|
delay1.delay(0, configuration.delay_time * 10); |
|
|
|
|
case 106: // CC 106: delay feedback
|
|
|
|
|
effect_delay_feedback = map(inValue, 0, 127, 0, ENC_DELAY_FB_STEPS); |
|
|
|
|
////delay_mixer_r.gain(1, mapfloat(float(effect_delay_feedback), 0, ENC_DELAY_FB_STEPS, 0.0, 1.0));
|
|
|
|
|
configuration.delay_feedback = map(inValue, 0, 0x7f, DELAY_FEEDBACK_MIN , DELAY_FEEDBACK_MAX); |
|
|
|
|
delay_fb_mixer.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback
|
|
|
|
|
delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signalbreak;
|
|
|
|
|
break; |
|
|
|
|
case 107: // CC 107: delay volume
|
|
|
|
|
effect_delay_volume = map(inValue, 0, 127, 0, ENC_DELAY_VOLUME_STEPS); |
|
|
|
|
////delay_mixer_l.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delay tap1 signal (with added feedback)
|
|
|
|
|
configuration.delay_level = map(inValue, 0, 0x7f, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); |
|
|
|
|
master_mixer_r.gain(2, configuration.delay_level / 100.0); |
|
|
|
|
master_mixer_l.gain(2, configuration.delay_level / 100.0); |
|
|
|
|
break; |
|
|
|
|
case 120: |
|
|
|
|
MicroDexed[0]->panic(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->panic(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 121: |
|
|
|
|
MicroDexed[0]->resetControllers(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->resetControllers(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 123: |
|
|
|
|
MicroDexed[0]->notesOff(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->notesOff(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 126: |
|
|
|
|
MicroDexed[0]->setMonoMode(true); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->setMonoMode(true); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 127: |
|
|
|
|
MicroDexed[0]->setMonoMode(false); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->setMonoMode(false); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -625,13 +671,19 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) |
|
|
|
|
|
|
|
|
|
void handleAfterTouch(byte inChannel, byte inPressure) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[0]->controllers.aftertouch_cc = inPressure; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.aftertouch_cc = inPressure; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void handlePitchBend(byte inChannel, int inPitch) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[0]->controllers.values_[kControllerPitch] = inPitch + 0x2000; // -8192 to +8191 --> 0 to 16383
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.values_[kControllerPitch] = inPitch + 0x2000; // -8192 to +8191 --> 0 to 16383
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void handleProgramChange(byte inChannel, byte inProgram) |
|
|
|
@ -928,19 +980,23 @@ bool checkMidiChannel(byte inChannel) |
|
|
|
|
VOLUME HELPER |
|
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
void set_volume(float v, float p) |
|
|
|
|
void set_volume(uint8_t v, int8_t p) |
|
|
|
|
{ |
|
|
|
|
configuration.vol = v; |
|
|
|
|
configuration.pan = p; |
|
|
|
|
|
|
|
|
|
MicroDexed[0]->fx.Gain = v; |
|
|
|
|
|
|
|
|
|
uint16_t tmp = v * 1023.0 + 0.5; |
|
|
|
|
float tmp2 = configuration.pan; |
|
|
|
|
uint16_t tmp = v / 100.0 * 1023.0 + 0.5; |
|
|
|
|
float tmp2 = mapfloat(configuration.pan, PANORAMA_MIN, PANORAMA_MAX, 0.0, 1.0); |
|
|
|
|
float tmp3 = (float)(tmp * (tmp + 2)) / (float)(1 << 20); |
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
|
|
|
|
|
// float v = (float)(a * (a + 2))/(float)(1 << 20); // (pseudo-) logarithmic curve for volume control
|
|
|
|
|
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
|
|
|
|
|
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2)); |
|
|
|
|
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2)); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Setting volume: VOL=")); |
|
|
|
|
Serial.print(value, DEC); |
|
|
|
|
Serial.print(configuration.vol, DEC); |
|
|
|
|
Serial.print(F("[")); |
|
|
|
|
Serial.print(tmp3, 3); |
|
|
|
|
Serial.print(F("] PAN=")); |
|
|
|
@ -953,15 +1009,21 @@ void set_volume(float v, float p) |
|
|
|
|
Serial.println(tmp3 * cosf(tmp2 * PI / 2), 3); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// float v = (float)(a * (a + 2))/(float)(1 << 20); // (pseudo-) logarithmic curve for volume control
|
|
|
|
|
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
|
|
|
|
|
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2)); |
|
|
|
|
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2)); |
|
|
|
|
|
|
|
|
|
if (configuration.mono == 2) |
|
|
|
|
{ |
|
|
|
|
volume_r.gain(1.0); |
|
|
|
|
volume_l.gain(0.0); |
|
|
|
|
} |
|
|
|
|
else if (configuration.mono == 3) |
|
|
|
|
{ |
|
|
|
|
volume_r.gain(0.0); |
|
|
|
|
volume_l.gain(1.0); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
volume_r.gain(1.0); |
|
|
|
|
volume_l.gain(1.0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// https://www.dr-lex.be/info-stuff/volumecontrols.html#table1
|
|
|
|
@ -1005,10 +1067,8 @@ void initial_values_from_eeprom(void) |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (configuration.vol > 1.0) |
|
|
|
|
configuration.vol = 1.0; |
|
|
|
|
else if (configuration.vol < 0.0) |
|
|
|
|
configuration.vol = 0.0; |
|
|
|
|
if (configuration.vol > 100) |
|
|
|
|
configuration.vol = 100; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void eeprom_write(void) |
|
|
|
|