diff --git a/src/common/helm_common.h b/src/common/helm_common.h index a907babd..9ce5b0d5 100644 --- a/src/common/helm_common.h +++ b/src/common/helm_common.h @@ -182,6 +182,7 @@ namespace mopo { const std::wstring DEFAULT_KEYBOARD = L"awsedftgyhujkolp;'"; const wchar_t DEFAULT_KEYBOARD_OCTAVE_UP = 'x'; const wchar_t DEFAULT_KEYBOARD_OCTAVE_DOWN = 'z'; + const wchar_t DEFAULT_KEYBOARD_SUSTAIN_PEDAL = 'n'; const std::string PATCH_EXTENSION = "helm"; @@ -254,10 +255,14 @@ namespace mopo { wchar_t getDownKey() { return down_key_; } void setDownKey(wchar_t down_key) { down_key_ = down_key; } + wchar_t getSustainPedalKey() { return sustain_pedal_key_; } + void setSustainPedalKey(wchar_t key) { sustain_pedal_key_ = key; } + protected: std::wstring layout_; int up_key_; int down_key_; + int sustain_pedal_key_; }; class ValueDetailsLookup { diff --git a/src/common/midi_manager.cpp b/src/common/midi_manager.cpp index b24131ef..faae0775 100644 --- a/src/common/midi_manager.cpp +++ b/src/common/midi_manager.cpp @@ -114,6 +114,10 @@ void MidiManager::processMidiMessage(const MidiMessage& midi_message, int sample engine_->noteOff(midi_message.getNoteNumber()); else if (midi_message.isAllNotesOff()) engine_->allNotesOff(); + else if (midi_message.isAllSoundOff()) { + engine_->allNotesOff(); + engine_->sustainOff(); + } else if (midi_message.isSustainPedalOn()) engine_->sustainOn(); else if (midi_message.isSustainPedalOff()) diff --git a/src/standalone/helm_computer_keyboard.cpp b/src/standalone/helm_computer_keyboard.cpp index 6615b54f..d4d90a13 100644 --- a/src/standalone/helm_computer_keyboard.cpp +++ b/src/standalone/helm_computer_keyboard.cpp @@ -27,6 +27,7 @@ HelmComputerKeyboard::HelmComputerKeyboard(mopo::HelmEngine* synth, layout_ = mopo::DEFAULT_KEYBOARD; up_key_ = mopo::DEFAULT_KEYBOARD_OCTAVE_UP; down_key_ = mopo::DEFAULT_KEYBOARD_OCTAVE_DOWN; + sustain_pedal_key_ = mopo::DEFAULT_KEYBOARD_SUSTAIN_PEDAL; } HelmComputerKeyboard::~HelmComputerKeyboard() { @@ -96,5 +97,18 @@ bool HelmComputerKeyboard::keyStateChanged(bool isKeyDown, Component *origin) { else keys_pressed_.erase(' '); + if (KeyPress::isKeyCurrentlyDown(sustain_pedal_key_) && + !keys_pressed_.count(sustain_pedal_key_) && isKeyDown) { + keys_pressed_.insert(sustain_pedal_key_); + synth_->sustainOn(); + consumed = true; + } + else if (!KeyPress::isKeyCurrentlyDown(sustain_pedal_key_) && + keys_pressed_.count(sustain_pedal_key_)) { + keys_pressed_.erase(sustain_pedal_key_); + synth_->sustainOff(); + consumed = true; + } + return consumed; }