OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_MidiKeyboardState.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26class MidiKeyboardState;
27
28
29//==============================================================================
38{
39public:
40 //==============================================================================
41 MidiKeyboardStateListener() = default;
42 virtual ~MidiKeyboardStateListener() = default;
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, float velocity) = 0;
68};
69
70
71//==============================================================================
86class JUCE_API MidiKeyboardState
87{
88public:
89 //==============================================================================
92
93 //==============================================================================
102 void reset();
103
109 bool isNoteOn (int midiChannel, int midiNoteNumber) const noexcept;
110
118 bool isNoteOnForChannels (int midiChannelMask, int midiNoteNumber) const noexcept;
119
128 void noteOn (int midiChannel, int midiNoteNumber, float velocity);
129
140 void noteOff (int midiChannel, int midiNoteNumber, float velocity);
141
149 void allNotesOff (int midiChannel);
150
151 //==============================================================================
157 void processNextMidiEvent (const MidiMessage& message);
158
177 void processNextMidiBuffer (MidiBuffer& buffer,
178 int startSample,
179 int numSamples,
181
182 //==============================================================================
186 void addListener (MidiKeyboardStateListener* listener);
187
191 void removeListener (MidiKeyboardStateListener* listener);
192
193private:
194 //==============================================================================
195 CriticalSection lock;
196 uint16 noteStates [128];
197 MidiBuffer eventsToAdd;
199
200 void noteOnInternal (int midiChannel, int midiNoteNumber, float velocity);
201 void noteOffInternal (int midiChannel, int midiNoteNumber, float velocity);
202
203 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiKeyboardState)
204};
205
206} // namespace juce
virtual void handleNoteOff(MidiKeyboardState *source, int midiChannel, int midiNoteNumber, float velocity)=0
virtual void handleNoteOn(MidiKeyboardState *source, int midiChannel, int midiNoteNumber, float velocity)=0