Added autothrottle for max_notes if CPU overload is detected.

pull/32/head
Holger Wirtz 5 years ago
parent 5d9ca93373
commit dcccc77712
  1. 14
      MicroDexed.ino
  2. 1
      config.h
  3. 21
      dexed.cpp

@ -600,10 +600,22 @@ void loop()
eeprom_update();
}
// check for value changes and unused voices
// check for value changes, unused voices and CPU overload
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
active_voices[instance_id] = MicroDexed[instance_id]->getNumNotesPlaying();
#ifdef CPU_OVERLOAD_THROTTLE
if (AudioProcessorUsageMax() > 99.9)
{
AudioProcessorUsageMaxReset();
MicroDexed[instance_id]->keyup(-1); // kills the oldest note and decreases max_notes
Serial.print(F("!!!CPU overload!!! Automatic throttling max_notes to "));
Serial.print(MicroDexed[instance_id]->getMaxNotes(), DEC);
Serial.print(F(" for instance "));
Serial.print(instance_id, DEC);
Serial.println(F("."));
}
#endif
}
}

@ -212,6 +212,7 @@
#define NUM_DEXED 1
#define MAX_DEXED 2
#define NORMALIZE_DX_VELOCITY 1
#define CPU_OVERLOAD_THROTTLE 1
enum { DEXED, CHORUS, DELAY, REVERB};

@ -251,10 +251,23 @@ void Dexed::keyup(int16_t pitch) {
pitch += data[144] - TRANSPOSE_FIX;
uint8_t note;
for (note = 0; note < max_notes; note++) {
if ( voices[note].midi_note == pitch && voices[note].keydown ) {
voices[note].keydown = false;
break;
if (pitch < 0) // for disabling the oldest note when cpu overload is detected
{
note = abs((currentNote + 1) % max_notes);
voices[note].keydown = false;
if (max_notes == note)
currentNote = 0;
else
currentNote = note;
max_notes--;
}
else
{
for (note = 0; note < max_notes; note++) {
if ( voices[note].midi_note == pitch && voices[note].keydown ) {
voices[note].keydown = false;
break;
}
}
}

Loading…
Cancel
Save