OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_MidiKeyboardState.h
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 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
23 namespace juce
24{
25
26//==============================================================================
41 class JUCE_API MidiKeyboardState
42{
43 public:
44 //==============================================================================
45 MidiKeyboardState();
46
47 //==============================================================================
56 void reset();
57
63 bool isNoteOn (int midiChannel, int midiNoteNumber) const noexcept;
64
72 bool isNoteOnForChannels (int midiChannelMask, int midiNoteNumber) const noexcept;
73
82 void noteOn (int midiChannel, int midiNoteNumber, float velocity);
83
94 void noteOff (int midiChannel, int midiNoteNumber, float velocity);
95
103 void allNotesOff (int midiChannel);
104
105 //==============================================================================
111 void processNextMidiEvent (const MidiMessage& message);
112
131 void processNextMidiBuffer (MidiBuffer& buffer,
132 int startSample,
133 int numSamples,
134 bool injectIndirectEvents);
135
136 //==============================================================================
138 class JUCE_API Listener
139 {
140 public:
141 //==============================================================================
142 virtual ~Listener() = default;
143
144 //==============================================================================
154 virtual void handleNoteOn (MidiKeyboardState* source,
155 int midiChannel, int midiNoteNumber, float velocity) = 0;
156
166 virtual void handleNoteOff (MidiKeyboardState* source,
167 int midiChannel, int midiNoteNumber, float velocity) = 0;
168 };
169
173 void addListener (Listener* listener);
174
178 void removeListener (Listener* listener);
179
180 private:
181 //==============================================================================
182 CriticalSection lock;
183 std::atomic<uint16> noteStates[128];
184 MidiBuffer eventsToAdd;
185 ListenerList<Listener> listeners;
186
187 void noteOnInternal (int midiChannel, int midiNoteNumber, float velocity);
188 void noteOffInternal (int midiChannel, int midiNoteNumber, float velocity);
189
190 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiKeyboardState)
191};
192
193 using MidiKeyboardStateListener = MidiKeyboardState::Listener;
194
195} // namespace juce
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::ListenerList
Definition juce_ListenerList.h:81
juce::MidiBuffer
Definition juce_MidiBuffer.h:145
juce::MidiKeyboardState::Listener
Definition juce_MidiKeyboardState.h:139
juce::MidiKeyboardState::Listener::handleNoteOff
virtual void handleNoteOff(MidiKeyboardState *source, int midiChannel, int midiNoteNumber, float velocity)=0
juce::MidiKeyboardState::Listener::handleNoteOn
virtual void handleNoteOn(MidiKeyboardState *source, int midiChannel, int midiNoteNumber, float velocity)=0
juce::MidiKeyboardState
Definition juce_MidiKeyboardState.h:42
juce::MidiMessage
Definition juce_MidiMessage.h:35