Fixing default configuration.

pull/5/head
Holger Wirtz 5 years ago
parent a69da0b47e
commit 7df518e0af
  1. 90
      MicroDexed.ino
  2. 159
      UI.hpp
  3. 14
      config.h
  4. 2
      effect_stereo_mono.cpp

@ -138,25 +138,8 @@ uint8_t active_voices = 0;
#ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis;
#endif
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
};
config_t configuration;
bool eeprom_update_flag = false;
// Allocate the delay lines for left and right channels
@ -370,7 +353,7 @@ void setup()
}
// set initial volume and pan (read from EEPROM)
set_volume(configuration.vol, configuration.pan);
set_volume(configuration.vol, configuration.pan, configuration.mono);
soften_volume.init(configuration.vol, VOLUME_MIN, VOLUME_MAX);
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
@ -500,7 +483,7 @@ void loop()
}
if (soften_volume.running())
{
set_volume(soften_volume.value(), configuration.pan);
set_volume(soften_volume.value(), configuration.pan, configuration.mono);
#ifdef DEBUG
Serial.print(F("Volume: "));
Serial.print(configuration.vol, DEC);
@ -586,7 +569,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
break;
case 10: // Pan
configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX);
set_volume(configuration.vol, configuration.pan);
set_volume(configuration.vol, configuration.pan, configuration.mono);
break;
case 32: // BankSelect LSB
configuration.bank = inValue;
@ -971,10 +954,11 @@ bool checkMidiChannel(byte inChannel)
VOLUME HELPER
******************************************************************************/
void set_volume(uint8_t v, int8_t p)
void set_volume(uint8_t v, int8_t p, uint8_t m)
{
configuration.vol = v;
configuration.pan = p;
configuration.mono = m;
uint16_t tmp = v / 100.0 * 1023.0 + 0.5;
float tmp2 = mapfloat(configuration.pan, PANORAMA_MIN, PANORAMA_MAX, 0.0, 1.0);
@ -987,11 +971,11 @@ void set_volume(uint8_t v, int8_t p)
#ifdef DEBUG
Serial.print(F("Setting volume: VOL="));
Serial.print(configuration.vol, DEC);
Serial.print(v, DEC);
Serial.print(F("["));
Serial.print(tmp3, 3);
Serial.print(F("] PAN="));
Serial.print(configuration.pan, DEC);
Serial.print(p, DEC);
Serial.print(F("["));
Serial.print(tmp2, 3);
Serial.print(F("] "));
@ -1000,20 +984,28 @@ void set_volume(uint8_t v, int8_t p)
Serial.println(tmp3 * cosf(tmp2 * PI / 2), 3);
#endif
if (configuration.mono == 2)
{
volume_r.gain(1.0);
volume_l.gain(0.0);
}
else if (configuration.mono == 3)
{
volume_r.gain(0.0);
volume_l.gain(1.0);
}
else
switch (m)
{
volume_r.gain(1.0);
volume_l.gain(1.0);
case 0:
volume_r.gain(1.0);
volume_l.gain(1.0);
stereomono1.stereo(true);
break;
case 1:
volume_r.gain(1.0);
volume_l.gain(1.0);
stereomono1.stereo(false);
break;
case 2:
volume_r.gain(1.0);
volume_l.gain(0.0);
stereomono1.stereo(false);
break;
case 3:
volume_r.gain(0.0);
volume_l.gain(1.0);
stereomono1.stereo(false);
break;
}
}
@ -1047,6 +1039,28 @@ void initial_values_from_eeprom(void)
#ifdef DEBUG
Serial.print(F(" - mismatch -> initializing EEPROM!"));
#endif
configuration.checksum = 0xffff;
configuration.bank = SYSEXBANK_DEFAULT;
configuration.voice = SYSEXSOUND_DEFAULT;
configuration.vol = VOLUME_DEFAULT;
configuration.pan = PANORAMA_DEFAULT;
configuration.mono = MONO_DEFAULT;
configuration.midi_channel = DEFAULT_MIDI_CHANNEL;
configuration.reverb_roomsize = REVERB_ROOMSIZE_DEFAULT;
configuration.reverb_damping = REVERB_DAMPING_DEFAULT;
configuration.reverb_level = REVERB_LEVEL_DEFAULT;
configuration.chorus_frequency = CHORUS_FREQUENCY_DEFAULT;
configuration.chorus_waveform = CHORUS_WAVEFORM_DEFAULT;
configuration.chorus_depth = CHORUS_DEPTH_DEFAULT;
configuration.chorus_level = CHORUS_LEVEL_DEFAULT;
configuration.delay_time = DELAY_TIME_DEFAULT;
configuration.delay_feedback = DELAY_FEEDBACK_DEFAULT;
configuration.delay_level = DELAY_LEVEL_DEFAULT;
configuration.filter_cutoff = FILTER_CUTOFF_DEFAULT;
configuration.filter_resonance = FILTER_RESONANCE_DEFAULT;
configuration.loudness = LOUDNESS_DEFAULT;
configuration.polyphony = POLYPHONY_DEFAULT;
configuration.engine = ENGINE_DEFAULT;
eeprom_update();
}
else

159
UI.hpp

@ -30,6 +30,7 @@
#include "LiquidCrystalPlus_I2C.h"
#include "SoftenValue.hpp"
#include "effect_modulated_delay.h"
#include "effect_stereo_mono.h"
#include "dexed.h"
#include <LCDMenuLib2.h>
@ -42,7 +43,7 @@
#define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar
extern config_t configuration;
//void set_volume(float v, float p);
extern void set_volume(uint8_t v, int8_t p, uint8_t m);
extern char bank_names[MAX_BANKS][BANK_NAME_LEN];
extern char bank_name[BANK_NAME_LEN];
extern char voice_name[VOICE_NAME_LEN];
@ -65,8 +66,8 @@ extern AudioMixer4 master_mixer_r;
extern AudioMixer4 master_mixer_l;
extern AudioAmplifier volume_r;
extern AudioAmplifier volume_l;
extern AudioEffectStereoMono stereomono1;
extern Dexed* MicroDexed[NUM_DEXED];
extern void set_volume(uint8_t v, int8_t p);
/***********************************************************************
GLOBAL
@ -642,7 +643,7 @@ void UI_func_sound(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -675,6 +676,7 @@ void UI_func_reverb_roomsize(uint8_t param)
configuration.reverb_roomsize--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.reverb_roomsize, 3, true, true, false);
@ -684,6 +686,7 @@ void UI_func_reverb_roomsize(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -716,6 +719,7 @@ void UI_func_reverb_damping(uint8_t param)
configuration.reverb_damping--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.reverb_damping, 3, true, true, false);
@ -725,6 +729,7 @@ void UI_func_reverb_damping(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -758,6 +763,7 @@ void UI_func_reverb_level(uint8_t param)
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.reverb_level, 3, true, true, false);
@ -768,6 +774,7 @@ void UI_func_reverb_level(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -800,6 +807,7 @@ void UI_func_chorus_frequency(uint8_t param)
configuration.chorus_frequency--;
}
}
lcd.setCursor(0, 1);
lcd_display_float(configuration.chorus_frequency / 10.0, 2, 1, false, true, false);
lcd.print(" Hz");
@ -810,6 +818,7 @@ void UI_func_chorus_frequency(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -842,6 +851,7 @@ void UI_func_chorus_waveform(uint8_t param)
configuration.chorus_waveform--;
}
}
lcd.setCursor(0, 1);
switch (configuration.chorus_waveform)
{
@ -863,6 +873,7 @@ void UI_func_chorus_waveform(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -895,6 +906,7 @@ void UI_func_chorus_depth(uint8_t param)
configuration.chorus_depth--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.chorus_depth, 3, true, true, false);
@ -904,6 +916,7 @@ void UI_func_chorus_depth(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -936,10 +949,10 @@ void UI_func_chorus_level(uint8_t param)
configuration.chorus_level--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.chorus_level, 3, true, true, false);
master_mixer_r.gain(3, configuration.chorus_level / 100.0);
master_mixer_l.gain(3, configuration.chorus_level / 100.0);
}
@ -947,6 +960,7 @@ void UI_func_chorus_level(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -979,6 +993,7 @@ void UI_func_delay_time(uint8_t param)
configuration.delay_time -= 10;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.delay_time * 10, 3, true, true, false);
@ -988,6 +1003,7 @@ void UI_func_delay_time(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1020,6 +1036,7 @@ void UI_func_delay_feedback(uint8_t param)
configuration.delay_feedback--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.delay_feedback, 3, true, true, false);
@ -1030,6 +1047,7 @@ void UI_func_delay_feedback(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1062,6 +1080,7 @@ void UI_func_delay_level(uint8_t param)
configuration.delay_level--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.delay_level, 3, true, true, false);
@ -1072,6 +1091,7 @@ void UI_func_delay_level(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1104,6 +1124,7 @@ void UI_func_filter_cutoff(uint8_t param)
configuration.filter_cutoff--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.filter_cutoff, 3, true, true, false);
@ -1116,6 +1137,7 @@ void UI_func_filter_cutoff(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1148,6 +1170,7 @@ void UI_func_filter_resonance(uint8_t param)
configuration.filter_resonance--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.filter_resonance, 3, true, true, false);
@ -1160,6 +1183,7 @@ void UI_func_filter_resonance(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1207,6 +1231,7 @@ void UI_func_midi_channel(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1239,6 +1264,7 @@ void UI_func_loudness(uint8_t param)
configuration.loudness--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.loudness, 3, true, true, false);
@ -1251,6 +1277,7 @@ void UI_func_loudness(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1278,20 +1305,21 @@ void UI_func_panorama(uint8_t param)
}
else if (LCDML.BT_checkUp())
{
if (configuration.loudness > PANORAMA_MIN)
if (configuration.pan > PANORAMA_MIN)
{
configuration.pan--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.pan, 2, false, true, true);
}
set_volume(configuration.vol, configuration.pan);
set_volume(configuration.vol, configuration.pan, configuration.mono);
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
@ -1329,33 +1357,132 @@ void UI_func_stereo_mono(uint8_t param)
{
case 0:
lcd.print(F("[MONO ]"));
stereomono1.stereo(false);
break;
case 1:
lcd.print(F("[STEREO]"));
stereomono1.stereo(true);
break;
case 2:
lcd.print(F("[MONO-R]"));
stereomono1.stereo(false);
break;
case 3:
lcd.print(F("[MONO-L]"));
stereomono1.stereo(false);
break;
}
set_volume(configuration.vol, configuration.pan, configuration.mono);
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
void UI_func_polyphony(uint8_t param)
{
;
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// setup function
lcd.setCursor(0, 0);
lcd.print(F("Polyphony"));
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
{
if (LCDML.BT_checkEnter())
{
LCDML.FUNC_goBackToMenu();
}
else if (LCDML.BT_checkDown())
{
if (configuration.polyphony < POLYPHONY_MAX)
{
configuration.polyphony++;
}
}
else if (LCDML.BT_checkUp())
{
if (configuration.polyphony > POLYPHONY_MIN)
{
configuration.polyphony--;
}
}
lcd.setCursor(0, 1);
lcd_display_int(configuration.polyphony, 2, false, true, false);
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
MicroDexed[i]->setMaxNotes(configuration.polyphony);
}
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
void UI_func_engine(uint8_t param)
{
;
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// setup function
lcd.setCursor(0, 0);
lcd.print(F("Engine"));
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
{
if (LCDML.BT_checkEnter())
{
LCDML.FUNC_goBackToMenu();
}
else if (LCDML.BT_checkDown())
{
if (configuration.engine < ENGINE_MAX)
{
configuration.engine++;
}
}
else if (LCDML.BT_checkUp())
{
if (configuration.engine > ENGINE_MIN)
{
configuration.engine--;
}
}
lcd.setCursor(0, 1);
switch (configuration.engine)
{
case 0:
lcd.print(F("[MODERN]"));
break;
case 1:
lcd.print(F("[MARK 1 ]"));
break;
case 2:
lcd.print(F("[OPL ]"));
break;
}
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
MicroDexed[i]->setEngineType(configuration.engine);
}
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
eeprom_write();
}
}
void UI_func_information(uint8_t param)
@ -1452,7 +1579,8 @@ void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool
{
int16_t tmp = 0;
uint16_t p;
bool non_zero_found=false;
if (size < 1)
return;
@ -1461,6 +1589,7 @@ void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool
if (sign == true)
{
size++;
if (var < 0)
{
lcd.print(F("-"));
@ -1481,10 +1610,18 @@ void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool
if (zeros == true)
lcd.print(F("0"));
else
lcd.print(F(" "));
{
if (non_zero_found == true)
lcd.print(F("0"));
else
lcd.print(F(" "));
}
}
else
{
non_zero_found = true;
lcd.print(tmp);
}
var -= (tmp * p);
}

@ -183,9 +183,9 @@
// Teensy-3.6 settings
#define MIDI_DEVICE_USB_HOST 1
#if defined(USE_REVERB)
#define MAX_NOTES 16
#else
#define MAX_NOTES 14
#else
#define MAX_NOTES 16
#endif
#else
// Teensy-3.5 settings
@ -287,6 +287,14 @@
#define LOUDNESS_MAX 100
#define LOUDNESS_DEFAULT 100
#define POLYPHONY_MIN 1
#define POLYPHONY_MAX MAX_NOTES
#define POLYPHONY_DEFAULT MAX_NOTES
#define ENGINE_MIN 0
#define ENGINE_MAX 2
#define ENGINE_DEFAULT 0
// struct for holding the current configuration
struct config_t {
uint32_t checksum;
@ -309,6 +317,8 @@ struct config_t {
uint8_t filter_cutoff;
uint8_t filter_resonance;
uint8_t loudness;
uint8_t polyphony;
uint8_t engine;
};
// struct for smoothing value changes

@ -41,7 +41,7 @@ void AudioEffectStereoMono::update(void)
block[0] = receiveWritable(0);
block[1] = receiveWritable(1);
if (_enabled == true)
if (_enabled == false)
{
if (block[0] && block[1])
{

Loading…
Cancel
Save