Added Mono/Stereo switch.

master
Holger Wirtz 5 years ago
parent cb917f3a2b
commit fd95535018
  1. 17
      MicroMDAEPiano.ino
  2. 97
      UI.hpp
  3. 11
      config.h
  4. 2
      mdaEPiano.cpp

@ -147,6 +147,7 @@ config_t configuration = {
ENC_MIDI_CHANNEL_DEFAULT, // midi_channel
ENC_MIDI_SOFT_THRU_DEFAULT, // midi_soft_thru
ENC_MAX_POLY_DEFAULT, // max_poly
ENC_MONO_DEFAULT, // mono
ENC_MASTER_PAN_DEFAULT // pan
};
@ -245,11 +246,6 @@ void setup()
modulator.phase(0);
modulator.amplitude(1.0);
modulator.offset(0.0);
#ifdef MOD_STEREO
inverter.gain(-1.0); // change phase for second modulated delay (faked stereo mode)
#else
inverter.gain(1.0);
#endif
modchorus_r.offset(15.0);
modchorus_l.offset(15.0);
// Butterworth filter, 12 db/octave
@ -277,6 +273,17 @@ void setup()
mixer_r.gain(VOL_CHORUS, 0.2);
mixer_l.gain(VOL_CHORUS, 0.2);
// Stereo/Mono initial setup
if (configuration.mono == false)
{
inverter.gain(-1.0); // change phase for second modulated delay (faked stereo mode)
}
else
{
inverter.gain(1.0);
configuration.pan = ENC_MASTER_PAN_DEFAULT;
}
// set master volume
set_master_volume(master_volume);

@ -28,16 +28,16 @@
const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5
/// Configures the number of available functions per line.
const uint8_t MAX_FUNCTIONS = 42; ///< @note Default: 8
const uint8_t MAX_FUNCTIONS = 43; ///< @note Default: 8
/// Configures the number of available lines per screen.
const uint8_t MAX_LINES = 20; ///< @note Default: 12
const uint8_t MAX_LINES = 22; ///< @note Default: 12
/// Configures the number of available screens per menu.
const uint8_t MAX_SCREENS = 2; ///< @note Default: 14
/// Configures the number of available menus per menus system.
const uint8_t MAX_MENUS = 45; ///< @note Default: 8
const uint8_t MAX_MENUS = 46; ///< @note Default: 8
*/
@ -56,7 +56,7 @@ int32_t encoder_value[NUM_ENCODER];
Bounce but[NUM_ENCODER] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)};
elapsedMillis back_to_main;
#define NUM_MENUS 45
#define NUM_MENUS 46
#define MAIN 0
/*************************************/
@ -104,10 +104,11 @@ elapsedMillis back_to_main;
#define MIDI_CHANNEL 39
#define MIDI_SOFT_THRU 40
#define MAX_POLY 41
#define MONO 42
/*************************************/
#define STORE_QUESTION 42
#define STORE_QUESTION 43
/*************************************/
#define MASTER_VOLUME 43
#define MASTER_VOLUME 44
/*************************************/
int8_t menu_position[NUM_MENUS];
@ -132,6 +133,7 @@ extern AudioMixer4 mixer_r;
extern AudioMixer4 mixer_l;
extern AudioAmplifier volume_r;
extern AudioAmplifier volume_l;
extern AudioAmplifier inverter;
extern mdaEPiano* ep;
extern config_t configuration;
extern uint8_t sound;
@ -285,6 +287,17 @@ char* get_midi_soft_thru_value_text(void)
return (midi_soft_thru_value_text1);
}
char mono_value_text1[] = " ";
char* get_mono_value_text(void)
{
if (configuration.mono == 0)
sprintf(mono_value_text1, "Stereo");
else
sprintf(mono_value_text1, "Mono ");
return (mono_value_text1);
}
char yes_no_value_text1[] = " ";
char* get_yes_no_value_text(void)
{
@ -727,15 +740,17 @@ LiquidMenu save_sound_menu(lcd);
/******************************************
SYSTEM MENU
******************************************/
#define NUM_SYSTEM_MENUS 4
#define NUM_SYSTEM_MENUS 5
const char system_text1[] PROGMEM = "Loudness";
const char system_text2[] PROGMEM = "MIDI Channel";
const char system_text3[] PROGMEM = "MIDI Soft-Thru";
const char system_text4[] PROGMEM = "Max. Polyphony";
const char system_text5[] PROGMEM = "Mono/Stereo";
LiquidLine system_line1(1, 0, system_text1);
LiquidLine system_line2(1, 1, system_text2);
LiquidLine system_line3(1, 1, system_text3);
LiquidLine system_line4(1, 1, system_text4);
LiquidLine system_line5(1, 1, system_text5);
LiquidScreen system_screen;
LiquidMenu system_menu(lcd);
@ -779,6 +794,16 @@ LiquidLine max_poly_line2(1, 1, configuration.max_poly);
LiquidScreen max_poly_screen;
LiquidMenu max_poly_menu(lcd);
/******************************************
MONO/STEREO MENU
******************************************/
#define NUM_MONO_MENUS 1
const char mono_text1[] PROGMEM = "Mono/Stereo";
LiquidLine mono_line1(1, 0, mono_text1);
LiquidLine mono_line2(1, 1, get_mono_value_text);
LiquidScreen mono_screen;
LiquidMenu mono_menu(lcd);
/******************************************
INFO MENU
******************************************/
@ -1349,11 +1374,23 @@ void callback_max_poly_function(void)
#endif
menu_system.change_menu(max_poly_menu);
menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
encoder_value[RIGHT_ENCODER] = configuration. max_poly;
encoder_value[RIGHT_ENCODER] = configuration.max_poly;
enc[RIGHT_ENCODER].write(configuration.max_poly, ENC_MAX_POLY_MIN, ENC_MAX_POLY_MAX);
menu_system.update();
}
void callback_mono_function(void)
{
#ifdef SHOW_DEBUG
Serial.println(F("callback_mono_function"));
#endif
menu_system.change_menu(mono_menu);
menu_position[SYSTEM] = encoder_value[RIGHT_ENCODER];
encoder_value[RIGHT_ENCODER] = configuration.mono;
enc[RIGHT_ENCODER].write(configuration.mono, ENC_MONO_MIN, ENC_MONO_MAX);
menu_system.update();
}
/******************************************
INFO MENU CALLBACKS
******************************************/
@ -1757,6 +1794,7 @@ void init_menus(void)
system_screen.add_line(system_line2);
system_screen.add_line(system_line3);
system_screen.add_line(system_line4);
system_screen.add_line(system_line5);
system_screen.set_displayLineCount(2);
system_menu.add_screen(system_screen);
@ -1764,6 +1802,7 @@ void init_menus(void)
system_line2.attach_function(MIDI_CHANNEL, callback_midi_channel_function);
system_line3.attach_function(MIDI_SOFT_THRU, callback_midi_soft_thru_function);
system_line4.attach_function(MAX_POLY, callback_max_poly_function);
system_line5.attach_function(MONO, callback_mono_function);
// setup loudness
loudness_screen.add_line(loudness_line1);
@ -1789,6 +1828,12 @@ void init_menus(void)
max_poly_screen.set_displayLineCount(2);
max_poly_menu.add_screen(max_poly_screen);
// setup mono
mono_screen.add_line(mono_line1);
mono_screen.add_line(mono_line2);
mono_screen.set_displayLineCount(2);
mono_menu.add_screen(mono_screen);
// setup info menu
info_screen.add_line(info_line1);
info_screen.add_line(info_line2);
@ -1845,6 +1890,7 @@ void init_menus(void)
menu_system.add_menu(midi_channel_menu);
menu_system.add_menu(midi_soft_thru_menu);
menu_system.add_menu(max_poly_menu);
menu_system.add_menu(mono_menu);
menu_system.add_menu(info_menu);
menu_system.add_menu(master_volume_menu);
@ -2359,6 +2405,24 @@ void set_max_poly(uint8_t value)
ep->reset_voices();
}
void set_mono(uint8_t mode)
{
#ifdef SHOW_DEBUG
Serial.print(F("Set MONO "));
Serial.println(mode);
#endif
if (mode == 0)
{
set_stereo(configuration.stereo);
inverter.gain(-1.0); // change phase for second modulated delay (faked stereo mode)
}
else
{
set_stereo(ENC_STEREO_MIN);
inverter.gain(1.0);
}
}
void set_complete_configuration(void)
{
set_decay(configuration.decay);
@ -2395,6 +2459,7 @@ void set_complete_configuration(void)
set_midi_channel(configuration.midi_channel);
set_midi_soft_thru(configuration.midi_soft_thru);
set_max_poly(configuration.max_poly);
set_mono(configuration.mono);
}
//********************************************************************************************+
@ -2765,6 +2830,15 @@ void handle_ui(void)
menu_system.update();
}
}
else if (menu_system.get_currentScreen() == &mono_screen)
{
if (encoder_tmp != encoder_value[RIGHT_ENCODER])
{
// value up/down
set_mono(encoder_tmp);
menu_system.update();
}
}
else
{
// Move menu focus
@ -3199,6 +3273,13 @@ void handle_ui(void)
#endif
goto_system_menu(MAX_POLY);
}
else if (menu_system.get_currentScreen() == &mono_screen) // mono menu
{
#ifdef SHOW_DEBUG
Serial.println(F("from mono to system"));
#endif
goto_system_menu(MONO);
}
else if (menu_system.get_currentScreen() == &info_screen) // info menu
{
#ifdef SHOW_DEBUG

@ -31,7 +31,7 @@
// 128 to 64 in <ARDUINO-IDE-DIR>/cores/teensy3/AudioStream.h
// arecord -f cd -Dhw:1,0 /tmp/bla.wav
// aplaymidi -p 20:0 test.mid
// aplaymidi -p 20:0 test.mid
//*************************************************************************************************
//* DEVICE SETTINGS
@ -60,7 +60,7 @@
// CHORUS parameters
#define CHORUS_DELAY_LENGTH_SAMPLES (16*AUDIO_BLOCK_SAMPLES) // one AUDIO_BLOCK_SAMPLES = 2.902ms
#define WAVEFORM_MOD WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
//#define MOD_STEREO 1
//*************************************************************************************************
//* DEBUG OUTPUT SETTINGS
//*************************************************************************************************
@ -99,7 +99,7 @@
30: 1.22 Volts p-p
31: 1.16 Volts p-p
*/
#define SGTL5000_LINEOUT_LEVEL 26
#define SGTL5000_LINEOUT_LEVEL 25
//#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14
@ -286,6 +286,10 @@
#define ENC_MAX_POLY_MAX NVOICES
#define ENC_MAX_POLY_DEFAULT NVOICES
//
#define ENC_MONO_MIN 0 // stereo
#define ENC_MONO_MAX 1 // mono
#define ENC_MONO_DEFAULT 1
//
#define ENC_MASTER_VOLUME_MIN 0
#define ENC_MASTER_VOLUME_MAX 99
#define ENC_MASTER_VOLUME_DEFAULT 80
@ -351,6 +355,7 @@ struct config_t {
uint8_t midi_channel;
bool midi_soft_thru;
uint8_t max_poly;
uint8_t mono;
int8_t pan;
};

@ -257,7 +257,7 @@ void mdaEPiano::setOverdrive(float value)
void mdaEPiano::setLoudness(float value)
{
//volume = value * 0.32258; // 0.00002 * 127^2
volume = value * 0.18f;
volume = value * 0.17f;
}
void mdaEPiano::setParameter(int32_t index, float value)

Loading…
Cancel
Save