Several fixes.

Added functions for detecting voices which do not produce any output.
Fixing screen changing when volume encoder was moved.
pull/4/head
Holger Wirtz 6 years ago
parent 4970cabc24
commit 3637e9c807
  1. 17
      MicroDexed.ino
  2. 5
      UI.cpp
  3. 1
      config.h
  4. 49
      dexed.cpp
  5. 2
      dexed.h

@ -123,6 +123,8 @@ uint8_t effect_delay_feedback = 0;
uint8_t effect_delay_volume = 0;
bool effect_delay_sync = 0;
elapsedMicros fill_audio_buffer;
elapsedMillis control_rate;
uint8_t shutdown_voices = 0;
#ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis;
@ -335,6 +337,21 @@ void loop()
// MIDI input handling
check_midi_devices();
// Shutdown unused voices
if (control_rate > CONTROL_RATE_MS)
{
uint8_t tmp = shutdown_voices;
control_rate = 0;
dexed->getNumNotesPlaying();
if (tmp != shutdown_voices)
{
Serial.print(F("Active voices ["));
Serial.print(shutdown_voices);
Serial.println(F("]"));
}
}
#ifdef I2C_DISPLAY
// UI
if (master_timer >= TIMER_UI_HANDLING_MS)

@ -235,6 +235,11 @@ void handle_ui(void)
case 1: // right encoder moved
switch (ui_state)
{
case UI_VOLUME:
ui_state = UI_MAIN;
lcd.clear();
ui_show_main();
break;
case UI_MAIN:
switch (ui_main_state)
{

@ -60,6 +60,7 @@
//* DEXED AND EFECTS SETTINGS
//*************************************************************************************************
#define DEXED_ENGINE DEXED_ENGINE_MODERN // DEXED_ENGINE_MARKI // DEXED_ENGINE_OPL
#define CONTROL_RATE_MS 200
// EFFECTS
#define FILTER_MAX_FREQ 10000

@ -63,7 +63,7 @@ Dexed::Dexed(int rate)
voices[i].live = false;
}
max_notes = 16;
max_notes = MAX_NOTES;
currentNote = 0;
resetControllers();
controllers.masterTune = 0;
@ -391,6 +391,53 @@ uint8_t Dexed::getMaxNotes(void)
return max_notes;
}
uint8_t Dexed::getNumNotesPlaying(void)
{
uint8_t op_carrier = controllers.core->get_carrier_operators(data[134]); // look for carriers
uint8_t i;
uint8_t count_playing_voices=0;
for (i = 0; i < max_notes; i++)
{
if (voices[i].live == true)
{
uint8_t op_amp = 0;
uint8_t op_carrier_num = 0;
memset(&voiceStatus, 0, sizeof(VoiceStatus));
voices[i].dx7_note->peekVoiceStatus(voiceStatus);
for (uint8_t op = 0; op < 6; op++)
{
if ((op_carrier & (1 >> op)) == 1)
{
{
// this voice is a carrier!
op_carrier_num++;
if (voiceStatus.amp[op] <= 1069 && voiceStatus.ampStep[op] == 4) // this voice produces no audio output
op_amp++;
}
}
}
if (op_amp == op_carrier_num)
{
// all carrier-operators are silent -> disable the voice
voices[i].live = false;
voices[i].sustained = false;
voices[i].keydown = false;
Serial.print(F("Voice shutdown: "));
Serial.println(i, DEC);
}
else
count_playing_voices++;
}
}
return(count_playing_voices);
}
bool Dexed::loadSysexVoice(uint8_t* new_data)
{
uint8_t* p_data = data;

@ -160,6 +160,7 @@ class Dexed
void keydown(uint8_t pitch, uint8_t velo);
void setSustain(bool sustain);
bool getSustain(void);
uint8_t getNumNotesPlaying(void);
ProcessorVoice voices[MAX_NOTES];
Controllers controllers;
@ -190,6 +191,7 @@ class Dexed
bool monoMode;
bool refreshVoice;
uint8_t engineType;
VoiceStatus voiceStatus;
Lfo lfo;
FmCore* engineMsfa;
EngineMkI* engineMkI;

Loading…
Cancel
Save