|
|
|
@ -43,7 +43,7 @@ |
|
|
|
|
|
|
|
|
|
extern config_t configuration; |
|
|
|
|
|
|
|
|
|
Dexed::Dexed(int rate) |
|
|
|
|
Dexed::Dexed(uint16_t rate, uint8_t instance_id) |
|
|
|
|
{ |
|
|
|
|
uint8_t i; |
|
|
|
|
|
|
|
|
@ -89,6 +89,8 @@ Dexed::Dexed(int rate) |
|
|
|
|
sustain = false; |
|
|
|
|
|
|
|
|
|
setEngineType(DEXED_ENGINE); |
|
|
|
|
|
|
|
|
|
id = instance_id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Dexed::~Dexed() |
|
|
|
@ -265,6 +267,12 @@ void Dexed::keydown(int16_t pitch, uint8_t velo) { |
|
|
|
|
voices[note].dx7_note->oscSync(); |
|
|
|
|
voices[i].key_pressed_timer = millis(); |
|
|
|
|
keydown_counter++; |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Start voice: ")); |
|
|
|
|
Serial.print(note, DEC); |
|
|
|
|
Serial.print(F(" pitch: ")); |
|
|
|
|
Serial.println(pitch, DEC); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
@ -309,13 +317,24 @@ void Dexed::keyup(int16_t pitch) { |
|
|
|
|
if ( voices[note].midi_note == pitch && voices[note].keydown ) { |
|
|
|
|
voices[note].keydown = false; |
|
|
|
|
voices[note].key_pressed_timer = 0; |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Stop voice: ")); |
|
|
|
|
Serial.print(note, DEC); |
|
|
|
|
Serial.print(F(" pitch: ")); |
|
|
|
|
Serial.println(pitch, DEC); |
|
|
|
|
Serial.print(F(" id: ")); |
|
|
|
|
Serial.println(id, DEC); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// note not found ?
|
|
|
|
|
if ( note >= max_notes ) { |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Note not found: ")); |
|
|
|
|
Serial.println(pitch, DEC); |
|
|
|
|
#endif |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -472,7 +491,8 @@ 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; |
|
|
|
|
|
|
|
|
|
VoiceStatus voiceStatus; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < max_notes; i++) |
|
|
|
|
{ |
|
|
|
|
if (voices[i].live == true) |
|
|
|
@ -483,13 +503,29 @@ uint8_t Dexed::getNumNotesPlaying(void) |
|
|
|
|
memset(&voiceStatus, 0, sizeof(VoiceStatus)); |
|
|
|
|
voices[i].dx7_note->peekVoiceStatus(voiceStatus); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(i); |
|
|
|
|
Serial.print("ALG: "); |
|
|
|
|
Serial.println(data[134]+1); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
for (uint8_t op = 0; op < 6; op++) |
|
|
|
|
{ |
|
|
|
|
if ((op_carrier & (1 << op))) |
|
|
|
|
{ |
|
|
|
|
// this voice is a carrier!
|
|
|
|
|
op_carrier_num++; |
|
|
|
|
if (voiceStatus.amp[op] <= VOICE_SILENCE_LEVEL && voiceStatus.ampStep[op] == 4) |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print("OP: "); |
|
|
|
|
Serial.print(op); |
|
|
|
|
Serial.print(" AMP_STEP: "); |
|
|
|
|
Serial.print(voiceStatus.ampStep[op],DEC); |
|
|
|
|
Serial.print(" AMP: "); |
|
|
|
|
Serial.println(voiceStatus.amp[op],DEC); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (voiceStatus.amp[op] < VOICE_SILENCE_LEVEL && voiceStatus.ampStep[op] >= 3) |
|
|
|
|
{ |
|
|
|
|
// this voice produces no audio output
|
|
|
|
|
op_amp++; |
|
|
|
@ -497,6 +533,22 @@ uint8_t Dexed::getNumNotesPlaying(void) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Serial.print(F("ID=")); |
|
|
|
|
Serial.print(id, DEC); |
|
|
|
|
Serial.print(F(" OP carrier=")); |
|
|
|
|
Serial.print(op_carrier_num, DEC); |
|
|
|
|
Serial.print(F(" OP amp=")); |
|
|
|
|
Serial.println(op_amp, DEC); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print("OP_AMP: "); |
|
|
|
|
Serial.print(op_amp); |
|
|
|
|
Serial.print(" OP_CARRIER_NUM: "); |
|
|
|
|
Serial.println(op_carrier_num); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (op_amp == op_carrier_num) |
|
|
|
|
{ |
|
|
|
|
// all carrier-operators are silent -> disable the voice
|
|
|
|
|