Loading...
Searching...
No Matches
juce_MidiMessageCollector.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API MidiMessageCollector : public MidiKeyboardState::Listener,
public MidiInputCallback
{
public:
//==============================================================================
MidiMessageCollector();
~MidiMessageCollector() override;
//==============================================================================
void reset (double sampleRate);
void addMessageToQueue (const MidiMessage& message);
void removeNextBlockOfMessages (MidiBuffer& destBuffer, int numSamples);
void ensureStorageAllocated (size_t bytes);
//==============================================================================
void handleNoteOn (MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity) override;
void handleNoteOff (MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity) override;
void handleIncomingMidiMessage (MidiInput*, const MidiMessage&) override;
private:
//==============================================================================
double lastCallbackTime = 0;
CriticalSection midiCallbackLock;
MidiBuffer incomingMessages;
double sampleRate = 44100.0;
#if JUCE_DEBUG
bool hasCalledReset = false;
#endif
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiMessageCollector)
};
} // namespace juce
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::MidiBuffer
Definition juce_MidiBuffer.h:145
juce::MidiInputCallback
Definition juce_MidiDevices.h:277
juce::MidiInput
Definition juce_MidiDevices.h:164
juce::MidiKeyboardState::Listener
Definition juce_MidiKeyboardState.h:139
juce::MidiKeyboardState
Definition juce_MidiKeyboardState.h:42
juce::MidiMessageCollector::handleIncomingMidiMessage
void handleIncomingMidiMessage(MidiInput *, const MidiMessage &) override
Definition juce_MidiMessageCollector.cpp:153
juce::MidiMessageCollector::handleNoteOn
void handleNoteOn(MidiKeyboardState *, int midiChannel, int midiNoteNumber, float velocity) override
Definition juce_MidiMessageCollector.cpp:137
juce::MidiMessageCollector::removeNextBlockOfMessages
void removeNextBlockOfMessages(MidiBuffer &destBuffer, int numSamples)
Definition juce_MidiMessageCollector.cpp:71
juce::MidiMessageCollector::handleNoteOff
void handleNoteOff(MidiKeyboardState *, int midiChannel, int midiNoteNumber, float velocity) override
Definition juce_MidiMessageCollector.cpp:145
juce::MidiMessageCollector::MidiMessageCollector
MidiMessageCollector()
Definition juce_MidiMessageCollector.cpp:26
juce::MidiMessageCollector::ensureStorageAllocated
void ensureStorageAllocated(size_t bytes)
Definition juce_MidiMessageCollector.cpp:131
juce::MidiMessageCollector::reset
void reset(double sampleRate)
Definition juce_MidiMessageCollector.cpp:35
juce::MidiMessageCollector::addMessageToQueue
void addMessageToQueue(const MidiMessage &message)
Definition juce_MidiMessageCollector.cpp:49
juce::MidiMessage
Definition juce_MidiMessage.h:35