Fixes for memory allocation.

pull/112/head
Holger Wirtz 3 years ago
parent 08a1d68a0d
commit df26d255d4
  1. 47
      MicroDexed.ino
  2. 2
      third-party/LCDMenuLib2/src/LCDMenuLib2.h

@ -509,8 +509,6 @@ void setup()
//sgtl5000.enhanceBass(1.0, 1.5, 0, 5); // enhanceBass(1.0, 1.0, 1, 2); // Configures the bass enhancement by setting the levels of the original stereo signal and the bass-enhanced mono level which will be mixed together. The high-pass filter may be enabled (0) or bypassed (1). //sgtl5000.enhanceBass(1.0, 1.5, 0, 5); // enhanceBass(1.0, 1.0, 1, 2); // Configures the bass enhancement by setting the levels of the original stereo signal and the bass-enhanced mono level which will be mixed together. The high-pass filter may be enabled (0) or bypassed (1).
//sgtl5000.surroundSoundEnable(); //sgtl5000.surroundSoundEnable();
//sgtl5000.surroundSound(7, 3); // Configures virtual surround width from 0 (mono) to 7 (widest). select may be set to 1 (disable), 2 (mono input) or 3 (stereo input). //sgtl5000.surroundSound(7, 3); // Configures virtual surround width from 0 (mono) to 7 (widest). select may be set to 1 (disable), 2 (mono input) or 3 (stereo input).
//sgtl5000.autoVolumeEnable();
//sgtl5000.autoVolumeControl(1, 1, 1, 0.9, 0.01, 0.05);
#else #else
sgtl5000.audioProcessorDisable(); sgtl5000.audioProcessorDisable();
sgtl5000.autoVolumeDisable(); sgtl5000.autoVolumeDisable();
@ -589,7 +587,10 @@ void setup()
#if defined(USE_FX) #if defined(USE_FX)
#if defined(USE_EPIANO) #if defined(USE_EPIANO)
// EP_CHORUS // EP_CHORUS
ep_delayline_l = new int16_t[MOD_DELAY_SAMPLE_BUFFER]; //ep_delayline_r = new (std::nothrow) int16_t[MOD_DELAY_SAMPLE_BUFFER];
ep_delayline_r = (int16_t*)malloc(MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (ep_delayline_r != NULL)
{
memset(ep_delayline_r, 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t)); memset(ep_delayline_r, 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (!ep_modchorus_r.begin(ep_delayline_r, MOD_DELAY_SAMPLE_BUFFER)) if (!ep_modchorus_r.begin(ep_delayline_r, MOD_DELAY_SAMPLE_BUFFER))
{ {
@ -598,12 +599,32 @@ void setup()
#endif #endif
while (1); while (1);
} }
ep_delayline_r = new int16_t[MOD_DELAY_SAMPLE_BUFFER]; }
else
{
#ifdef DEBUG
Serial.println(F("AudioEffectModulatedDelay R - memory allocation failed EP"));
#endif
while (1);
}
//ep_delayline_l = new (std::nothrow) int16_t[MOD_DELAY_SAMPLE_BUFFER];
ep_delayline_l = (int16_t*)malloc(MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (ep_delayline_l != NULL)
{
memset(ep_delayline_l, 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t)); memset(ep_delayline_l, 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (!ep_modchorus_l.begin(ep_delayline_l, MOD_DELAY_SAMPLE_BUFFER)) if (!ep_modchorus_l.begin(ep_delayline_l, MOD_DELAY_SAMPLE_BUFFER))
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("AudioEffectModulatedDelay L - begin failed EP")); Serial.println(F("AudioEffectModulatedDelay L - begin failed EP"));
#endif
while (1);
}
}
else
{
#ifdef DEBUG
Serial.println(F("AudioEffectModulatedDelay L - memory allocation failed EP"));
#endif #endif
while (1); while (1);
} }
@ -631,13 +652,27 @@ void setup()
#if defined(USE_FX) #if defined(USE_FX)
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
delayline[instance_id] = new int16_t[MOD_DELAY_SAMPLE_BUFFER]; //delayline[instance_id] = new (std::nothrow) int16_t[MOD_DELAY_SAMPLE_BUFFER];
delayline[instance_id] = (int16_t*)malloc(MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (delayline[instance_id] != NULL)
{
memset(delayline[instance_id], 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t)); memset(delayline[instance_id], 0, MOD_DELAY_SAMPLE_BUFFER * sizeof(int16_t));
if (!modchorus[instance_id]->begin(delayline[instance_id], MOD_DELAY_SAMPLE_BUFFER)) { if (!modchorus[instance_id]->begin(delayline[instance_id], MOD_DELAY_SAMPLE_BUFFER))
{
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("AudioEffectModulatedDelay - begin failed [")); Serial.print(F("AudioEffectModulatedDelay - begin failed ["));
Serial.print(instance_id); Serial.print(instance_id);
Serial.println(F("]")); Serial.println(F("]"));
#endif
while (1);
}
}
else
{
#ifdef DEBUG
Serial.print(F("AudioEffectModulatedDelay - memory allocation failed ["));
Serial.print(instance_id);
Serial.println(F("]"));
#endif #endif
while (1); while (1);
} }

@ -80,7 +80,7 @@
#endif #endif
// Version // Version
#define _LCDML_VERSION "LCDML2 v2.2.7" #define _LCDML_VERSION "LCDML2 v2.2.7-T"
// this makro is for unused variables which exists for compatibility things ... // this makro is for unused variables which exists for compatibility things ...
#define LCDML_UNUSED(expr) do { (void)(expr); } while (0) #define LCDML_UNUSED(expr) do { (void)(expr); } while (0)

Loading…
Cancel
Save