45 incomingMessages.
clear();
83 auto msElapsed =
timeNow - lastCallbackTime;
87 if (! incomingMessages.
isEmpty())
99 auto iter = incomingMessages.
cbegin();
112 const auto pos = ((meta.samplePosition - startSample) * scale) >> 10;
113 destBuffer.addEvent (meta.data, meta.numBytes, jlimit (0, numSamples - 1, pos));
122 for (
const auto metadata : incomingMessages)
124 jlimit (0, numSamples - 1,
metadata.samplePosition + startSample));
127 incomingMessages.
clear();
Automatically locks and unlocks a mutex object.
Holds a sequence of time-stamped midi events.
void ensureSize(size_t minimumNumBytes)
Preallocates some memory for the buffer to use.
MidiBufferIterator cbegin() const noexcept
Get a read-only iterator pointing to the beginning of this buffer.
MidiBufferIterator findNextSamplePosition(int samplePosition) const noexcept
Get an iterator pointing to the first event with a timestamp greater-than or equal-to samplePosition.
MidiBufferIterator cend() const noexcept
Get a read-only iterator pointing one past the end of this buffer.
bool isEmpty() const noexcept
Returns true if the buffer is empty.
bool addEvent(const MidiMessage &midiMessage, int sampleNumber)
Adds an event to the buffer.
void clear() noexcept
Removes all events from the buffer.
Represents a piano keyboard, keeping track of which keys are currently pressed.
void handleIncomingMidiMessage(MidiInput *, const MidiMessage &) override
Receives an incoming message.
void handleNoteOn(MidiKeyboardState *, int midiChannel, int midiNoteNumber, float velocity) override
Called when one of the MidiKeyboardState's keys is pressed.
void removeNextBlockOfMessages(MidiBuffer &destBuffer, int numSamples)
Removes all the pending messages from the queue as a buffer.
void handleNoteOff(MidiKeyboardState *, int midiChannel, int midiNoteNumber, float velocity) override
Called when one of the MidiKeyboardState's keys is released.
MidiMessageCollector()
Creates a MidiMessageCollector.
void ensureStorageAllocated(size_t bytes)
Preallocates storage for collected messages.
~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.
Encapsulates a MIDI message.
static MidiMessage noteOn(int channel, int noteNumber, float velocity) noexcept
Creates a key-down message (using a floating-point velocity).
double getTimeStamp() const noexcept
Returns the timestamp associated with this message.
static MidiMessage noteOff(int channel, int noteNumber, float velocity) noexcept
Creates a key-up message.
void setTimeStamp(double newTimestamp) noexcept
Changes the message's associated timestamp.
static double getMillisecondCounterHiRes() noexcept
Returns the number of millisecs since a fixed event (usually system startup).
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.