Fixes for drum note mapping.

dev
Holger Wirtz 2 years ago
parent 71ee0ecbcc
commit eaf7736830
  1. 34
      MicroDexed.ino
  2. 5
      UI.hpp

@ -909,13 +909,20 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
Serial.flush(); Serial.flush();
#endif #endif
uint8_t use_drum = 0;
for (uint8_t d = 0; d < NUM_DRUMSET_CONFIG; d++) { for (uint8_t d = 0; d < NUM_DRUMSET_CONFIG; d++) {
if (inNumber == configuration.drums.midinote[d]) { if (inNumber == configuration.drums.midinote[d]) {
uint8_t slot = drum_get_slot(drum_config[d].drum_class); use_drum = d;
float pan = mapfloat(configuration.drums.pan[d], DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX, 0.0, 1.0); break;
float reverb_send = configuration.drums.reverb_send[d] / 100.0f; }
float vol_min = configuration.drums.vol_min[d] / 100.0f; }
float vol_max = configuration.drums.vol_max[d] / 100.0f;
uint8_t slot = drum_get_slot(drum_config[use_drum].drum_class);
float pan = mapfloat(configuration.drums.pan[use_drum], DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX, 0.0, 1.0);
float reverb_send = configuration.drums.reverb_send[use_drum] / 100.0f;
float vol_min = configuration.drums.vol_min[use_drum] / 100.0f;
float vol_max = configuration.drums.vol_max[use_drum] / 100.0f;
drum_mixer_r.gain(slot, pan * volume_transform(mapfloat(inVelocity, 0, 127, vol_min, vol_max))); drum_mixer_r.gain(slot, pan * volume_transform(mapfloat(inVelocity, 0, 127, vol_min, vol_max)));
drum_mixer_l.gain(slot, (1.0 - pan) * volume_transform(mapfloat(inVelocity, 0, 127, vol_min, vol_max))); drum_mixer_l.gain(slot, (1.0 - pan) * volume_transform(mapfloat(inVelocity, 0, 127, vol_min, vol_max)));
@ -923,17 +930,17 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
drum_reverb_send_mixer_r.gain(slot, pan * volume_transform(reverb_send)); drum_reverb_send_mixer_r.gain(slot, pan * volume_transform(reverb_send));
drum_reverb_send_mixer_l.gain(slot, (1.0 - pan) * volume_transform(reverb_send)); drum_reverb_send_mixer_l.gain(slot, (1.0 - pan) * volume_transform(reverb_send));
if (drum_config[d].drum_data != NULL && drum_config[d].len > 0) { if (drum_config[use_drum].drum_data != NULL && drum_config[use_drum].len > 0) {
if (configuration.drums.pitch[d] != 0) { if (configuration.drums.pitch[use_drum] != 0) {
Drum[slot]->enableInterpolation(true); Drum[slot]->enableInterpolation(true);
Drum[slot]->setPlaybackRate(pow(2, float(configuration.drums.pitch[d]) / 120.0)); Drum[slot]->setPlaybackRate(pow(2, float(configuration.drums.pitch[use_drum]) / 120.0));
} else { } else {
Drum[slot]->enableInterpolation(false); Drum[slot]->enableInterpolation(false);
Drum[slot]->setPlaybackRate(1.0); Drum[slot]->setPlaybackRate(1.0);
} }
Drum[slot]->playRaw((int16_t*)drum_config[d].drum_data, drum_config[d].len, 1); Drum[slot]->playRaw((int16_t*)drum_config[use_drum].drum_data, drum_config[use_drum].len, 1);
#ifdef DEBUG #ifdef DEBUG
Serial.printf(PSTR("Playing sample [%s][%c%c] on slot [%d] main volume [%d]: drum_data=%p, len=%d\n"), drum_config[d].name, slot, configuration.drums.main_vol, drum_config[d].drum_data, drum_config[d].len); Serial.printf(PSTR("Playing sample [%s][%c%c] on slot [%d] main volume [%d]: drum_data=%p, len=%d\n"), drum_config[use_drum].name, slot, configuration.drums.main_vol, drum_config[use_drum].drum_data, drum_config[use_drum].len);
Serial.print(F("Drum Slot [")); Serial.print(F("Drum Slot ["));
Serial.print(slot); Serial.print(slot);
@ -944,13 +951,10 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
Serial.print(F(" ReverbSend=")); Serial.print(F(" ReverbSend="));
Serial.print(reverb_send, 2); Serial.print(reverb_send, 2);
Serial.print(F(" Pitch=")); Serial.print(F(" Pitch="));
Serial.print(configuration.drums.pitch[d] / 10.0f, 1); Serial.print(configuration.drums.pitch[use_drum] / 10.0f, 1);
Serial.print(F(" Playback speed=")); Serial.print(F(" Playback speed="));
Serial.println(pow(2, float(configuration.drums.pitch[d]) / 120.0)); Serial.println(pow(2, float(configuration.drums.pitch[use_drum]) / 120.0));
#endif #endif
break;
}
}
} }
} }
#endif #endif

@ -4456,8 +4456,10 @@ void UI_func_drum_midi_note(uint8_t param) {
if (ask_before_quit == true && ask_before_quit_mode <= 0) { if (ask_before_quit == true && ask_before_quit_mode <= 0) {
uint8_t num_changes = 0; uint8_t num_changes = 0;
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) { for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) {
if (midinote_old[i] != configuration.drums.midinote[i]) if (midinote_old[i] != configuration.drums.midinote[i]) {
num_changes++; num_changes++;
break;
}
} }
if (num_changes > 0) { if (num_changes > 0) {
ask_before_quit_mode = 0; ask_before_quit_mode = 0;
@ -4557,6 +4559,7 @@ void UI_func_drum_midi_note(uint8_t param) {
{ {
encoderDir[ENC_L].reset(); encoderDir[ENC_L].reset();
midi_learn_mode = MIDI_LEARN_MODE_OFF; midi_learn_mode = MIDI_LEARN_MODE_OFF;
ask_before_quit = false;
} }
} }

Loading…
Cancel
Save