Adding changes of Dexed library.

pull/46/head
Holger Wirtz 3 years ago
parent 173b0a425e
commit 52d8beac5b
  1. 78
      third-party/Synth_Dexed/src/synth_dexed.cpp
  2. 39
      third-party/Synth_Dexed/src/synth_dexed.h

@ -283,8 +283,6 @@ float PluginFx::getGain(void)
Dexed::Dexed(uint8_t maxnotes, int rate) Dexed::Dexed(uint8_t maxnotes, int rate)
{ {
uint8_t i;
Exp2::init(); Exp2::init();
Tanh::init(); Tanh::init();
Sin::init(); Sin::init();
@ -297,19 +295,7 @@ Dexed::Dexed(uint8_t maxnotes, int rate)
fx.init(rate); fx.init(rate);
engineMsfa = new FmCore; engineMsfa = new FmCore;
max_notes=maxnotes; max_notes=maxnotes;
voices=new ProcessorVoice[max_notes];
for (i = 0; i < max_notes; i++)
{
voices[i].dx7_note = new Dx7Note;
voices[i].keydown = false;
voices[i].sustained = false;
voices[i].live = false;
voices[i].key_pressed_timer = 0;
}
currentNote = 0; currentNote = 0;
resetControllers(); resetControllers();
controllers.masterTune = 0; controllers.masterTune = 0;
@ -317,13 +303,12 @@ Dexed::Dexed(uint8_t maxnotes, int rate)
lastKeyDown = -1; lastKeyDown = -1;
vuSignal = 0.0; vuSignal = 0.0;
controllers.core = engineMsfa; controllers.core = engineMsfa;
lfo.reset(data + 137); lfo.reset(data + 137);
setMonoMode(false);
sustain = false; sustain = false;
voices=NULL;
setMaxNotes(max_notes);
setMonoMode(false);
loadInitVoice(); loadInitVoice();
xrun = 0; xrun = 0;
@ -343,6 +328,47 @@ Dexed::~Dexed()
delete(engineMsfa); delete(engineMsfa);
} }
void Dexed::setMaxNotes(uint8_t new_max_notes)
{
uint8_t i=0;
max_notes=constrain(max_notes,0,_MAX_NOTES);
#ifdef DEBUG
Serial.print("Allocating memory for ");
Serial.print(max_notes,DEC);
Serial.println(" notes.");
#endif
if(voices)
{
panic();
for (i = 0; i < max_notes; i++)
{
if(voices[i].dx7_note)
delete voices[i].dx7_note;
}
delete voices;
}
max_notes=new_max_notes;
if(max_notes>0)
{
voices=new ProcessorVoice[max_notes];
for (i = 0; i < max_notes; i++)
{
voices[i].dx7_note = new Dx7Note;
voices[i].keydown = false;
voices[i].sustained = false;
voices[i].live = false;
voices[i].key_pressed_timer = 0;
}
}
else
voices=NULL;
}
void Dexed::activate(void) void Dexed::activate(void)
{ {
panic(); panic();
@ -596,7 +622,7 @@ void Dexed::setOPAll(uint8_t ops)
controllers.opSwitch = ops; controllers.opSwitch = ops;
} }
bool Dexed::isMonoMode(void) { bool Dexed::getMonoMode(void) {
return monoMode; return monoMode;
} }
@ -604,7 +630,6 @@ void Dexed::setMonoMode(bool mode) {
if (monoMode == mode) if (monoMode == mode)
return; return;
//panic();
notesOff(); notesOff();
monoMode = mode; monoMode = mode;
} }
@ -668,16 +693,6 @@ void Dexed::notesOff(void) {
} }
} }
void Dexed::setMaxNotes(uint8_t n) {
if (n <= max_notes)
{
notesOff();
max_notes = n;
//panic();
controllers.refresh();
}
}
uint8_t Dexed::getMaxNotes(void) uint8_t Dexed::getMaxNotes(void)
{ {
return max_notes; return max_notes;
@ -885,9 +900,8 @@ void Dexed::loadVoiceParameters(uint8_t* new_data)
panic(); panic();
memcpy(&data, new_data, 155); memcpy(&data, new_data, 155);
doRefreshVoice(); doRefreshVoice();
strncpy(dexed_voice_name, (char *)&new_data[145], sizeof(dexed_voice_name) - 1);
#ifdef DEBUG #ifdef DEBUG
strncpy(dexed_voice_name, (char *)&new_data[145], sizeof(dexed_voice_name) - 1);
dexed_voice_name[10] = '\0'; dexed_voice_name[10] = '\0';
Serial.print(F("Voice [")); Serial.print(F("Voice ["));

@ -30,47 +30,14 @@
#include "teensy_board_detection.h" #include "teensy_board_detection.h"
#define SYNTH_DEXED_VERSION "1.0.0" #define SYNTH_DEXED_VERSION "1.0.0"
#define DEBUG 1 //#define DEBUG 1
#define SAMPLE_RATE 44100 #define SAMPLE_RATE 44100
#define MIDI_CONTROLLER_MODE_MAX 2 #define MIDI_CONTROLLER_MODE_MAX 2
#define TRANSPOSE_FIX 24 #define TRANSPOSE_FIX 24
#define VOICE_SILENCE_LEVEL 1100 #define VOICE_SILENCE_LEVEL 1100
// Teensy-4.x settings #define _MAX_NOTES 32
#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
#define NUM_VOICE_PARAMETERS 156 #define NUM_VOICE_PARAMETERS 156
@ -1150,7 +1117,7 @@ class Dexed
// Global methods // Global methods
void activate(void); void activate(void);
void deactivate(void); void deactivate(void);
bool isMonoMode(void); bool getMonoMode(void);
void setMonoMode(bool mode); void setMonoMode(bool mode);
void setRefreshMode(bool mode); void setRefreshMode(bool mode);
void setMaxNotes(uint8_t n); void setMaxNotes(uint8_t n);

Loading…
Cancel
Save