Complete change of the audio chain.

Small fixes.
There is currently a problem with protamento glissando.
pull/32/head
Holger Wirtz 5 years ago
parent 89c13cfef3
commit 0d1b9bf51b
  1. 444
      MicroDexed.ino
  2. 95
      UI.hpp
  3. 13
      config.h
  4. 2
      dexed.cpp
  5. 6
      dx7note.cpp
  6. 17
      effect_mono_stereo.cpp
  7. 15
      effect_mono_stereo.h

@ -35,112 +35,154 @@
#include "dexed_sysex.h" #include "dexed_sysex.h"
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
#include "effect_mono_stereo.h"
#include "PluginFx.h" #include "PluginFx.h"
#include "UI.hpp" #include "UI.hpp"
#include "source_microdexed.h" #include "source_microdexed.h"
// Audio engines // Audio engines
AudioAnalyzePeak peak1;
AudioSourceMicroDexed* MicroDexed[NUM_DEXED]; AudioSourceMicroDexed* MicroDexed[NUM_DEXED];
AudioEffectDelay delay1; AudioEffectMonoStereo* mono2stereo[NUM_DEXED];
AudioEffectModulatedDelay modchorus; AudioSynthWaveformDc* pan[NUM_DEXED];
AudioSynthWaveform modulator;
AudioMixer4 chorus_mixer; // single used objects
AudioMixer4 delay_mixer; AudioAnalyzePeak microdexed_peak;
AudioMixer4 delay_fb_mixer; AudioMixer4 microdexed_peak_mixer;
AudioMixer4 master_mixer_r; AudioSynthWaveform chorus_modulator;
AudioMixer4 master_mixer_l;
AudioAmplifier volume_r;
AudioAmplifier volume_l;
AudioAmplifier modchorus_inverter; AudioAmplifier modchorus_inverter;
#if defined(AUDIO_DEVICE_USB)
AudioOutputUSB usb1; // FX chain left
AudioMixer4 chorus_send_mixer_l;
AudioMixer4 delay_send_mixer_l;
AudioMixer4 delay_fb_mixer_l;
AudioEffectDelay delay_l;
AudioConnection patchCord1(delay_send_mixer_l, 0, delay_fb_mixer_l, 0);
AudioConnection patchCord2(delay_fb_mixer_l, delay_l);
AudioConnection patchCord3(delay_l, 0, delay_fb_mixer_l, 1); // feedback-loop
AudioConnection patchCord4(delay_fb_mixer_l, 0, master_mixer_l, DELAY);
AudioEffectModulatedDelay modchorus_l;
AudioConnection patchCord5(chorus_modulator, 0, modchorus_l, 1);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioFilterBiquad modchorus_filter_l;
AudioConnection patchCord6(modchorus_l, modchorus_filter_l);
AudioConnection patchCord7(modchorus_filter_l, modchorus_inverter);
AudioConnection patchCord8(modchorus_inverter_l, 0, master_mixer_l, CHORUS );
#else
AudioConnection patchCord9(modchorus_l, modchorus_inverter);
AudioConnection patchCord10(modchorus_inverter, 0, master_mixer_l, CHORUS);
#endif
#if defined(USE_REVERB)
AudioMixer4 reverb_send_mixer_l;
AudioEffectFreeverb freeverb_l;
AudioConnection patchCord11(reverb_send_mixer_l, freeverb_l);
AudioConnection patchCord12(freeverb_l, 0, master_mixer_r, REVERB);
#endif #endif
AudioEffectStereoMono stereomono1;
// FX chain right
// Audio connections AudioMixer4 chorus_send_mixer_r;
AudioConnection patchCord1(modulator, 0, modchorus, 1); AudioMixer4 delay_send_mixer_r;
AudioConnection patchCord2(chorus_mixer, 0, modchorus, 0); AudioMixer4 delay_fb_mixer_r;
AudioConnection patchCord3(delay_mixer, 0, delay_fb_mixer, 0); AudioEffectDelay delay_r;
AudioConnection patchCord4(delay_fb_mixer, delay1); AudioConnection patchCord13(delay_send_mixer_r, 0, delay_fb_mixer_r, 0);
AudioConnection patchCord5(delay1, 0, delay_fb_mixer, 1); AudioConnection patchCord14(delay_fb_mixer_r, delay_r);
AudioConnection patchCord6(delay1, 0, master_mixer_r, 2); AudioConnection patchCord15(delay_r, 0, delay_fb_mixer_r, 1); // feedback-loop
AudioConnection patchCord7(delay1, 0, master_mixer_l, 2); AudioConnection patchCord16(delay_fb_mixer_r, 0, master_mixer_r, DELAY);
AudioConnection patchCord8(master_mixer_r, volume_r); AudioEffectModulatedDelay modchorus_r;
AudioConnection patchCord9(master_mixer_l, volume_l); AudioConnection patchCord17(chorus_modulator, 0, modchorus_r, 1);
AudioConnection patchCord10(volume_r, 0, stereomono1, 0);
AudioConnection patchCord11(volume_l, 0, stereomono1, 1);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioFilterBiquad modchorus_filter; AudioFilterBiquad modchorus_filter_r;
AudioConnection patchCord12(modchorus, modchorus_filter); AudioConnection patchCord18(modchorus_r, modchorus_filter_r);
AudioConnection patchCord13(modchorus_filter, 0, master_mixer_r, 3); AudioConnection patchCord19(modchorus_filter_r, 0, master_mixer_r, CHORUS );
AudioConnection patchCord14(modchorus_filter, modchorus_inverter);
AudioConnection patchCord15(modchorus_inverter, 0, master_mixer_l, 3);
#else #else
AudioConnection patchCord16(modchorus, 0, master_mixer_r, 3); AudioConnection patchCord20(modchorus_r, 0, master_mixer_r, CHORUS);
AudioConnection patchCord17(modchorus, modchorus_inverter);
AudioConnection patchCord18(modchorus_inverter, 0, master_mixer_l, 3);
#endif #endif
#if defined(USE_REVERB) #if defined(USE_REVERB)
AudioMixer4 reverb_mixer; AudioMixer4 reverb_send_mixer_r;
AudioEffectFreeverbStereo freeverbs1; AudioEffectFreeverb freeverb_r;
AudioConnection patchCord19(reverb_mixer, 0, freeverbs1, 0); AudioConnection patchCord21(reverb_send_mixer_r, freeverb_r);
AudioConnection patchCord20(freeverbs1, 0, master_mixer_r, 1); AudioConnection patchCord22(freeverb_r, 0, master_mixer_r, REVERB);
AudioConnection patchCord21(freeverbs1, 1, master_mixer_l, 1);
#endif #endif
// FX chain tail
AudioMixer4 microdexed_mixer_r;
AudioMixer4 microdexed_mixer_l;
AudioMixer4 master_mixer_r;
AudioMixer4 master_mixer_l;
AudioAmplifier volume_r;
AudioAmplifier volume_l;
AudioEffectStereoMono stereo2mono;
AudioAnalyzePeak master_peak_r;
AudioAnalyzePeak master_peak_l;
AudioConnection patchCord23(microdexed_mixer_r, 0, master_mixer_r, DEXED);
AudioConnection patchCord24(microdexed_mixer_l, 0, master_mixer_l, DEXED);
AudioConnection patchCord25(master_mixer_r, volume_r);
AudioConnection patchCord26(master_mixer_l, volume_l);
AudioConnection patchCord27(volume_r, 0, stereo2mono, 0);
AudioConnection patchCord28(volume_l, 0, stereo2mono, 1);
AudioConnection patchCord29(volume_r, master_peak_r);
AudioConnection patchCord30(volume_l, master_peak_l);
AudioConnection patchCord31(microdexed_peak_mixer, microdexed_peak);
// Outputs
#ifdef AUDIO_DEVICE_USB #ifdef AUDIO_DEVICE_USB
AudioConnection patchCord22(stereomono1, 0, usb1, 0); AudioOutputUSB usb1;
AudioConnection patchCord23(stereomono1, 1, usb1, 1); AudioConnection patchCord32(stereo2mono, 0, usb1, 0);
AudioConnection patchCord33(stereo2mono, 1, usb1, 1);
#endif #endif
#if defined(TEENSY_AUDIO_BOARD) #if defined(TEENSY_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord24(stereomono1, 0, i2s1, 0); AudioConnection patchCord34(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord25(stereomono1, 1, i2s1, 1); AudioConnection patchCord35(stereo2mono, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; AudioControlSGTL5000 sgtl5000_1;
#elif defined (I2S_AUDIO_ONLY) #elif defined (I2S_AUDIO_ONLY)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord26(stereomono1, 0, i2s1, 0); AudioConnection patchCord36(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord27(stereomono1, 1, i2s1, 1); AudioConnection patchCord37(stereo2mono, 1, i2s1, 1);
#elif defined(TGA_AUDIO_BOARD) #elif defined(TGA_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord28(stereomono1, 0, i2s1, 0); AudioConnection patchCord38(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord29(stereomono1, 1, i2s1, 1); AudioConnection patchCord39(stereo2mono, 1, i2s1, 1);
AudioControlWM8731master wm8731_1; AudioControlWM8731master wm8731_1;
#elif defined(PT8211_AUDIO) #elif defined(PT8211_AUDIO)
AudioOutputPT8211 pt8211_1; AudioOutputPT8211 pt8211_1;
AudioConnection patchCord30(stereomono1, 0, pt8211_1, 0); AudioConnection patchCord40(stereo2mono, 0, pt8211_1, 0);
AudioConnection patchCord31(stereomono1, 1, pt8211_1, 1); AudioConnection patchCord41(stereo2mono, 1, pt8211_1, 1);
#elif defined(TEENSY_DAC_SYMMETRIC) #elif defined(TEENSY_DAC_SYMMETRIC)
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioMixer4 invMixer; AudioMixer4 invMixer;
AudioConnection patchCord32(stereomono1, 0, dacOut , 0); AudioConnection patchCord42(stereo2mono, 0, dacOut , 0);
AudioConnection patchCord33(stereomono1, 1, invMixer, 0); AudioConnection patchCord43(stereo2mono, 1, invMixer, 0);
AudioConnection patchCord34(invMixer, 0, dacOut , 1); AudioConnection patchCord44(invMixer, 0, dacOut , 1);
#else #else
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioConnection patchCord35(stereomono1, 0, dacOut, 0); AudioConnection patchCord45(stereo2mono, 0, dacOut, 0);
AudioConnection patchCord36(stereomono1, 1, dacOut, 1); AudioConnection patchCord46(stereo2mono, 1, dacOut, 1);
#endif #endif
// //
// Dynamic patching // Dynamic patching of MicroDexed objects
// //
uint8_t nDynamic = 0; uint8_t nDynamic = 0;
#ifdef USE_REVERB #if defined(USE_REVERB)
AudioConnection * dynamicConnections[NUM_DEXED * 7]; AudioConnection * dynamicConnections[NUM_DEXED * 11];
#else #else
AudioConnection * dynamicConnections[NUM_DEXED * 6]; AudioConnection * dynamicConnections[NUM_DEXED * 9];
#endif #endif
void create_audio_connections(AudioSourceMicroDexed &d, uint8_t instance_id) void create_audio_connections(AudioSourceMicroDexed &dexed, AudioEffectMonoStereo &mono2stereo, AudioSynthWaveformDc &pan, uint8_t instance_id)
{ {
dynamicConnections[nDynamic++] = new AudioConnection(d, peak1); dynamicConnections[nDynamic++] = new AudioConnection(dexed, 0, microdexed_peak_mixer, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(dexed, 0, mono2stereo, 0);
dynamicConnections[nDynamic++] = new AudioConnection(pan, 0, mono2stereo, 1);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, microdexed_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, microdexed_mixer_l, instance_id);
#if defined(USE_REVERB) #if defined(USE_REVERB)
dynamicConnections[nDynamic++] = new AudioConnection(d, 0, reverb_mixer, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, reverb_send_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, reverb_send_mixer_l, instance_id);
#endif #endif
dynamicConnections[nDynamic++] = new AudioConnection(d, 0, delay_mixer, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, delay_send_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(d, 0, chorus_mixer, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, chorus_send_mixer_l, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(d, 0 , master_mixer_r, 0); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, delay_send_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(d, 0 , master_mixer_l, 0); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, chorus_send_mixer_l, instance_id);
} }
bool sd_card_available = false; bool sd_card_available = false;
@ -161,13 +203,17 @@ uint8_t active_voices = 0;
elapsedMillis cpu_mem_millis; elapsedMillis cpu_mem_millis;
#endif #endif
//uint32_t overload = 0; //uint32_t overload = 0;
uint32_t peak = 0; uint32_t peak_dexed = 0;
float peak_dexed_value = 0.0;
uint32_t peak_r = 0;
uint32_t peak_l = 0;
bool eeprom_update_flag = false; bool eeprom_update_flag = false;
config_t configuration; config_t configuration;
uint8_t selected_dexed_instance = 0; uint8_t selected_dexed_instance = 0;
// Allocate the delay lines for chorus // Allocate the delay lines for chorus
int16_t delayline[MOD_DELAY_SAMPLE_BUFFER]; int16_t delayline_r[MOD_DELAY_SAMPLE_BUFFER];
int16_t delayline_l[MOD_DELAY_SAMPLE_BUFFER];
#ifdef ENABLE_LCD_UI #ifdef ENABLE_LCD_UI
/*********************************************************************** /***********************************************************************
@ -217,14 +263,27 @@ void setup()
setup_midi_devices(); setup_midi_devices();
for (uint8_t i = 0; i < NUM_DEXED; i++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
if (instance_id < MAX_DEXED)
{ {
Serial.print(F("Creating MicroDexed instance ")); Serial.print(F("Creating MicroDexed instance "));
Serial.print(i, DEC); Serial.print(instance_id, DEC);
MicroDexed[i] = new AudioSourceMicroDexed(SAMPLE_RATE); MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE);
create_audio_connections(*MicroDexed[i], i); mono2stereo[instance_id] = new AudioEffectMonoStereo();
pan[instance_id] = new AudioSynthWaveformDc();
create_audio_connections(*MicroDexed[instance_id], *mono2stereo[instance_id], *pan[instance_id], instance_id);
Serial.println(F("... created")); Serial.println(F("... created"));
} }
else
{
Serial.print(F("Ignoring instance "));
Serial.print(instance_id, DEC);
Serial.print(F(" (maximum allowed: "));
Serial.print(MAX_DEXED, DEC);
Serial.println(F(")"));
}
}
// Init EEPROM if both buttons are pressed at startup // Init EEPROM if both buttons are pressed at startup
/* if (digitalRead(BUT_R_PIN) == LOW) /* if (digitalRead(BUT_R_PIN) == LOW)
@ -340,9 +399,14 @@ void setup()
change_disp_sd(true); change_disp_sd(true);
#endif #endif
// Init effects // Init effects
memset(delayline, 0, sizeof(delayline)); memset(delayline_r, 0, sizeof(delayline_r));
if (!modchorus.begin(delayline, MOD_DELAY_SAMPLE_BUFFER)) { if (!modchorus_r.begin(delayline_r, MOD_DELAY_SAMPLE_BUFFER)) {
Serial.println(F("AudioEffectModulatedDelay - begin failed")); Serial.println(F("AudioEffectModulatedDelay - begin failed (R)"));
while (1);
}
memset(delayline_l, 0, sizeof(delayline_l));
if (!modchorus_l.begin(delayline_l, MOD_DELAY_SAMPLE_BUFFER)) {
Serial.println(F("AudioEffectModulatedDelay - begin failed (L)"));
while (1); while (1);
} }
#ifdef DEBUG #ifdef DEBUG
@ -350,76 +414,102 @@ void setup()
Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC); Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC);
Serial.println(F(" samples")); Serial.println(F(" samples"));
#endif #endif
master_mixer_r.gain(DEXED, 1.0); master_mixer_r.gain(DEXED, 1.0);
master_mixer_l.gain(DEXED, 1.0); master_mixer_l.gain(DEXED, 1.0);
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
// INIT PEAK MIXER
microdexed_peak_mixer.gain(instance_id, 1.0);
// INIT DEXED MIXER
microdexed_mixer_r.gain(instance_id, 1.0);
microdexed_mixer_l.gain(instance_id, 1.0);
#ifdef USE_REVERB #ifdef USE_REVERB
// INIT REVERB // INIT REVERB
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) reverb_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0));
reverb_mixer.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0)); reverb_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0));
master_mixer_r.gain(REVERB, 1.0);
master_mixer_l.gain(REVERB, 1.0);
freeverbs1.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverbs1.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
#endif #endif
// INIT DELAY // INIT DELAY
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) delay_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 1.0));
delay_mixer.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 1.0)); delay_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 1.0));
// INIT CHORUS
chorus_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 1.0));
chorus_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 1.0));
// DEXED FILTER
MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 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.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
MicroDexed[instance_id]->doRefreshVoice();
// PANORAMA
pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
}
// REVERB
master_mixer_r.gain(REVERB, 1.0);
master_mixer_l.gain(REVERB, 1.0);
freeverb_r.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_r.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
// DELAY
master_mixer_r.gain(DELAY, 1.0); master_mixer_r.gain(DELAY, 1.0);
master_mixer_l.gain(DELAY, 1.0); master_mixer_l.gain(DELAY, 1.0);
delay1.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX))); delay_r.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX)));
delay_l.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX)));
// delay_fb_mixer is the feedback-adding mixer // delay_fb_mixer is the feedback-adding mixer
//delay_fb_mixer.gain(0, 1.0 - (mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0))); // original signal delay_fb_mixer_r.gain(0, 1.0); // original signal
delay_fb_mixer.gain(0, 1.0); // original signal delay_fb_mixer_l.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback
delay_fb_mixer.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback
// INIT CHORUS // CHORUS
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
chorus_mixer.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 1.0));
master_mixer_r.gain(CHORUS, 1.0); master_mixer_r.gain(CHORUS, 1.0);
master_mixer_l.gain(CHORUS, 1.0); master_mixer_l.gain(CHORUS, 1.0);
switch (configuration.chorus_waveform) switch (configuration.chorus_waveform)
{ {
case 0: case 0:
modulator.begin(WAVEFORM_TRIANGLE); chorus_modulator.begin(WAVEFORM_TRIANGLE);
break; break;
case 1: case 1:
modulator.begin(WAVEFORM_SINE); chorus_modulator.begin(WAVEFORM_SINE);
break; break;
default: default:
modulator.begin(WAVEFORM_TRIANGLE); chorus_modulator.begin(WAVEFORM_TRIANGLE);
} }
modulator.phase(0); chorus_modulator.phase(0);
modulator.frequency(configuration.chorus_frequency / 10.0); chorus_modulator.frequency(configuration.chorus_frequency / 10.0);
modulator.amplitude(mapfloat(configuration.chorus_depth, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX, 0.0, 1.0)); chorus_modulator.amplitude(mapfloat(configuration.chorus_depth, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX, 0.0, 1.0));
modulator.offset(0.0); chorus_modulator.offset(0.0);
#if MOD_FILTER_OUTPUT == MOD_BUTTERWORTH_FILTER_OUTPUT #if MOD_FILTER_OUTPUT == MOD_BUTTERWORTH_FILTER_OUTPUT
// Butterworth filter, 12 db/octave // Butterworth filter, 12 db/octave
modchorus_filter.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.707); modchorus_filter_r.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.707);
modchorus_filter_l.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.707);
#elif MOD_FILTER_OUTPUT == MOD_LINKWITZ_RILEY_FILTER_OUTPUT #elif MOD_FILTER_OUTPUT == MOD_LINKWITZ_RILEY_FILTER_OUTPUT
// Linkwitz-Riley filter, 48 dB/octave // Linkwitz-Riley filter, 48 dB/octave
modchorus_filter.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.54); modchorus_filter_r.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter.setLowpass(1, MOD_FILTER_CUTOFF_HZ, 1.3); modchorus_filter_r.setLowpass(1, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54); modchorus_filter_r.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3); modchorus_filter_r.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter_l.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter_l.setLowpass(1, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter_l.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter_l.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
#endif #endif
// MONO/STEREO
if (configuration.mono == 0) if (configuration.mono == 0)
modchorus_inverter.gain(-1.0); // stereo mode modchorus_inverter.gain(-1.0); // stereo mode
else else
modchorus_inverter.gain(1.0); // mono mode modchorus_inverter.gain(1.0); // mono mode
// Filter // set initial volume
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) set_volume(configuration.vol, configuration.mono);
{
MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 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.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
MicroDexed[instance_id]->doRefreshVoice();
}
// set initial volume and pan (read from EEPROM)
set_volume(configuration.vol, configuration.pan, configuration.mono);
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
// Initialize processor and memory measurements // Initialize processor and memory measurements
@ -527,10 +617,17 @@ void loop()
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
if (cpu_mem_millis >= SHOW_CPU_LOAD_MSEC) if (cpu_mem_millis >= SHOW_CPU_LOAD_MSEC)
{ {
if (peak1.available()) if (master_peak_r.available())
if (master_peak_r.read() > 0.99)
peak_r++;
if (master_peak_l.available())
if (master_peak_l.read() > 0.99)
peak_l++;
if (microdexed_peak.available())
{ {
if (peak1.read() > 0.99) peak_dexed_value = microdexed_peak.read();
peak++; if (peak_dexed_value > 0.99)
peak_dexed++;
} }
cpu_mem_millis -= SHOW_CPU_LOAD_MSEC; cpu_mem_millis -= SHOW_CPU_LOAD_MSEC;
show_cpu_and_mem_usage(); show_cpu_and_mem_usage();
@ -587,6 +684,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
if (inValue < MAX_BANKS - 1) if (inValue < MAX_BANKS - 1)
{ {
configuration.dexed[instance_id].bank = inValue; configuration.dexed[instance_id].bank = inValue;
eeprom_write();
} }
break; break;
case 1: case 1:
@ -613,6 +711,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
case 5: // Portamento time case 5: // Portamento time
configuration.dexed[instance_id].portamento_time = inValue; configuration.dexed[instance_id].portamento_time = inValue;
MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time); MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time);
eeprom_write();
break; break;
case 7: // Instance Volume case 7: // Instance Volume
#ifdef DEBUG #ifdef DEBUG
@ -620,19 +719,22 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
#endif #endif
configuration.dexed[instance_id].sound_intensity = map(inValue, 0, 0x7f, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); configuration.dexed[instance_id].sound_intensity = map(inValue, 0, 0x7f, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX);
MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 1.0); MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 1.0);
eeprom_write();
break; break;
case 10: // Pan case 10: // Pan
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("PANORAMA CC")); Serial.println(F("PANORAMA CC"));
#endif #endif
configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX); configuration.dexed[instance_id].pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX);
set_volume(configuration.vol, configuration.pan, configuration.mono); pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
eeprom_write();
break; break;
case 32: // BankSelect LSB case 32: // BankSelect LSB
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("BANK-SELECT CC")); Serial.println(F("BANK-SELECT CC"));
#endif #endif
configuration.dexed[instance_id].bank = inValue; configuration.dexed[instance_id].bank = inValue;
eeprom_write();
break; break;
case 64: case 64:
MicroDexed[instance_id]->setSustain(inValue > 63); MicroDexed[instance_id]->setSustain(inValue > 63);
@ -650,27 +752,36 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
break; break;
case 65: case 65:
MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time); MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time);
eeprom_write();
break; break;
case 103: // CC 103: filter resonance case 103: // CC 103: filter resonance
configuration.dexed[instance_id].filter_resonance = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); configuration.dexed[instance_id].filter_resonance = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX);
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);
eeprom_write();
break; break;
case 104: // CC 104: filter cutoff case 104: // CC 104: filter cutoff
configuration.dexed[instance_id].filter_cutoff = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); configuration.dexed[instance_id].filter_cutoff = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX);
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);
eeprom_write();
break; break;
case 105: // CC 105: delay time case 105: // CC 105: delay time
configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX); configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX);
delay1.delay(0, configuration.delay_time * 10); delay_r.delay(0, configuration.delay_time * 10);
delay_l.delay(0, configuration.delay_time * 10);
eeprom_write();
case 106: // CC 106: delay feedback case 106: // CC 106: delay feedback
configuration.delay_feedback = map(inValue, 0, 0x7f, DELAY_FEEDBACK_MIN , DELAY_FEEDBACK_MAX); 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_r.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback
delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signalbreak; delay_fb_mixer_r.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signalbreak;
delay_fb_mixer_l.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback
delay_fb_mixer_l.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signalbreak;
eeprom_write();
break; break;
case 107: // CC 107: delay volume case 107: // CC 107: delay volume
configuration.dexed[instance_id].delay_send = map(inValue, 0, 0x7f, DELAY_SEND_MIN, DELAY_SEND_MAX); configuration.dexed[instance_id].delay_send = map(inValue, 0, 0x7f, DELAY_SEND_MIN, DELAY_SEND_MAX);
master_mixer_r.gain(DELAY, configuration.dexed[instance_id].delay_send / 100.0); master_mixer_r.gain(DELAY, configuration.dexed[instance_id].delay_send / 100.0);
master_mixer_l.gain(2, configuration.dexed[instance_id].delay_send / 100.0); master_mixer_l.gain(2, configuration.dexed[instance_id].delay_send / 100.0);
eeprom_write();
break; break;
case 120: case 120:
MicroDexed[instance_id]->panic(); MicroDexed[instance_id]->panic();
@ -683,12 +794,13 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
break; break;
case 126: case 126:
MicroDexed[instance_id]->setMonoMode(true); MicroDexed[instance_id]->setMonoMode(true);
eeprom_write();
break; break;
case 127: case 127:
MicroDexed[instance_id]->setMonoMode(false); MicroDexed[instance_id]->setMonoMode(false);
eeprom_write();
break; break;
} }
eeprom_write();
} }
} }
} }
@ -1073,73 +1185,55 @@ bool checkMidiChannel(byte inChannel, uint8_t instance_id)
VOLUME HELPER VOLUME HELPER
******************************************************************************/ ******************************************************************************/
void set_volume(uint8_t v, int8_t p, uint8_t m) void set_volume(uint8_t v, uint8_t m)
{ {
float tmp2;
configuration.vol = v; configuration.vol = v;
if (configuration.vol > 100) if (configuration.vol > 100)
configuration.vol = 100; configuration.vol = 100;
//configuration.dexed[instance_id].pan = p; // TODO: Fixing pan per Dexed
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
configuration.pan = p;
}
configuration.mono = m; configuration.mono = m;
uint16_t tmp = v / 100.0 * 1023.0 + 0.5;
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
tmp2 = mapfloat(configuration.pan - 20, PANORAMA_MIN, PANORAMA_MAX, 0.0, 1.0);
}
float tmp3 = (float)(tmp * (tmp + 2)) / (float)(1 << 20);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Setting volume: VOL=")); Serial.print(F("Setting volume: VOL="));
Serial.print(v, DEC); Serial.println(v, DEC);
Serial.print(F("["));
Serial.print(tmp3, 3);
Serial.print(F("] PAN="));
Serial.print(p - 20, DEC);
Serial.print(F("["));
Serial.print(tmp2, 3);
Serial.print(F("] "));
Serial.print(tmp3 * sinf(tmp2 * PI / 2), 3);
Serial.print(F("/"));
Serial.println(tmp3 * cosf(tmp2 * PI / 2), 3);
#endif #endif
// float v = (float)(a * (a + 2))/(float)(1 << 20); // (pseudo-) logarithmic curve for volume control volume_r.gain(v);
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html volume_l.gain(v);
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
switch (m) switch (m)
{ {
case 0: // stereo case 0: // stereo
stereomono1.stereo(true); stereo2mono.stereo(true);
modchorus_inverter.gain(-1.0); // stereo mode modchorus_inverter.gain(-1.0); // stereo mode
break; break;
case 1: // mono both case 1: // mono both
stereomono1.stereo(false); stereo2mono.stereo(false);
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
configuration.pan = PANORAMA_DEFAULT; configuration.dexed[instance_id].pan = PANORAMA_DEFAULT;
} }
modchorus_inverter.gain(1.0); // stereo mode modchorus_inverter.gain(1.0); // stereo mode
break; break;
case 2: // mono right case 2: // mono right
volume_l.gain(0.0); volume_l.gain(0.0);
stereomono1.stereo(false); stereo2mono.stereo(false);
configuration.pan = PANORAMA_DEFAULT; for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
configuration.dexed[instance_id].pan = 0.0;
pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
}
modchorus_inverter.gain(1.0); // stereo mode modchorus_inverter.gain(1.0); // stereo mode
break; break;
case 3: // mono left case 3: // mono left
volume_r.gain(0.0); volume_r.gain(0.0);
stereomono1.stereo(false); stereo2mono.stereo(false);
configuration.pan = PANORAMA_DEFAULT; for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
configuration.dexed[instance_id].pan = 1.0;
pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
}
modchorus_inverter.gain(1.0); // stereo mode modchorus_inverter.gain(1.0); // stereo mode
break; break;
} }
@ -1215,7 +1309,6 @@ void check_configuration(void)
configuration.instance_mode = constrain(configuration.instance_mode, INSTANCE_MODE_MIN, INSTANCE_MODE_MAX); configuration.instance_mode = constrain(configuration.instance_mode, INSTANCE_MODE_MIN, INSTANCE_MODE_MAX);
configuration.instance_splitpoint = constrain(configuration.instance_splitpoint, INSTANCE_SPLITPOINT_MAX, INSTANCE_SPLITPOINT_MAX); configuration.instance_splitpoint = constrain(configuration.instance_splitpoint, INSTANCE_SPLITPOINT_MAX, INSTANCE_SPLITPOINT_MAX);
configuration.vol = constrain(configuration.vol, VOLUME_MIN, VOLUME_MAX); configuration.vol = constrain(configuration.vol, VOLUME_MIN, VOLUME_MAX);
configuration.pan = constrain(configuration.pan, PANORAMA_MIN, PANORAMA_MAX);
configuration.mono = constrain(configuration.mono, MONO_MIN, MONO_MAX); configuration.mono = constrain(configuration.mono, MONO_MIN, MONO_MAX);
configuration.reverb_roomsize = constrain(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX); configuration.reverb_roomsize = constrain(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX);
configuration.reverb_damping = constrain(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX); configuration.reverb_damping = constrain(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX);
@ -1235,6 +1328,7 @@ void check_configuration(void)
configuration.dexed[instance_id].filter_cutoff = constrain(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); configuration.dexed[instance_id].filter_cutoff = constrain(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX);
configuration.dexed[instance_id].filter_resonance = constrain(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); configuration.dexed[instance_id].filter_resonance = constrain(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX);
configuration.dexed[instance_id].sound_intensity = constrain(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); configuration.dexed[instance_id].sound_intensity = constrain(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX);
configuration.dexed[instance_id].pan = constrain(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX);
configuration.dexed[instance_id].transpose = constrain(configuration.dexed[instance_id].transpose, TRANSPOSE_MIN, TRANSPOSE_MAX); configuration.dexed[instance_id].transpose = constrain(configuration.dexed[instance_id].transpose, TRANSPOSE_MIN, TRANSPOSE_MAX);
configuration.dexed[instance_id].tune = constrain(configuration.dexed[instance_id].tune, TUNE_MIN, TUNE_MAX); configuration.dexed[instance_id].tune = constrain(configuration.dexed[instance_id].tune, TUNE_MIN, TUNE_MAX);
configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony, POLYPHONY_MIN, POLYPHONY_MAX); configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony, POLYPHONY_MIN, POLYPHONY_MAX);
@ -1268,7 +1362,6 @@ void init_configuration(void)
configuration.instance_mode = INSTANCE_MODE_DEFAULT; configuration.instance_mode = INSTANCE_MODE_DEFAULT;
configuration.instance_splitpoint = INSTANCE_SPLITPOINT_DEFAULT; configuration.instance_splitpoint = INSTANCE_SPLITPOINT_DEFAULT;
configuration.vol = VOLUME_DEFAULT; configuration.vol = VOLUME_DEFAULT;
configuration.pan = PANORAMA_DEFAULT;
configuration.mono = MONO_DEFAULT; configuration.mono = MONO_DEFAULT;
configuration.reverb_roomsize = REVERB_ROOMSIZE_DEFAULT; configuration.reverb_roomsize = REVERB_ROOMSIZE_DEFAULT;
configuration.reverb_damping = REVERB_DAMPING_DEFAULT; configuration.reverb_damping = REVERB_DAMPING_DEFAULT;
@ -1288,6 +1381,7 @@ void init_configuration(void)
configuration.dexed[instance_id].filter_cutoff = FILTER_CUTOFF_DEFAULT; configuration.dexed[instance_id].filter_cutoff = FILTER_CUTOFF_DEFAULT;
configuration.dexed[instance_id].filter_resonance = FILTER_RESONANCE_DEFAULT; configuration.dexed[instance_id].filter_resonance = FILTER_RESONANCE_DEFAULT;
configuration.dexed[instance_id].sound_intensity = SOUND_INTENSITY_DEFAULT; configuration.dexed[instance_id].sound_intensity = SOUND_INTENSITY_DEFAULT;
configuration.dexed[instance_id].pan = PANORAMA_DEFAULT;
configuration.dexed[instance_id].transpose = TRANSPOSE_DEFAULT; configuration.dexed[instance_id].transpose = TRANSPOSE_DEFAULT;
configuration.dexed[instance_id].tune = TUNE_DEFAULT; configuration.dexed[instance_id].tune = TUNE_DEFAULT;
configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT; configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT;
@ -1369,23 +1463,29 @@ void show_cpu_and_mem_usage(void)
} }
Serial.print(F("CPU:")); Serial.print(F("CPU:"));
Serial.print(AudioProcessorUsage(), 2); Serial.print(AudioProcessorUsage(), 2);
Serial.print(F("% CPU MAX: ")); Serial.print(F("%|CPUMAX:"));
Serial.print(AudioProcessorUsageMax(), 2); Serial.print(AudioProcessorUsageMax(), 2);
Serial.print(F("% MEM: ")); Serial.print(F("%|MEM:"));
Serial.print(AudioMemoryUsage(), DEC); Serial.print(AudioMemoryUsage(), DEC);
Serial.print(F(" MEM MAX: ")); Serial.print(F("|MEMMAX:"));
Serial.print(AudioMemoryUsageMax(), DEC); Serial.print(AudioMemoryUsageMax(), DEC);
Serial.print(F(" RENDER_TIME_MAX: ")); Serial.print(F("|RENDERTIMEMAX:"));
Serial.print(sum_render_time_max, DEC); Serial.print(sum_render_time_max, DEC);
Serial.print(F(" XRUN: ")); Serial.print(F("|XRUN:"));
Serial.print(sum_xrun, DEC); Serial.print(sum_xrun, DEC);
Serial.print(F(" OVERLOAD: ")); Serial.print(F("|OVERLOAD:"));
Serial.print(sum_overload, DEC); Serial.print(sum_overload, DEC);
Serial.print(F(" PEAK: ")); Serial.print(F("|PEAKR:"));
Serial.print(peak, DEC); Serial.print(peak_r, DEC);
Serial.print(F(" BLOCKSIZE: ")); Serial.print(F("|PEAKL:"));
Serial.print(peak_l, DEC);
Serial.print(F("|PEAKMD:"));
Serial.print(peak_dexed, DEC);
Serial.print(F("|ACTPEAKMD:"));
Serial.print(peak_dexed_value, 1);
Serial.print(F("|BLOCKSIZE:"));
Serial.print(AUDIO_BLOCK_SAMPLES, DEC); Serial.print(AUDIO_BLOCK_SAMPLES, DEC);
Serial.print(F(" ACTIVE_VOICES: ")); Serial.print(F("|ACTVOICES:"));
Serial.print(active_voices, DEC); Serial.print(active_voices, DEC);
Serial.println(); Serial.println();
Serial.flush(); Serial.flush();
@ -1404,7 +1504,6 @@ void show_configuration(void)
Serial.print(F("Instance Mode ")); Serial.println(configuration.instance_mode, DEC); Serial.print(F("Instance Mode ")); Serial.println(configuration.instance_mode, DEC);
Serial.print(F("Instance Splitpoint ")); Serial.println(configuration.instance_splitpoint, DEC); Serial.print(F("Instance Splitpoint ")); Serial.println(configuration.instance_splitpoint, DEC);
Serial.print(F("Volume ")); Serial.println(configuration.vol, DEC); Serial.print(F("Volume ")); Serial.println(configuration.vol, DEC);
Serial.print(F("Panorama ")); Serial.println(configuration.pan, DEC);
Serial.print(F("Mono ")); Serial.println(configuration.mono, DEC); Serial.print(F("Mono ")); Serial.println(configuration.mono, DEC);
Serial.print(F("Reverb Roomsize ")); Serial.println(configuration.reverb_roomsize, DEC); Serial.print(F("Reverb Roomsize ")); Serial.println(configuration.reverb_roomsize, DEC);
Serial.print(F("Reverb Damping ")); Serial.println(configuration.reverb_damping, DEC); Serial.print(F("Reverb Damping ")); Serial.println(configuration.reverb_damping, DEC);
@ -1428,6 +1527,7 @@ void show_configuration(void)
Serial.print(F(" Filter Cutoff ")); Serial.println(configuration.dexed[instance_id].filter_cutoff, DEC); Serial.print(F(" Filter Cutoff ")); Serial.println(configuration.dexed[instance_id].filter_cutoff, DEC);
Serial.print(F(" Filter Resonance ")); Serial.println(configuration.dexed[instance_id].filter_resonance, DEC); Serial.print(F(" Filter Resonance ")); Serial.println(configuration.dexed[instance_id].filter_resonance, DEC);
Serial.print(F(" Loudness ")); Serial.println(configuration.dexed[instance_id].sound_intensity, DEC); Serial.print(F(" Loudness ")); Serial.println(configuration.dexed[instance_id].sound_intensity, DEC);
Serial.print(F(" Panorama ")); Serial.println(configuration.dexed[instance_id].pan, DEC);
Serial.print(F(" Transpose ")); Serial.println(configuration.dexed[instance_id].transpose, DEC); Serial.print(F(" Transpose ")); Serial.println(configuration.dexed[instance_id].transpose, DEC);
Serial.print(F(" Tune ")); Serial.println(configuration.dexed[instance_id].tune, DEC); Serial.print(F(" Tune ")); Serial.println(configuration.dexed[instance_id].tune, DEC);
Serial.print(F(" Polyphony ")); Serial.println(configuration.dexed[instance_id].polyphony, DEC); Serial.print(F(" Polyphony ")); Serial.println(configuration.dexed[instance_id].polyphony, DEC);

@ -48,7 +48,7 @@
#define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar #define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar
extern config_t configuration; extern config_t configuration;
extern void set_volume(uint8_t v, int8_t p, uint8_t m); extern void set_volume(uint8_t v, uint8_t m);
extern char bank_names[NUM_DEXED][MAX_BANKS][BANK_NAME_LEN]; extern char bank_names[NUM_DEXED][MAX_BANKS][BANK_NAME_LEN];
extern char bank_name[NUM_DEXED][BANK_NAME_LEN]; extern char bank_name[NUM_DEXED][BANK_NAME_LEN];
extern char voice_name[NUM_DEXED][VOICE_NAME_LEN]; extern char voice_name[NUM_DEXED][VOICE_NAME_LEN];
@ -60,22 +60,31 @@ extern bool load_sysex(uint8_t b, uint8_t v);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
extern void change_disp_sd(bool d); extern void change_disp_sd(bool d);
#endif #endif
extern AudioEffectDelay delay1; extern AudioEffectDelay delay_r;
extern AudioEffectDelay delay_l;
#ifdef USE_REVERB #ifdef USE_REVERB
extern AudioEffectFreeverbStereo freeverbs1; extern AudioEffectFreeverb freeverb_r;
extern AudioMixer4 reverb_mixer; extern AudioEffectFreeverb freeverb_l;
extern AudioMixer4 reverb_send_mixer_r;
extern AudioMixer4 reverb_send_mixer_l;
#endif #endif
extern AudioEffectModulatedDelay modchorus; extern AudioEffectModulatedDelay modchorus_r;
extern AudioSynthWaveform modulator; extern AudioEffectModulatedDelay modchorus_l;
extern AudioMixer4 chorus_mixer; extern AudioSynthWaveform chorus_modulator;
extern AudioMixer4 delay_mixer; extern AudioMixer4 chorus_send_mixer_r;
extern AudioMixer4 delay_fb_mixer; extern AudioMixer4 chorus_send_mixer_l;
extern AudioMixer4 delay_send_mixer_r;
extern AudioMixer4 delay_send_mixer_l;
extern AudioMixer4 delay_fb_mixer_r;
extern AudioMixer4 delay_fb_mixer_l;
extern AudioMixer4 master_mixer_r; extern AudioMixer4 master_mixer_r;
extern AudioMixer4 master_mixer_l; extern AudioMixer4 master_mixer_l;
extern AudioAmplifier volume_r; extern AudioAmplifier volume_r;
extern AudioAmplifier volume_l; extern AudioAmplifier volume_l;
extern AudioEffectStereoMono stereomono1; extern AudioEffectStereoMono stereo2mono;
extern AudioSourceMicroDexed* MicroDexed[NUM_DEXED]; extern AudioSourceMicroDexed* MicroDexed[NUM_DEXED];
extern AudioEffectMonoStereo* mono2stereo[NUM_DEXED];
extern AudioSynthWaveformDc* pan[NUM_DEXED];
extern uint8_t selected_dexed_instance; extern uint8_t selected_dexed_instance;
/*********************************************************************** /***********************************************************************
@ -719,7 +728,7 @@ void encoder_left_up(void)
#endif #endif
configuration.vol = constrain(configuration.vol + VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX); configuration.vol = constrain(configuration.vol + VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX);
eeprom_write(); eeprom_write();
set_volume(configuration.vol, configuration.pan, configuration.mono); set_volume(configuration.vol, configuration.mono);
UI_func_volume(0); UI_func_volume(0);
} }
@ -731,7 +740,7 @@ void encoder_left_down(void)
#endif #endif
configuration.vol = constrain(configuration.vol - VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX); configuration.vol = constrain(configuration.vol - VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX);
eeprom_write(); eeprom_write();
set_volume(configuration.vol, configuration.pan, configuration.mono); set_volume(configuration.vol, configuration.mono);
UI_func_volume(0); UI_func_volume(0);
} }
@ -952,7 +961,8 @@ void UI_func_reverb_roomsize(uint8_t param)
} }
} }
freeverbs1.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0)); freeverb_r.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1011,7 +1021,8 @@ void UI_func_reverb_damping(uint8_t param)
} }
} }
freeverbs1.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0)); freeverb_r.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_l.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1078,7 +1089,8 @@ void UI_func_reverb_send(uint8_t param)
} }
} }
reverb_mixer.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0); reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0);
reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0);
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1138,7 +1150,7 @@ void UI_func_chorus_frequency(uint8_t param)
} }
} }
modulator.frequency(configuration.chorus_frequency / 10.0); chorus_modulator.frequency(configuration.chorus_frequency / 10.0);
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1191,15 +1203,15 @@ void UI_func_chorus_waveform(uint8_t param)
switch (configuration.chorus_waveform) switch (configuration.chorus_waveform)
{ {
case 0: case 0:
modulator.begin(WAVEFORM_TRIANGLE); chorus_modulator.begin(WAVEFORM_TRIANGLE);
lcd.print(F("[TRIANGLE]")); lcd.print(F("[TRIANGLE]"));
break; break;
case 1: case 1:
modulator.begin(WAVEFORM_SINE); chorus_modulator.begin(WAVEFORM_SINE);
lcd.print(F("[SINE ]")); lcd.print(F("[SINE ]"));
break; break;
default: default:
modulator.begin(WAVEFORM_TRIANGLE); chorus_modulator.begin(WAVEFORM_TRIANGLE);
lcd.print(F("[TRIANGLE]")); lcd.print(F("[TRIANGLE]"));
break; break;
} }
@ -1244,7 +1256,7 @@ void UI_func_chorus_depth(uint8_t param)
} }
} }
modulator.amplitude(configuration.chorus_depth / 100.0); chorus_modulator.amplitude(configuration.chorus_depth / 100.0);
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1295,7 +1307,8 @@ void UI_func_chorus_send(uint8_t param)
} }
} }
chorus_mixer.gain(instance_id, configuration.dexed[instance_id].chorus_send / 100.0); chorus_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].chorus_send / 100.0);
chorus_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].chorus_send / 100.0);
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1341,7 +1354,8 @@ void UI_func_delay_time(uint8_t param)
} }
} }
delay1.delay(0, configuration.delay_time * 10); delay_r.delay(0, configuration.delay_time * 10);
delay_l.delay(0, configuration.delay_time * 10);
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1387,7 +1401,9 @@ void UI_func_delay_feedback(uint8_t param)
configuration.delay_feedback--; configuration.delay_feedback--;
} }
} }
delay_fb_mixer.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback
delay_fb_mixer_r.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback
delay_fb_mixer_l.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback
//delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 200.0); // original signal //delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 200.0); // original signal
} }
@ -1439,7 +1455,8 @@ void UI_func_delay_send(uint8_t param)
} }
} }
delay_mixer.gain(instance_id, configuration.dexed[instance_id].delay_send / 100.0); delay_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].delay_send / 100.0);
delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 100.0);
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1764,6 +1781,11 @@ void UI_func_sound_intensity(uint8_t param)
void UI_func_panorama(uint8_t param) void UI_func_panorama(uint8_t param)
{ {
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP ********* if (LCDML.FUNC_setup()) // ****** SETUP *********
{ {
// setup function // setup function
@ -1784,25 +1806,24 @@ void UI_func_panorama(uint8_t param)
} }
else if (LCDML.BT_checkDown() && configuration.mono == 0) else if (LCDML.BT_checkDown() && configuration.mono == 0)
{ {
if (configuration.pan < PANORAMA_MAX) if (configuration.dexed[instance_id].pan < PANORAMA_MAX)
{ {
configuration.pan++; configuration.dexed[instance_id].pan++;
} }
} }
else if (LCDML.BT_checkUp() && configuration.mono == 0) else if (LCDML.BT_checkUp() && configuration.mono == 0)
{ {
if (configuration.pan > PANORAMA_MIN) if (configuration.dexed[instance_id].pan > PANORAMA_MIN)
{ {
configuration.pan--; configuration.dexed[instance_id].pan--;
} }
} }
if (configuration.mono == 0) if (configuration.mono == 0)
{ {
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.pan, 1, false, true, true); lcd_display_int(configuration.dexed[instance_id].pan, 1, false, true, true);
pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
set_volume(configuration.vol, configuration.pan, configuration.mono);
} }
} }
@ -1847,22 +1868,22 @@ void UI_func_stereo_mono(uint8_t param)
{ {
case 0: case 0:
lcd.print(F("[STEREO]")); lcd.print(F("[STEREO]"));
stereomono1.stereo(true); stereo2mono.stereo(true);
break; break;
case 1: case 1:
lcd.print(F("[MONO ]")); lcd.print(F("[MONO ]"));
stereomono1.stereo(false); stereo2mono.stereo(false);
break; break;
case 2: case 2:
lcd.print(F("[MONO-R]")); lcd.print(F("[MONO-R]"));
stereomono1.stereo(false); stereo2mono.stereo(false);
break; break;
case 3: case 3:
lcd.print(F("[MONO-L]")); lcd.print(F("[MONO-L]"));
stereomono1.stereo(false); stereo2mono.stereo(false);
break; break;
} }
set_volume(configuration.vol, configuration.pan, configuration.mono); set_volume(configuration.vol, configuration.mono);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -3064,7 +3085,7 @@ void UI_func_volume(uint8_t param)
else else
lcd.print(F(" ")); lcd.print(F(" "));
} }
set_volume(configuration.vol, configuration.pan, configuration.mono); set_volume(configuration.vol, configuration.mono);
eeprom_write(); eeprom_write();
} }

@ -91,17 +91,17 @@
//************************************************************************************************* //*************************************************************************************************
#ifndef TEENSY_AUDIO_BOARD #ifndef TEENSY_AUDIO_BOARD
#if AUDIO_BLOCK_SAMPLES == 64 #if AUDIO_BLOCK_SAMPLES == 64
#define AUDIO_MEM 256 #define AUDIO_MEM 512
#else #else
#define AUDIO_MEM 128 #define AUDIO_MEM 384
#endif #endif
#define REDUCE_LOUDNESS 1 #define REDUCE_LOUDNESS 1
#else // IF TEENSY_AUDIO_BOARD #else // IF TEENSY_AUDIO_BOARD
#define SGTL5000_LINEOUT_LEVEL 29 #define SGTL5000_LINEOUT_LEVEL 29
#if AUDIO_BLOCK_SAMPLES == 64 #if AUDIO_BLOCK_SAMPLES == 64
#define AUDIO_MEM 512
#else
#define AUDIO_MEM 256 #define AUDIO_MEM 256
#else
#define AUDIO_MEM 384
#endif #endif
#define DELAY_MAX_TIME 600 #define DELAY_MAX_TIME 600
#define REDUCE_LOUDNESS 1 #define REDUCE_LOUDNESS 1
@ -212,6 +212,7 @@
//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!! //* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!!
//************************************************************************************************* //*************************************************************************************************
#define NUM_DEXED 1 #define NUM_DEXED 1
#define MAX_DEXED 2
#define NORMALIZE_DX_VELOCITY 1 #define NORMALIZE_DX_VELOCITY 1
enum { DEXED, REVERB, DELAY, CHORUS }; enum { DEXED, REVERB, DELAY, CHORUS };
@ -230,7 +231,7 @@ enum { DEXED, REVERB, DELAY, CHORUS };
// Teensy-3.6 settings // Teensy-3.6 settings
#define MIDI_DEVICE_USB_HOST 1 #define MIDI_DEVICE_USB_HOST 1
#if defined(USE_REVERB) #if defined(USE_REVERB)
#define MAX_NOTES 11 #define MAX_NOTES 12
#else #else
#define MAX_NOTES 14 #define MAX_NOTES 14
#endif #endif
@ -437,6 +438,7 @@ typedef struct {
uint8_t transpose; uint8_t transpose;
uint8_t tune; uint8_t tune;
uint8_t sound_intensity; uint8_t sound_intensity;
uint8_t pan;
uint8_t polyphony; uint8_t polyphony;
uint8_t engine; uint8_t engine;
uint8_t monopoly; uint8_t monopoly;
@ -463,7 +465,6 @@ typedef struct {
uint8_t instance_mode; uint8_t instance_mode;
uint8_t instance_splitpoint; uint8_t instance_splitpoint;
uint8_t vol; uint8_t vol;
uint8_t pan;
uint8_t mono; uint8_t mono;
uint8_t reverb_roomsize; uint8_t reverb_roomsize;
uint8_t reverb_damping; uint8_t reverb_damping;

@ -99,8 +99,6 @@ Dexed::~Dexed()
void Dexed::activate(void) void Dexed::activate(void)
{ {
panic(); panic();
//controllers.values_[kControllerPitchRange] = data[155];
//controllers.values_[kControllerPitchStep] = data[156];
controllers.refresh(); controllers.refresh();
} }

@ -156,7 +156,7 @@ Dx7Note::Dx7Note() {
} }
//void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity) { //void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity) {
void Dx7Note::init(const uint8_t patch[173], int midinote, int velocity, int srcnote, int porta) { void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity, int srcnote, int porta) {
int rates[4]; int rates[4];
int levels[4]; int levels[4];
for (int op = 0; op < 6; op++) { for (int op = 0; op < 6; op++) {
@ -202,7 +202,7 @@ void Dx7Note::init(const uint8_t patch[173], int midinote, int velocity, int src
pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; pitchmodsens_ = pitchmodsenstab[patch[143] & 7];
ampmoddepth_ = (patch[140] * 165) >> 6; ampmoddepth_ = (patch[140] * 165) >> 6;
porta_rateindex_ = (porta < 128) ? porta : 127; porta_rateindex_ = (porta < 128) ? porta : 127;
porta_gliss_ = patch[68]; porta_gliss_ = 0; // TO BE FIXED
} }
void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Controllers *ctrls) { void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Controllers *ctrls) {
@ -344,7 +344,7 @@ void Dx7Note::update(const uint8_t patch[156], int midinote, int velocity, int p
pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; pitchmodsens_ = pitchmodsenstab[patch[143] & 7];
ampmoddepth_ = (patch[140] * 165) >> 6; ampmoddepth_ = (patch[140] * 165) >> 6;
porta_rateindex_ = (porta < 128) ? porta : 127; porta_rateindex_ = (porta < 128) ? porta : 127;
porta_gliss_ = patch[68]; porta_gliss_ = 0; // TO BE FIXED
} }
void Dx7Note::peekVoiceStatus(VoiceStatus &status) { void Dx7Note::peekVoiceStatus(VoiceStatus &status) {

@ -22,10 +22,10 @@
#include <Arduino.h> #include <Arduino.h>
#include <Audio.h> #include <Audio.h>
#include "effect_mono2stereo.h" #include "effect_mono_stereo.h"
/*************************************************************************/ /*************************************************************************/
// A u d i o E f f e c t M o n o 2 S t e r e o // A u d i o E f f e c t M o n o S t e r e o
// Written by Holger Wirtz // Written by Holger Wirtz
// 20191122 - initial version // 20191122 - initial version
@ -37,7 +37,7 @@ inline float mapfloat(float val, float in_min, float in_max, float out_min, floa
} }
#endif #endif
void Mono2Stereo::update(void) void AudioEffectMonoStereo::update(void)
{ {
audio_block_t *in; audio_block_t *in;
audio_block_t *mod; audio_block_t *mod;
@ -52,19 +52,20 @@ void Mono2Stereo::update(void)
if (in && mod && out[0] && out[1]) if (in && mod && out[0] && out[1])
{ {
int16_t *ip = in->data; int16_t *ip = in->data;
int16_t *modp = mod->data; float pan = mapfloat(mod->data[0], -1.0, 1.0, 0.0, 1.0);
int16_t *op[2] = { out[0]->data, out[1]->data }; int16_t *op[2] = { out[0]->data, out[1]->data };
float f_l = _pseudo_log * sinf(pan * PI / 2); // Pan [L0.0 ... M0.5 ... 1.0R]
float f_r = _pseudo_log * cosf(pan * PI / 2);
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++)
{ {
mapfloat(*modp, -1.0, 1.0, 0.0, 1.0);
float f_l = _pseudo_log * sinf(*modp * PI / 2); // _Pan [L0.0 ... M0.5 ... 1.0R]
float f_r = _pseudo_log * cosf(*modp * PI / 2);
*op[0]++ = int16_t(f_l * (*ip)); *op[0]++ = int16_t(f_l * (*ip));
*op[1]++ = int16_t(f_r * (*ip++)); *op[1]++ = int16_t(f_r * (*ip++));
//op[0]++; //op[0]++;
//op[1]++; //op[1]++;
mod++; //mod++;
} }
if (in) if (in)

@ -20,33 +20,32 @@
THE SOFTWARE. THE SOFTWARE.
*/ */
#ifndef effect_mono2stereo_h_ #ifndef effect_mono_stereo_h_
#define effect_mono2stereo_h_ #define effect_mono_stereo_h_
#include "Arduino.h" #include "Arduino.h"
#include "AudioStream.h" #include "AudioStream.h"
/*************************************************************************/ /*************************************************************************/
// A u d i o E f f e c t M o n o 2 S t e r e o // A u d i o E f f e c t M o n o S t e r e o
// Written by Holger Wirtz // Written by Holger Wirtz
// 20191122 - inital version // 20191122 - inital version
class Mono2Stereo : public AudioStream class AudioEffectMonoStereo : public AudioStream
{ {
public: public:
Mono2Stereo(void): AudioEffectMonoStereo(void):
AudioStream(2, inputQueueArray) AudioStream(2, inputQueueArray)
{ {
_pan = 0.5; ;
} }
virtual void update(void); virtual void update(void);
private: private:
audio_block_t *inputQueueArray[4]; audio_block_t *inputQueueArray[2];
audio_block_t *out[2]; audio_block_t *out[2];
const float _pseudo_log = 1048575 / (float)(1 << 20); const float _pseudo_log = 1048575 / (float)(1 << 20);
float _pan;
}; };
#endif #endif
Loading…
Cancel
Save