Small fixes.

Added support for full dynamic voice allocation of Dexed.
pull/45/head
Holger Wirtz 3 years ago
parent b28790e944
commit 22bdb020ca
  1. 67
      MicroDexed.ino
  2. 59
      UI.hpp
  3. 50
      config.h

@ -176,7 +176,7 @@ AudioConnection * dynamicConnections[NUM_DEXED * 5];
#endif
void create_audio_engine_chain(uint8_t instance_id)
{
MicroDexed[instance_id] = new AudioSynthDexed(MAX_VOICES, SAMPLE_RATE);
MicroDexed[instance_id] = new AudioSynthDexed(MAX_NOTES / NUM_DEXED, SAMPLE_RATE);
mono2stereo[instance_id] = new AudioEffectMonoStereo();
#if defined(USE_FX)
chorus_modulator[instance_id] = new AudioSynthWaveform();
@ -301,25 +301,6 @@ void setup()
#endif
#endif
#ifdef DEBUG
generate_version_string(version_string, sizeof(version_string));
Serial.println(F("MicroDexed based on https://github.com/asb2m10/dexed"));
Serial.println(F("(c)2018-2021 H. Wirtz <wirtz@parasitstudio.de>"));
Serial.println(F("https://codeberg.org/dcoredump/MicroDexed"));
Serial.print(F("Version: "));
Serial.println(version_string);
Serial.print(F("CPU-Speed: "));
Serial.print(F_CPU / 1000000.0, 1);
Serial.print(F(" MHz / "));
Serial.print(NUM_DEXED, DEC);
Serial.print(F(" Instances with "));
Serial.print(MAX_NOTES);
Serial.println(F(" notes for each instance"));
Serial.println(F("<setup start>"));
Serial.flush();
#endif
setup_midi_devices();
// Start audio system
@ -416,15 +397,27 @@ void setup()
#endif
#endif
#if defined(ANTIALIAS_FRQ)
antialias_r.setLowpass(0, ANTIALIAS_FRQ, 0.54);
antialias_r.setLowpass(1, ANTIALIAS_FRQ, 1.3);
antialias_r.setLowpass(2, ANTIALIAS_FRQ, 0.54);
antialias_r.setLowpass(3, ANTIALIAS_FRQ, 1.3);
antialias_l.setLowpass(0, ANTIALIAS_FRQ, 0.54);
antialias_l.setLowpass(1, ANTIALIAS_FRQ, 1.3);
antialias_l.setLowpass(2, ANTIALIAS_FRQ, 0.54);
antialias_l.setLowpass(3, ANTIALIAS_FRQ, 1.3);
#ifdef DEBUG
generate_version_string(version_string, sizeof(version_string));
Serial.println(F("MicroDexed based on https://github.com/asb2m10/dexed"));
Serial.println(F("(c)2018-2021 H. Wirtz <wirtz@parasitstudio.de>"));
Serial.println(F("https://codeberg.org/dcoredump/MicroDexed"));
Serial.print(F("Version: "));
Serial.println(version_string);
Serial.print(F("CPU-Speed: "));
Serial.print(F_CPU / 1000000.0, 1);
Serial.println(F(" MHz"));
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
Serial.print(F("Instance "));
Serial.print(instance_id);
Serial.print(F(": "));
Serial.print(MicroDexed[instance_id]->getMaxNotes());
Serial.println(F(" voices"));
}
Serial.println(F("<setup start>"));
Serial.flush();
#endif
initial_values_from_eeprom(false);
@ -1593,9 +1586,9 @@ void initial_values_from_eeprom(bool init)
#ifdef DEBUG
Serial.println(F("OK, loaded!"));
#endif
}
check_configuration();
}
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
@ -1645,9 +1638,8 @@ void check_configuration(void)
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].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 / NUM_DEXED);
configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony, POLYPHONY_MIN, POLYPHONY_MAX);
configuration.dexed[instance_id].velocity_level = constrain(configuration.dexed[instance_id].velocity_level, VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX);
configuration.dexed[instance_id].engine = constrain(configuration.dexed[instance_id].engine, ENGINE_MIN, ENGINE_MAX);
configuration.dexed[instance_id].monopoly = constrain(configuration.dexed[instance_id].monopoly, MONOPOLY_MIN, MONOPOLY_MAX);
configuration.dexed[instance_id].note_refresh = constrain(configuration.dexed[instance_id].note_refresh, NOTE_REFRESH_MIN, NOTE_REFRESH_MAX);
configuration.dexed[instance_id].pb_range = constrain(configuration.dexed[instance_id].pb_range, PB_RANGE_MIN, PB_RANGE_MAX);
@ -1724,7 +1716,6 @@ void init_configuration(void)
configuration.dexed[instance_id].tune = TUNE_DEFAULT;
configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT;
configuration.dexed[instance_id].velocity_level = VELOCITY_LEVEL_DEFAULT;
configuration.dexed[instance_id].engine = ENGINE_DEFAULT;
configuration.dexed[instance_id].monopoly = MONOPOLY_DEFAULT;
configuration.dexed[instance_id].note_refresh = NOTE_REFRESH_DEFAULT;
configuration.dexed[instance_id].pb_range = PB_RANGE_DEFAULT;
@ -1763,13 +1754,7 @@ void init_configuration(void)
configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT;
#if NUM_DEXED > 1
MicroDexed[instance_id]->ControllersRefresh();
#else
if (instance_id == 0)
MicroDexed[instance_id]->ControllersRefresh();
#endif
}
set_volume(configuration.sys.vol, configuration.sys.mono);
@ -1952,6 +1937,7 @@ void set_fx_params(void)
master_mixer_r.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)));
master_mixer_l.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)));
#endif
#ifdef SGTL5000_AUDIO_ENHANCE
sgtl5000_1.eqBands(mapfloat(configuration.fx.eq_bass, EQ_BASS_MIN, EQ_BASS_MAX, -1.0, 1.0), mapfloat(configuration.fx.eq_treble, EQ_TREBLE_MIN, EQ_TREBLE_MAX, -1.0, 1.0));
@ -1966,6 +1952,7 @@ void set_voiceconfig_params(uint8_t instance_id)
microdexed_peak_mixer.gain(instance_id, 1.0);
// Controller
MicroDexed[instance_id]->setMaxNotes(configuration.dexed[instance_id].polyphony);
MicroDexed[instance_id]->setPBController(configuration.dexed[instance_id].pb_range, configuration.dexed[instance_id].pb_step);
MicroDexed[instance_id]->setMWController(configuration.dexed[instance_id].mw_range, configuration.dexed[instance_id].mw_assign, configuration.dexed[instance_id].mw_mode);
MicroDexed[instance_id]->setFCController(configuration.dexed[instance_id].fc_range, configuration.dexed[instance_id].fc_assign, configuration.dexed[instance_id].fc_mode);
@ -1974,7 +1961,6 @@ void set_voiceconfig_params(uint8_t instance_id)
MicroDexed[instance_id]->ControllersRefresh();
MicroDexed[instance_id]->setOPAll(configuration.dexed[instance_id].op_enabled);
MicroDexed[instance_id]->doRefreshVoice();
MicroDexed[instance_id]->setMaxNotes(configuration.dexed[instance_id].polyphony);
MicroDexed[instance_id]->setMonoMode(configuration.sys.mono);
// Dexed output level
@ -2388,7 +2374,6 @@ void show_configuration(void)
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(" Polyphony ")); Serial.println(configuration.dexed[instance_id].polyphony, DEC);
Serial.print(F(" Engine ")); Serial.println(configuration.dexed[instance_id].engine, DEC);
Serial.print(F(" Mono/Poly ")); Serial.println(configuration.dexed[instance_id].monopoly, DEC);
Serial.print(F(" Note Refresh ")); Serial.println(configuration.dexed[instance_id].note_refresh, DEC);
Serial.print(F(" Pitchbend Range ")); Serial.println(configuration.dexed[instance_id].pb_range, DEC);

@ -2289,61 +2289,7 @@ void UI_func_polyphony(uint8_t param)
void UI_func_engine(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
encoderDir[ENC_R].reset();
lcd.setCursor(0, 0);
lcd.print(F("Engine"));
lcd_active_instance_number(selected_instance_id);
UI_update_instance_icons();
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
{
if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort()))
{
if (LCDML.BT_checkDown())
configuration.dexed[selected_instance_id].engine = constrain(configuration.dexed[selected_instance_id].engine + 1, ENGINE_MIN, ENGINE_MAX);
else if (LCDML.BT_checkUp())
configuration.dexed[selected_instance_id].engine = constrain(configuration.dexed[selected_instance_id].engine - 1, ENGINE_MIN, ENGINE_MAX);
#if NUM_DEXED > 1
else if (LCDML.BT_checkEnter())
{
selected_instance_id = !selected_instance_id;
lcd_active_instance_number(selected_instance_id);
UI_update_instance_icons();
}
#endif
}
//MicroDexed[selected_instance_id]->setEngineType(configuration.dexed[selected_instance_id].engine);
lcd.setCursor(0, 1);
switch (configuration.dexed[selected_instance_id].engine)
{
case 0:
lcd.print(F("[MODERN]"));
break;
case 1:
lcd.print(F("[MARK 1]"));
break;
case 2:
lcd.print(F("[OPL ]"));
break;
}
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_R].reset();
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[0].engine), configuration.dexed[0].engine);
#if NUM_DEXED > 1
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[1].engine), configuration.dexed[1].engine);
#endif
}
;
}
void UI_func_mono_poly(uint8_t param)
@ -3679,10 +3625,9 @@ void UI_func_eeprom_reset(uint8_t param)
if (yesno == true)
{
LCDML.DISP_clear();
lcd.print("EEPROM Reset:");
lcd.print("EEPROM Reset");
initial_values_from_eeprom(true);
lcd.setCursor(0, 1);
lcd.print("Done.");
delay(MESSAGE_WAIT_TIME);

@ -23,8 +23,7 @@
*/
#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED
#pragma once
#include <Arduino.h>
#include "midinotes.h"
@ -103,8 +102,6 @@
//*************************************************************************************************
//* DEXED AND EFFECTS SETTINGS
//*************************************************************************************************
#define DEXED_ENGINE DEXED_ENGINE_MODERN // DEXED_ENGINE_MARKI // DEXED_ENGINE_OPL
// Number of Dexed instances
#define NUM_DEXED 2 // 1 or 2 - nothing else!
// FX-CHAIN ENABLE/DISABLE
@ -297,6 +294,42 @@
#define EEPROM_MARKER 0x4242
// MAX_NOTES SETTINGS
// Teensy-4.x settings
#ifdef TEENSY4
#define MAX_NOTES 32
#endif
// Teensy-3.6 settings
#if defined(TEENSY3_6)
# if defined(USE_FX)
# if F_CPU == 256000000
# define MAX_NOTES 20
# elif F_CPU == 240000000
# define MAX_NOTES 18
# elif F_CPU == 216000000
# define MAX_NOTES 16
# else
# warning >>> You should consider to use 216MHz overclocking to get polyphony of 16 instead 12 voices <<<
# define MAX_NOTES 12
# endif
# else
# if F_CPU == 256000000
# define MAX_NOTES 20
# elif F_CPU == 216000000
# define MAX_NOTES 20
# else
# define MAX_NOTES 16
# endif
# endif
#endif
#ifdef TEENSY3_5
#undef MIDI_DEVICE_USB_HOST
#define MAX_NOTES 11
#undef USE_FX
#endif
// MIDI
#ifdef MIDI_DEVICE_USB
#define USBCON 1
@ -437,11 +470,7 @@
#define POLYPHONY_MIN 0
#define POLYPHONY_MAX MAX_NOTES
#define POLYPHONY_DEFAULT MAX_NOTES
#define ENGINE_MIN 0
#define ENGINE_MAX 2
#define ENGINE_DEFAULT 0
#define POLYPHONY_DEFAULT MAX_NOTES / NUM_DEXED
#define MONOPOLY_MIN 0
#define MONOPOLY_MAX 1
@ -573,7 +602,6 @@ typedef struct dexed_s {
uint8_t pan;
uint8_t polyphony;
uint8_t velocity_level;
uint8_t engine;
uint8_t monopoly;
uint8_t note_refresh;
uint8_t pb_range;
@ -651,5 +679,3 @@ inline float mapfloat(float val, float in_min, float in_max, float out_min, floa
return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
#endif
#endif // CONFIG_H_INCLUDED

Loading…
Cancel
Save