Fix and UI improvments for panorama.

pull/8/head
Holger Wirtz 5 years ago
parent d1577d4ef1
commit f03960fb75
  1. 189
      MicroDexed.ino
  2. 27
      UI.hpp
  3. 2
      config.h

@ -414,120 +414,120 @@ void loop()
//while (42 == 42)
//{
#ifdef OLD
// Main sound calculation
if (queue1.available() && fill_audio_buffer > audio_block_time_us - 10)
{
fill_audio_buffer = 0;
// Main sound calculation
if (queue1.available() && fill_audio_buffer > audio_block_time_us - 10)
{
fill_audio_buffer = 0;
audio_buffer = queue1.getBuffer();
audio_buffer = queue1.getBuffer();
elapsedMicros t1;
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
MicroDexed[i]->getSamples(AUDIO_BLOCK_SAMPLES, audio_buffer);
}
if (t1 > audio_block_time_us) // everything greater 2.9ms is a buffer underrun!
xrun++;
if (t1 > render_time_max)
render_time_max = t1;
if (peak1.available())
{
if (peak1.read() > 0.99)
peak++;
}
queue1.playBuffer();
elapsedMicros t1;
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
MicroDexed[i]->getSamples(AUDIO_BLOCK_SAMPLES, audio_buffer);
}
#endif
// EEPROM update handling
if (autostore >= AUTOSTORE_MS && active_voices == 0 && eeprom_update_flag == true)
if (t1 > audio_block_time_us) // everything greater 2.9ms is a buffer underrun!
xrun++;
if (t1 > render_time_max)
render_time_max = t1;
if (peak1.available())
{
// only store configuration data to EEPROM when AUTOSTORE_MS is reached and no voices are activated anymore
eeprom_update();
if (peak1.read() > 0.99)
peak++;
}
queue1.playBuffer();
}
#endif
// MIDI input handling
check_midi_devices();
// EEPROM update handling
if (autostore >= AUTOSTORE_MS && active_voices == 0 && eeprom_update_flag == true)
{
// only store configuration data to EEPROM when AUTOSTORE_MS is reached and no voices are activated anymore
eeprom_update();
}
// CONTROL-RATE-EVENT-HANDLING
if (control_rate > CONTROL_RATE_MS)
{
// MIDI input handling
check_midi_devices();
// CONTROL-RATE-EVENT-HANDLING
if (control_rate > CONTROL_RATE_MS)
{
#ifdef ENABLE_LCD_UI
// LCD Menu
LCDML.loop();
// LCD Menu
LCDML.loop();
// initial starts voice selection menu as default
if (menu_state == MENU_START)
{
menu_state = MENU_VOICE;
UI_func_voice_selection(0);
}
// initial starts voice selection menu as default
if (menu_state == MENU_START)
{
menu_state = MENU_VOICE;
UI_func_voice_selection(0);
}
#endif
control_rate = 0;
control_rate = 0;
// check for value changes and unused voices
soften_volume.tick();
// check for value changes and unused voices
soften_volume.tick();
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
active_voices = MicroDexed[i]->getNumNotesPlaying();
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
active_voices = MicroDexed[i]->getNumNotesPlaying();
soften_filter_res[i].tick();
soften_filter_cut[i].tick();
soften_filter_res[i].tick();
soften_filter_cut[i].tick();
if (soften_filter_res[i].running())
{
// soften filter resonance value
MicroDexed[i]->fx.Reso = soften_filter_res[i].value();
if (soften_filter_res[i].running())
{
// soften filter resonance value
MicroDexed[i]->fx.Reso = soften_filter_res[i].value();
#ifdef DEBUG
Serial.print(F("Filter-Resonance: "));
Serial.print(MicroDexed[i]->fx.Reso, 5);
Serial.print(F(" Filter-Resonance step: "));
Serial.print(soften_filter_res[i].steps());
Serial.print(F(" Filter-Resonance diff: "));
Serial.println(soften_filter_res[i].diff(), 5);
Serial.print(F("Filter-Resonance: "));
Serial.print(MicroDexed[i]->fx.Reso, 5);
Serial.print(F(" Filter-Resonance step: "));
Serial.print(soften_filter_res[i].steps());
Serial.print(F(" Filter-Resonance diff: "));
Serial.println(soften_filter_res[i].diff(), 5);
#endif
}
// soften filter cutoff value
if (soften_filter_cut[i].running())
{
MicroDexed[i]->fx.Cutoff = soften_filter_cut[i].value();
#ifdef DEBUG
Serial.print(F("Filter-Cutoff: "));
Serial.print(MicroDexed[i]->fx.Cutoff, 5);
Serial.print(F(" Filter-Cutoff step: "));
Serial.print(soften_filter_cut[i].steps());
Serial.print(F(" Filter-Cutoff diff: "));
Serial.println(soften_filter_cut[i].diff(), 5);
#endif
}
}
if (soften_volume.running())
// soften filter cutoff value
if (soften_filter_cut[i].running())
{
set_volume(soften_volume.value(), configuration.pan, configuration.mono);
MicroDexed[i]->fx.Cutoff = soften_filter_cut[i].value();
#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);
Serial.print(F("Filter-Cutoff: "));
Serial.print(MicroDexed[i]->fx.Cutoff, 5);
Serial.print(F(" Filter-Cutoff step: "));
Serial.print(soften_filter_cut[i].steps());
Serial.print(F(" Filter-Cutoff diff: "));
Serial.println(soften_filter_cut[i].diff(), 5);
#endif
}
}
if (soften_volume.running())
{
set_volume(soften_volume.value(), configuration.pan, configuration.mono);
#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 (cpu_mem_millis >= SHOW_CPU_LOAD_MSEC)
if (cpu_mem_millis >= SHOW_CPU_LOAD_MSEC)
{
if (peak1.available())
{
if (peak1.available())
{
if (peak1.read() > 0.99)
peak++;
}
cpu_mem_millis -= SHOW_CPU_LOAD_MSEC;
show_cpu_and_mem_usage();
if (peak1.read() > 0.99)
peak++;
}
cpu_mem_millis -= SHOW_CPU_LOAD_MSEC;
show_cpu_and_mem_usage();
}
#endif
//}
}
@ -547,7 +547,7 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
{
if (checkMidiChannel(inChannel))
{
MicroDexed[0]->keyup(inNumber);
MicroDexed[0]->keyup(inNumber);
}
}
@ -1015,22 +1015,25 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
// 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));
switch (m)
{
case 0:
case 0: // stereo
stereomono1.stereo(true);
break;
case 1:
case 1: // mono both
stereomono1.stereo(false);
configuration.pan = 0.5;
break;
case 2:
case 2: // mono right
volume_l.gain(0.0);
stereomono1.stereo(false);
configuration.pan = 0.5;
break;
case 3:
case 3: // mono left
volume_r.gain(0.0);
stereomono1.stereo(false);
configuration.pan = 0.5;
break;
}
}

@ -1428,6 +1428,11 @@ void UI_func_panorama(uint8_t param)
// setup function
lcd.setCursor(0, 0);
lcd.print(F("Panorama"));
if (configuration.mono > 0)
{
lcd.setCursor(0, 1);
lcd.print(F("MONO-disabled"));
}
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1436,24 +1441,28 @@ void UI_func_panorama(uint8_t param)
{
LCDML.FUNC_goBackToMenu();
}
else if (LCDML.BT_checkDown())
else if (LCDML.BT_checkDown() && configuration.mono == 0)
{
if (configuration.pan < PANORAMA_MAX)
{
configuration.pan++;
}
}
else if (LCDML.BT_checkUp())
else if (LCDML.BT_checkUp() && configuration.mono == 0)
{
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, configuration.mono);
if (configuration.mono == 0)
{
lcd.setCursor(0, 1);
lcd_display_int(configuration.pan, 2, false, true, true);
set_volume(configuration.vol, configuration.pan, configuration.mono);
}
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -1496,13 +1505,13 @@ void UI_func_stereo_mono(uint8_t param)
switch (configuration.mono)
{
case 0:
lcd.print(F("[MONO ]"));
stereomono1.stereo(false);
break;
case 1:
lcd.print(F("[STEREO]"));
stereomono1.stereo(true);
break;
case 1:
lcd.print(F("[MONO ]"));
stereomono1.stereo(false);
break;
case 2:
lcd.print(F("[MONO-R]"));
stereomono1.stereo(false);

@ -265,7 +265,7 @@
#else
#define MONO_MIN 0
#define MONO_MAX 3
#define MONO_DEFAULT 1
#define MONO_DEFAULT 0
#endif
#define VOLUME_MIN 0

Loading…
Cancel
Save