|
|
@ -136,18 +136,18 @@ AudioConnection patchCord13(stereo2mono, 1, dacOut, 1); |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Dynamic patching of MicroDexed objects
|
|
|
|
// Dynamic patching of MicroDexed objects
|
|
|
|
//
|
|
|
|
//
|
|
|
|
uint8_t nDynamic = 0; |
|
|
|
uint16_t nDynamic = 0; |
|
|
|
#if defined(USE_FX) && MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
|
#if defined(USE_FX) && MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT |
|
|
|
AudioConnection * dynamicConnections[NUM_DEXED * 17]; |
|
|
|
AudioConnection * dynamicConnections[NUM_DEXED * 18]; |
|
|
|
#elif defined(USE_FX) && MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT |
|
|
|
#elif defined(USE_FX) && MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT |
|
|
|
AudioConnection * dynamicConnections[NUM_DEXED * 16]; |
|
|
|
AudioConnection * dynamicConnections[NUM_DEXED * 17]; |
|
|
|
#else |
|
|
|
#else |
|
|
|
AudioConnection * dynamicConnections[NUM_DEXED * 5]; |
|
|
|
AudioConnection * dynamicConnections[NUM_DEXED * 6]; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE); |
|
|
|
MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE); |
|
|
|
dexed_dynamic[instance_id] = new AudioEffectDynamics; |
|
|
|
dexed_dynamic[instance_id] = new AudioEffectDynamics(); |
|
|
|
dexed_level[instance_id] = new AudioAmplifier(); |
|
|
|
dexed_level[instance_id] = new AudioAmplifier(); |
|
|
|
mono2stereo[instance_id] = new AudioEffectMonoStereo(); |
|
|
|
mono2stereo[instance_id] = new AudioEffectMonoStereo(); |
|
|
|
#if defined(USE_FX) |
|
|
|
#if defined(USE_FX) |
|
|
@ -183,13 +183,11 @@ void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*delay_mixer[instance_id], 0, *mono2stereo[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*delay_mixer[instance_id], 0, *mono2stereo[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, reverb_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, reverb_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, reverb_mixer_l, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, reverb_mixer_l, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id); |
|
|
|
|
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id); |
|
|
|
|
|
|
|
#else |
|
|
|
#else |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*dexed_level[instance_id], 0, *mono2stereo[instance_id], 0); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*dexed_level[instance_id], 0, *mono2stereo[instance_id], 0); |
|
|
|
|
|
|
|
#endif |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 0, master_mixer_r, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id); |
|
|
|
dynamicConnections[nDynamic++] = new AudioConnection(*mono2stereo[instance_id], 1, master_mixer_l, instance_id); |
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint8_t sd_card = 0; |
|
|
|
uint8_t sd_card = 0; |
|
|
@ -286,28 +284,6 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
setup_midi_devices(); |
|
|
|
setup_midi_devices(); |
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (instance_id < MAX_DEXED) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Creating MicroDexed instance ")); |
|
|
|
|
|
|
|
Serial.println(instance_id, DEC); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
create_audio_engine_chain(instance_id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Ignoring instance ")); |
|
|
|
|
|
|
|
Serial.print(instance_id, DEC); |
|
|
|
|
|
|
|
Serial.print(F(" (maximum allowed: ")); |
|
|
|
|
|
|
|
Serial.print(MAX_DEXED, DEC); |
|
|
|
|
|
|
|
Serial.println(F(")")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(TEENSY_AUDIO_BOARD) |
|
|
|
#if defined(TEENSY_AUDIO_BOARD) |
|
|
|
sgtl5000_1.enable(); |
|
|
|
sgtl5000_1.enable(); |
|
|
|
sgtl5000_1.lineOutLevel(SGTL5000_LINEOUT_LEVEL); |
|
|
|
sgtl5000_1.lineOutLevel(SGTL5000_LINEOUT_LEVEL); |
|
|
@ -370,6 +346,16 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create dynamic Dexed instances
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Creating MicroDexed instance ")); |
|
|
|
|
|
|
|
Serial.println(instance_id, DEC); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
create_audio_engine_chain(instance_id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if defined(USE_FX) |
|
|
|
#if defined(USE_FX) |
|
|
|
// Init effects
|
|
|
|
// Init effects
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
@ -391,7 +377,7 @@ void setup() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if defined(REVERB_ANTIALIAS_FRQ) |
|
|
|
#if defined(USE_FX) && defined(REVERB_ANTIALIAS_FRQ) |
|
|
|
freeverb_antialias_r.setLowpass(0, REVERB_ANTIALIAS_FRQ, 0.54); |
|
|
|
freeverb_antialias_r.setLowpass(0, REVERB_ANTIALIAS_FRQ, 0.54); |
|
|
|
freeverb_antialias_r.setLowpass(1, REVERB_ANTIALIAS_FRQ, 1.3); |
|
|
|
freeverb_antialias_r.setLowpass(1, REVERB_ANTIALIAS_FRQ, 1.3); |
|
|
|
freeverb_antialias_r.setLowpass(2, REVERB_ANTIALIAS_FRQ, 0.54); |
|
|
|
freeverb_antialias_r.setLowpass(2, REVERB_ANTIALIAS_FRQ, 0.54); |
|
|
@ -451,8 +437,6 @@ void setup() |
|
|
|
Serial.println(F("]")); |
|
|
|
Serial.println(F("]")); |
|
|
|
Serial.print(F("Polyphony: ")); |
|
|
|
Serial.print(F("Polyphony: ")); |
|
|
|
Serial.println(configuration.dexed[instance_id].polyphony, DEC); |
|
|
|
Serial.println(configuration.dexed[instance_id].polyphony, DEC); |
|
|
|
|
|
|
|
|
|
|
|
dexed_dynamic[instance_id]->limit(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); |
|
|
|
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); |
|
|
@ -466,6 +450,32 @@ void setup() |
|
|
|
show_cpu_and_mem_usage(); |
|
|
|
show_cpu_and_mem_usage(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MicroDexed[instance_id]->fx.Gain = 1.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// init dynamics for dexed
|
|
|
|
|
|
|
|
dexed_dynamic[instance_id]->limit(); |
|
|
|
|
|
|
|
//dexed_dynamic[instance_id]->autoMakeupGain();
|
|
|
|
|
|
|
|
//dexed_dynamic[instance_id]->compression();
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// init master_mixer
|
|
|
|
|
|
|
|
#if NUM_DEXED > 1 |
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//master_mixer_r.gain(instance_id, pseudo_log_curve(0.5));
|
|
|
|
|
|
|
|
//master_mixer_l.gain(instance_id, pseudo_log_curve(0.5));
|
|
|
|
|
|
|
|
master_mixer_r.gain(instance_id, 1.0); |
|
|
|
|
|
|
|
master_mixer_l.gain(instance_id, 1.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
master_mixer_r.gain(0, 1.0); |
|
|
|
|
|
|
|
master_mixer_l.gain(0, 1.0); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
master_mixer_r.gain(3, 0.0); |
|
|
|
|
|
|
|
master_mixer_l.gain(3, 0.0); |
|
|
|
|
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -699,7 +709,9 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) |
|
|
|
MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX); |
|
|
|
MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX); |
|
|
|
#else*/ |
|
|
|
#else*/ |
|
|
|
|
|
|
|
|
|
|
|
dexed_level[instance_id]->gain(pseudo_log_curve(mapfloat(map(inValue, 0, 0x7f, 0, configuration.dexed[instance_id].sound_intensity), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX))); |
|
|
|
// dexed_level[instance_id]->gain(pseudo_log_curve(mapfloat(map(inValue, 0, 0x7f, 0, configuration.dexed[instance_id].sound_intensity), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX))); // That's not right... have to fix this!
|
|
|
|
|
|
|
|
dexed_level[instance_id]->gain(mapfloat(map(inValue, 0, 0x7f, 0, configuration.dexed[instance_id].sound_intensity), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX)); |
|
|
|
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
//#endif
|
|
|
|
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sound_intensity)) |
|
|
|
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sound_intensity)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1762,8 +1774,7 @@ void set_fx_params(void) |
|
|
|
reverb_mixer_l.gain(instance_id, pseudo_log_curve(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0))); |
|
|
|
reverb_mixer_l.gain(instance_id, pseudo_log_curve(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0))); |
|
|
|
|
|
|
|
|
|
|
|
// DEXED FILTER
|
|
|
|
// DEXED FILTER
|
|
|
|
//MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX);
|
|
|
|
//MicroDexed[instance_id]->fx.Gain = 1.0;
|
|
|
|
MicroDexed[instance_id]->fx.Gain = 1.0; |
|
|
|
|
|
|
|
MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); |
|
|
|
MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); |
|
|
|
MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); |
|
|
|
MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); |
|
|
|
MicroDexed[instance_id]->doRefreshVoice(); |
|
|
|
MicroDexed[instance_id]->doRefreshVoice(); |
|
|
@ -1824,7 +1835,6 @@ void _softRestart(void) |
|
|
|
float pseudo_log_curve(float value) |
|
|
|
float pseudo_log_curve(float value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const float _pseudo_log = 1048575 / (float)(1 << 20); |
|
|
|
const float _pseudo_log = 1048575 / (float)(1 << 20); |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("value in: ")); |
|
|
|
Serial.print(F("value in: ")); |
|
|
@ -1834,7 +1844,14 @@ float pseudo_log_curve(float value) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
return (mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0)); |
|
|
|
// return (mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float g = mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (g == 0.0) |
|
|
|
|
|
|
|
return (0.001); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return (g); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc
|
|
|
|
uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc
|
|
|
|