JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MidiKeyboardComponent.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
51 private Timer
52{
53public:
54 //==============================================================================
61
63 ~MidiKeyboardComponent() override;
64
65 //==============================================================================
73 void setVelocity (float velocity, bool useMousePositionForVelocity);
74
75 //==============================================================================
87 void setMidiChannel (int midiChannelNumber);
88
92 int getMidiChannel() const noexcept { return midiChannel; }
93
106 void setMidiChannelsToDisplay (int midiChannelMask);
107
111 int getMidiChannelsToDisplay() const noexcept { return midiInChannelMask; }
112
113 //==============================================================================
118 void clearKeyMappings();
119
128 void setKeyPressForNote (const KeyPress& key, int midiNoteOffsetFromC);
129
134 void removeKeyPressForNote (int midiNoteOffsetFromC);
135
145 void setKeyPressBaseOctave (int newOctaveNumber);
146
147 //==============================================================================
156 {
157 whiteNoteColourId = 0x1005000,
158 blackNoteColourId = 0x1005001,
159 keySeparatorLineColourId = 0x1005002,
160 mouseOverKeyOverlayColourId = 0x1005003,
161 keyDownOverlayColourId = 0x1005004,
162 textLabelColourId = 0x1005005,
163 shadowColourId = 0x1005006
164 };
165
166 //==============================================================================
174 virtual void drawWhiteNote (int midiNoteNumber, Graphics& g, Rectangle<float> area,
175 bool isDown, bool isOver, Colour lineColour, Colour textColour);
176
184 virtual void drawBlackNote (int midiNoteNumber, Graphics& g, Rectangle<float> area,
185 bool isDown, bool isOver, Colour noteFillColour);
186
196 virtual bool mouseDownOnKey (int midiNoteNumber, const MouseEvent& e);
197
205 virtual bool mouseDraggedToKey (int midiNoteNumber, const MouseEvent& e);
206
211 virtual void mouseUpOnKey (int midiNoteNumber, const MouseEvent& e);
212
219 virtual String getWhiteNoteText (int midiNoteNumber);
220
221 //==============================================================================
223 void mouseMove (const MouseEvent&) override;
225 void mouseDrag (const MouseEvent&) override;
227 void mouseDown (const MouseEvent&) override;
229 void mouseUp (const MouseEvent&) override;
231 void mouseEnter (const MouseEvent&) override;
233 void mouseExit (const MouseEvent&) override;
235 void timerCallback() override;
237 bool keyStateChanged (bool isKeyDown) override;
239 bool keyPressed (const KeyPress&) override;
241 void focusLost (FocusChangeType) override;
243 void colourChanged() override;
244
245private:
246 //==============================================================================
247 void drawKeyboardBackground (Graphics& g, Rectangle<float> area) override final;
248 void drawWhiteKey (int midiNoteNumber, Graphics& g, Rectangle<float> area) override final;
249 void drawBlackKey (int midiNoteNumber, Graphics& g, Rectangle<float> area) override final;
250
251 void handleNoteOn (MidiKeyboardState*, int, int, float) override;
252 void handleNoteOff (MidiKeyboardState*, int, int, float) override;
253
254 //==============================================================================
255 void resetAnyKeysInUse();
256 void updateNoteUnderMouse (Point<float>, bool isDown, int fingerNum);
257 void updateNoteUnderMouse (const MouseEvent&, bool isDown);
258 void repaintNote (int midiNoteNumber);
259
260 //==============================================================================
261 MidiKeyboardState& state;
262 int midiChannel = 1, midiInChannelMask = 0xffff;
263 int keyMappingOctave = 6;
264
265 float velocity = 1.0f;
266 bool useMousePositionForVelocity = true;
267
268 Array<int> mouseOverNotes, mouseDownNotes;
269 Array<KeyPress> keyPresses;
270 Array<int> keyPressNotes;
271 BigInteger keysPressed, keysCurrentlyDrawnDown;
272
273 std::atomic<bool> noPendingUpdates { true };
274
275 //==============================================================================
277};
278
279} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
An arbitrarily large integer class.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
A graphics context, used for drawing a component or image.
Represents a key press, including any modifier keys that are needed.
A base class for drawing a custom MIDI keyboard component.
Orientation
The direction of the keyboard.
A component that displays a piano keyboard, whose notes can be clicked on.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the keyboard.
int getMidiChannelsToDisplay() const noexcept
Returns the current set of midi channels represented by the component.
int getMidiChannel() const noexcept
Returns the midi channel that the keyboard is using for midi messages.
Receives events from a MidiKeyboardState object.
Represents a piano keyboard, keeping track of which keys are currently pressed.
Contains position and status information about a mouse event.
A pair of (x, y) coordinates.
Definition juce_Point.h:42
Manages a rectangle and allows geometric operations to be performed on it.
The JUCE String class!
Definition juce_String.h:53
Makes repeated callbacks to a virtual method at a specified time interval.
Definition juce_Timer.h:52
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.