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