openshot-audio  0.1.4
juce_MidiKeyboardState.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_MIDIKEYBOARDSTATE_H_INCLUDED
26 #define JUCE_MIDIKEYBOARDSTATE_H_INCLUDED
27 
28 class MidiKeyboardState;
29 
30 
31 //==============================================================================
38 {
39 public:
40  //==============================================================================
43 
44  //==============================================================================
54  virtual void handleNoteOn (MidiKeyboardState* source,
55  int midiChannel, int midiNoteNumber, float velocity) = 0;
56 
66  virtual void handleNoteOff (MidiKeyboardState* source,
67  int midiChannel, int midiNoteNumber) = 0;
68 };
69 
70 
71 //==============================================================================
85 {
86 public:
87  //==============================================================================
90 
91  //==============================================================================
100  void reset();
101 
107  bool isNoteOn (int midiChannel, int midiNoteNumber) const noexcept;
108 
116  bool isNoteOnForChannels (int midiChannelMask, int midiNoteNumber) const noexcept;
117 
126  void noteOn (int midiChannel, int midiNoteNumber, float velocity);
127 
138  void noteOff (int midiChannel, int midiNoteNumber);
139 
147  void allNotesOff (int midiChannel);
148 
149  //==============================================================================
155  void processNextMidiEvent (const MidiMessage& message);
156 
175  void processNextMidiBuffer (MidiBuffer& buffer,
176  int startSample,
177  int numSamples,
178  bool injectIndirectEvents);
179 
180  //==============================================================================
184  void addListener (MidiKeyboardStateListener* listener);
185 
189  void removeListener (MidiKeyboardStateListener* listener);
190 
191 private:
192  //==============================================================================
193  CriticalSection lock;
194  uint16 noteStates [128];
195  MidiBuffer eventsToAdd;
197 
198  void noteOnInternal (int midiChannel, int midiNoteNumber, float velocity);
199  void noteOffInternal (int midiChannel, int midiNoteNumber);
200 
202 };
203 
204 
205 #endif // JUCE_MIDIKEYBOARDSTATE_H_INCLUDED
virtual ~MidiKeyboardStateListener()
Definition: juce_MidiKeyboardState.h:42
#define noexcept
Definition: juce_CompilerSupport.h:141
unsigned short uint16
Definition: juce_MathsFunctions.h:47
MidiKeyboardStateListener() noexcept
Definition: juce_MidiKeyboardState.h:41
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_CriticalSection.h:47
Definition: juce_Array.h:60
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_MidiKeyboardState.h:37
Definition: juce_MidiBuffer.h:43
Definition: juce_MidiMessage.h:35
Definition: juce_MidiKeyboardState.h:84