Fixes for voice auto-shutdown.

pull/4/head
Holger Wirtz 6 years ago
parent 3637e9c807
commit 09037e4c73
  1. 14
      MicroDexed.ino
  2. 21
      dexed.cpp

@ -124,7 +124,7 @@ uint8_t effect_delay_volume = 0;
bool effect_delay_sync = 0; bool effect_delay_sync = 0;
elapsedMicros fill_audio_buffer; elapsedMicros fill_audio_buffer;
elapsedMillis control_rate; elapsedMillis control_rate;
uint8_t shutdown_voices = 0; uint8_t active_voices = 0;
#ifdef SHOW_CPU_LOAD_MSEC #ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis; elapsedMillis cpu_mem_millis;
@ -340,16 +340,8 @@ void loop()
// Shutdown unused voices // Shutdown unused voices
if (control_rate > CONTROL_RATE_MS) if (control_rate > CONTROL_RATE_MS)
{ {
uint8_t tmp = shutdown_voices;
control_rate = 0; control_rate = 0;
dexed->getNumNotesPlaying(); active_voices = dexed->getNumNotesPlaying();
if (tmp != shutdown_voices)
{
Serial.print(F("Active voices ["));
Serial.print(shutdown_voices);
Serial.println(F("]"));
}
} }
#ifdef I2C_DISPLAY #ifdef I2C_DISPLAY
@ -954,6 +946,8 @@ void show_cpu_and_mem_usage(void)
Serial.print(peak, DEC); Serial.print(peak, DEC);
Serial.print(F(" BLOCKSIZE: ")); Serial.print(F(" BLOCKSIZE: "));
Serial.print(AUDIO_BLOCK_SAMPLES, DEC); Serial.print(AUDIO_BLOCK_SAMPLES, DEC);
Serial.print(F(" ACTIVE_VOICES: "));
Serial.print(active_voices, DEC);
Serial.println(); Serial.println();
AudioProcessorUsageMaxReset(); AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset(); AudioMemoryUsageMaxReset();

@ -395,7 +395,7 @@ uint8_t Dexed::getNumNotesPlaying(void)
{ {
uint8_t op_carrier = controllers.core->get_carrier_operators(data[134]); // look for carriers uint8_t op_carrier = controllers.core->get_carrier_operators(data[134]); // look for carriers
uint8_t i; uint8_t i;
uint8_t count_playing_voices=0; uint8_t count_playing_voices = 0;
for (i = 0; i < max_notes; i++) for (i = 0; i < max_notes; i++)
{ {
@ -405,19 +405,18 @@ uint8_t Dexed::getNumNotesPlaying(void)
uint8_t op_carrier_num = 0; uint8_t op_carrier_num = 0;
memset(&voiceStatus, 0, sizeof(VoiceStatus)); memset(&voiceStatus, 0, sizeof(VoiceStatus));
voices[i].dx7_note->peekVoiceStatus(voiceStatus); voices[i].dx7_note->peekVoiceStatus(voiceStatus);
for (uint8_t op = 0; op < 6; op++) for (uint8_t op = 0; op < 6; op++)
{ {
if ((op_carrier & (1 >> op)) == 1) if ((op_carrier & (1 << op)))
{ {
// this voice is a carrier!
op_carrier_num++;
if (voiceStatus.amp[op] <= 1069 && voiceStatus.ampStep[op] == 4)
{ {
// this voice is a carrier! // this voice produces no audio output
op_carrier_num++; op_amp++;
if (voiceStatus.amp[op] <= 1069 && voiceStatus.ampStep[op] == 4) // this voice produces no audio output
op_amp++;
} }
} }
} }
@ -428,14 +427,16 @@ uint8_t Dexed::getNumNotesPlaying(void)
voices[i].live = false; voices[i].live = false;
voices[i].sustained = false; voices[i].sustained = false;
voices[i].keydown = false; voices[i].keydown = false;
Serial.print(F("Voice shutdown: ")); #ifdef DEBUG
Serial.print(F("Shutdown voice: "));
Serial.println(i, DEC); Serial.println(i, DEC);
#endif
} }
else else
count_playing_voices++; count_playing_voices++;
} }
} }
return(count_playing_voices); return (count_playing_voices);
} }
bool Dexed::loadSysexVoice(uint8_t* new_data) bool Dexed::loadSysexVoice(uint8_t* new_data)

Loading…
Cancel
Save