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_MPEKeyboardComponent.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//==============================================================================
44 private Timer
45{
46public:
47 //==============================================================================
53 MPEKeyboardComponent (MPEInstrument& instrument, Orientation orientation);
54
56 virtual ~MPEKeyboardComponent() override;
57
58 //==============================================================================
60 void setVelocity (float newVelocity) { velocity = jlimit (0.0f, 1.0f, newVelocity); }
61
63 void setPressure (float newPressure) { pressure = jlimit (0.0f, 1.0f, newPressure); }
64
66 void setLift (float newLift) { lift = jlimit (0.0f, 1.0f, newLift); }
67
71 void setUseMouseSourcePressureForStrike (bool usePressureForStrike) { useMouseSourcePressureForStrike = usePressureForStrike; }
72
73 //==============================================================================
82 {
83 whiteNoteColourId = 0x1006000,
84 blackNoteColourId = 0x1006001,
85 textLabelColourId = 0x1006002,
86 noteCircleFillColourId = 0x1006003,
87 noteCircleOutlineColourId = 0x1006004
88 };
89
90 //==============================================================================
92 void mouseDrag (const MouseEvent&) override;
94 void mouseDown (const MouseEvent&) override;
96 void mouseUp (const MouseEvent&) override;
98 void focusLost (FocusChangeType) override;
100 void colourChanged() override;
101
102private:
103 //==============================================================================
104 struct MPENoteComponent;
105
106 //==============================================================================
107 void drawKeyboardBackground (Graphics& g, Rectangle<float> area) override;
108 void drawWhiteKey (int midiNoteNumber, Graphics& g, Rectangle<float> area) override;
109 void drawBlackKey (int midiNoteNumber, Graphics& g, Rectangle<float> area) override;
110
111 void updateNoteData (MPENote&);
112
113 void noteAdded (MPENote) override;
114 void notePressureChanged (MPENote) override;
115 void notePitchbendChanged (MPENote) override;
116 void noteTimbreChanged (MPENote) override;
117 void noteReleased (MPENote) override;
118 void zoneLayoutChanged() override;
119
120 void timerCallback() override;
121
122 //==============================================================================
123 MPEValue mousePositionToPitchbend (int, Point<float>);
124 MPEValue mousePositionToTimbre (Point<float>);
125
126 void addNewNote (MPENote);
127 void removeNote (MPENote);
128
129 void handleNoteOns (std::set<MPENote>&);
130 void handleNoteOffs (std::set<MPENote>&);
131 void updateNoteComponentBounds (const MPENote&, MPENoteComponent&);
132 void updateNoteComponents();
133
134 void updateZoneLayout();
135
136 //==============================================================================
137 MPEInstrument& instrument;
139
140 CriticalSection activeNotesLock;
143 std::map<int, uint16> sourceIDMap;
144
145 float velocity = 0.7f, pressure = 1.0f, lift = 0.0f;
146 bool useMouseSourcePressureForStrike = false;
147 int perNotePitchbendRange = 48;
148
149 //==============================================================================
151};
152
153} // namespace juce
A graphics context, used for drawing a component or image.
A base class for drawing a custom MIDI keyboard component.
Orientation
The direction of the keyboard.
Derive from this class to be informed about any changes in the MPE notes played by this instrument,...
This class represents an instrument handling MPE.
A component that displays an MPE-compatible keyboard, whose notes can be clicked on.
void setUseMouseSourcePressureForStrike(bool usePressureForStrike)
Use this to enable the mouse source pressure to be used for the initial note-on velocity,...
void setPressure(float newPressure)
Sets the pressure value that will be used for new notes.
void setLift(float newLift)
Sets the note-off velocity, or "lift", value that will be used when notes are released.
void setVelocity(float newVelocity)
Sets the note-on velocity, or "strike", value that will be used when triggering new notes.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the keyboard.
This class represents a single value for any of the MPE dimensions of control.
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.
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.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
This struct represents a playing MPE note.