From 44d52ffcef8a4b3738feff7a24fb14cd6f8ce3cf Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 17 Jan 2014 09:43:42 +0000 Subject: [PATCH] Added a method to MidiKeyboardComponent --- .../juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp | 6 ++++++ modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h | 8 +++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index 56dbab2e4a..88004e6897 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -260,6 +260,12 @@ int MidiKeyboardComponent::getKeyStartPosition (const int midiNoteNumber) const return x; } +int MidiKeyboardComponent::getNoteAtPosition (Point p) +{ + float v; + return xyToNote (p, v); +} + const uint8 MidiKeyboardComponent::whiteNotes[] = { 0, 2, 4, 5, 7, 9, 11 }; const uint8 MidiKeyboardComponent::blackNotes[] = { 1, 3, 6, 8, 10 }; diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h index fd0d37c7b1..21bca127d9 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h @@ -96,7 +96,6 @@ public: void setMidiChannel (int midiChannelNumber); /** Returns the midi channel that the keyboard is using for midi messages. - @see setMidiChannel */ int getMidiChannel() const noexcept { return midiChannel; } @@ -116,7 +115,6 @@ public: void setMidiChannelsToDisplay (int midiChannelMask); /** Returns the current set of midi channels represented by the component. - This is the value that was set with setMidiChannelsToDisplay(). */ int getMidiChannelsToDisplay() const noexcept { return midiInChannelMask; } @@ -168,7 +166,6 @@ public: int getLowestVisibleKey() const noexcept { return (int) firstKey; } /** Returns the length of the black notes. - This will be their vertical or horizontal length, depending on the keyboard's orientation. */ int getBlackNoteLength() const noexcept { return blackNoteLength; } @@ -205,6 +202,9 @@ public: */ int getKeyStartPosition (int midiNoteNumber) const; + /** Returns the key at a given coordinate. */ + int getNoteAtPosition (Point position); + //============================================================================== /** Deletes all key-mappings. @see setKeyPressForNote @@ -318,9 +318,7 @@ protected: const Colour& noteFillColour); /** Allows text to be drawn on the white notes. - By default this is used to label the C in each octave, but could be used for other things. - @see setOctaveForMiddleC */ virtual String getWhiteNoteText (const int midiNoteNumber);