|
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 |
Collects incoming realtime MIDI messages and turns them into blocks suitable for processing by a block-based audio callback. More...
#include "juce_MidiMessageCollector.h"
Public Member Functions | |
| MidiMessageCollector () | |
| Creates a MidiMessageCollector. | |
| ~MidiMessageCollector () override | |
| Destructor. | |
| void | reset (double sampleRate) |
| Clears any messages from the queue. | |
| void | addMessageToQueue (const MidiMessage &message) |
| Takes an incoming real-time message and adds it to the queue. | |
| void | removeNextBlockOfMessages (MidiBuffer &destBuffer, int numSamples) |
| Removes all the pending messages from the queue as a buffer. | |
| void | ensureStorageAllocated (size_t bytes) |
| Preallocates storage for collected messages. | |
| void | handleNoteOn (MidiKeyboardState *, int midiChannel, int midiNoteNumber, float velocity) override |
| Called when one of the MidiKeyboardState's keys is pressed. | |
| void | handleNoteOff (MidiKeyboardState *, int midiChannel, int midiNoteNumber, float velocity) override |
| Called when one of the MidiKeyboardState's keys is released. | |
| void | handleIncomingMidiMessage (MidiInput *, const MidiMessage &) override |
| Receives an incoming message. | |
Public Member Functions inherited from juce::MidiInputCallback | |
| virtual | ~MidiInputCallback ()=default |
| Destructor. | |
| virtual void | handlePartialSysexMessage (MidiInput *source, const uint8 *messageData, int numBytesSoFar, double timestamp) |
| Notification sent each time a packet of a multi-packet sysex message arrives. | |
Collects incoming realtime MIDI messages and turns them into blocks suitable for processing by a block-based audio callback.
The class can also be used as either a MidiKeyboardState::Listener or a MidiInputCallback so it can easily use a midi input or keyboard component as its source.
@tags{Audio}
Definition at line 38 of file juce_MidiMessageCollector.h.
| juce::MidiMessageCollector::MidiMessageCollector | ( | ) |
Creates a MidiMessageCollector.
Definition at line 26 of file juce_MidiMessageCollector.cpp.
|
override |
Destructor.
Definition at line 30 of file juce_MidiMessageCollector.cpp.
| void juce::MidiMessageCollector::addMessageToQueue | ( | const MidiMessage & | message | ) |
Takes an incoming real-time message and adds it to the queue.
The message's timestamp is taken, and it will be ready for retrieval as part of the block returned by the next call to removeNextBlockOfMessages().
This method is fully thread-safe when overlapping calls are made with removeNextBlockOfMessages().
Definition at line 49 of file juce_MidiMessageCollector.cpp.
Preallocates storage for collected messages.
This can be called before audio processing begins to ensure that there is sufficient space for the expected MIDI messages, in order to avoid allocations within the audio callback.
Definition at line 131 of file juce_MidiMessageCollector.cpp.
|
overridevirtual |
Receives an incoming message.
A MidiInput object will call this method when a midi event arrives. It'll be called on a high-priority system thread, so avoid doing anything time-consuming in here, and avoid making any UI calls. You might find the MidiBuffer class helpful for queueing incoming messages for use later.
| source | the MidiInput object that generated the message |
| message | the incoming message. The message's timestamp is set to a value equivalent to (Time::getMillisecondCounter() / 1000.0) to specify the time when the message arrived |
Implements juce::MidiInputCallback.
Definition at line 153 of file juce_MidiMessageCollector.cpp.
|
overridevirtual |
Called when one of the MidiKeyboardState's keys is released.
This will be called synchronously when the state is either processing a buffer in its MidiKeyboardState::processNextMidiBuffer() method, or when a note is being played with its MidiKeyboardState::noteOff() method.
Note that this callback could happen from an audio callback thread, so be careful not to block, and avoid any UI activity in the callback.
Implements juce::MidiKeyboardState::Listener.
Definition at line 145 of file juce_MidiMessageCollector.cpp.
|
overridevirtual |
Called when one of the MidiKeyboardState's keys is pressed.
This will be called synchronously when the state is either processing a buffer in its MidiKeyboardState::processNextMidiBuffer() method, or when a note is being played with its MidiKeyboardState::noteOn() method.
Note that this callback could happen from an audio callback thread, so be careful not to block, and avoid any UI activity in the callback.
Implements juce::MidiKeyboardState::Listener.
Definition at line 137 of file juce_MidiMessageCollector.cpp.
| void juce::MidiMessageCollector::removeNextBlockOfMessages | ( | MidiBuffer & | destBuffer, |
| int | numSamples | ||
| ) |
Removes all the pending messages from the queue as a buffer.
This will also correct the messages' timestamps to make sure they're in the range 0 to numSamples - 1.
This call should be made regularly by something like an audio processing callback, because the time that it happens is used in calculating the midi event positions.
This method is fully thread-safe when overlapping calls are made with addMessageToQueue().
Precondition: numSamples must be greater than 0.
Definition at line 71 of file juce_MidiMessageCollector.cpp.
Clears any messages from the queue.
You need to call this method before starting to use the collector, so that it knows the correct sample rate to use.
Definition at line 35 of file juce_MidiMessageCollector.cpp.