26MidiKeyboardState::MidiKeyboardState()
41 jassert (midiChannel > 0 && midiChannel <= 16);
44 && (noteStates[n] & (1 << (midiChannel - 1))) != 0;
55 jassert (midiChannel > 0 && midiChannel <= 16);
70void MidiKeyboardState::noteOnInternal (
const int midiChannel,
const int midiNoteNumber,
const float velocity)
75 listeners.call ([&] (Listener&
l) {
l.handleNoteOn (
this, midiChannel,
midiNoteNumber, velocity); });
93void MidiKeyboardState::noteOffInternal (
const int midiChannel,
const int midiNoteNumber,
const float velocity)
98 listeners.call ([&] (Listener&
l) {
l.handleNoteOff (
this, midiChannel,
midiNoteNumber, velocity); });
106 if (midiChannel <= 0)
108 for (
int i = 1; i <= 16; ++i)
113 for (
int i = 0; i < 128; ++i)
114 noteOff (midiChannel, i, 0.0f);
130 for (
int i = 0; i < 128; ++i)
131 noteOffInternal (message.
getChannel(), i, 0.0f);
136 const int startSample,
137 const int numSamples,
150 for (
const auto metadata : eventsToAdd)
164 listeners.add (listener);
170 listeners.remove (listener);
Automatically locks and unlocks a mutex object.
Holds a sequence of time-stamped midi events.
int getFirstEventTime() const noexcept
Returns the sample number of the first event in the buffer.
int getLastEventTime() const noexcept
Returns the sample number of the last event in the buffer.
bool addEvent(const MidiMessage &midiMessage, int sampleNumber)
Adds an event to the buffer.
void clear() noexcept
Removes all events from the buffer.
Receives events from a MidiKeyboardState object.
void processNextMidiBuffer(MidiBuffer &buffer, int startSample, int numSamples, bool injectIndirectEvents)
Scans a midi stream for up/down events and adds its own events to it.
void addListener(Listener *listener)
Registers a listener for callbacks when keys go up or down.
void noteOff(int midiChannel, int midiNoteNumber, float velocity)
Turns a specified note off.
void allNotesOff(int midiChannel)
This will turn off any currently-down notes for the given midi channel.
void processNextMidiEvent(const MidiMessage &message)
Looks at a key-up/down event and uses it to update the state of this object.
void removeListener(Listener *listener)
Deregisters a listener.
bool isNoteOn(int midiChannel, int midiNoteNumber) const noexcept
Returns true if the given midi key is currently held down for the given midi channel.
void noteOn(int midiChannel, int midiNoteNumber, float velocity)
Turns a specified note on.
void reset()
Resets the state of the object.
bool isNoteOnForChannels(int midiChannelMask, int midiNoteNumber) const noexcept
Returns true if the given midi key is currently held down on any of a set of midi channels.
Encapsulates a MIDI message.
bool isNoteOn(bool returnTrueForVelocity0=false) const noexcept
Returns true if this message is a 'key-down' event.
float getFloatVelocity() const noexcept
Returns the velocity of a note-on or note-off message.
int getChannel() const noexcept
Returns the midi channel associated with the message.
bool isNoteOff(bool returnTrueForNoteOnVelocity0=true) const noexcept
Returns true if this message is a 'key-up' event.
static MidiMessage noteOn(int channel, int noteNumber, float velocity) noexcept
Creates a key-down message (using a floating-point velocity).
int getNoteNumber() const noexcept
Returns the midi note number for note-on and note-off messages.
bool isAllNotesOff() const noexcept
Checks whether this message is an all-notes-off message.
static MidiMessage noteOff(int channel, int noteNumber, float velocity) noexcept
Creates a key-up message.
static uint32 getMillisecondCounter() noexcept
Returns the number of millisecs since a fixed event (usually system startup).
void zerostruct(Type &structure) noexcept
Overwrites a structure or object with zeros.
unsigned short uint16
A platform-independent 16-bit unsigned integer type.
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...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.