mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added new helper function MidiMessage::getDescription(), replacing some code that was previously in the Juce Demo.
This commit is contained in:
parent
5854829fcf
commit
497f286b53
3 changed files with 32 additions and 27 deletions
|
|
@ -309,6 +309,31 @@ uint8* MidiMessage::allocateSpace (int bytes)
|
|||
return preallocatedData.asBytes;
|
||||
}
|
||||
|
||||
String MidiMessage::getDescription() const
|
||||
{
|
||||
if (isNoteOn()) return "Note on " + MidiMessage::getMidiNoteName (getNoteNumber(), true, true, 3) + " Velocity " + String (getVelocity()) + " Channel " + String (getChannel());
|
||||
if (isNoteOff()) return "Note off " + MidiMessage::getMidiNoteName (getNoteNumber(), true, true, 3) + " Velocity " + String (getVelocity()) + " Channel " + String (getChannel());
|
||||
if (isProgramChange()) return "Program change " + String (getProgramChangeNumber()) + " Channel " + String (getChannel());
|
||||
if (isPitchWheel()) return "Pitch wheel " + String (getPitchWheelValue()) + " Channel " + String (getChannel());
|
||||
if (isAftertouch()) return "Aftertouch " + MidiMessage::getMidiNoteName (getNoteNumber(), true, true, 3) + ": " + String (getAfterTouchValue()) + " Channel " + String (getChannel());
|
||||
if (isChannelPressure()) return "Channel pressure " + String (getChannelPressureValue()) + " Channel " + String (getChannel());
|
||||
if (isAllNotesOff()) return "All notes off Channel " + String (getChannel());
|
||||
if (isAllSoundOff()) return "All sound off Channel " + String (getChannel());
|
||||
if (isMetaEvent()) return "Meta event";
|
||||
|
||||
if (isController())
|
||||
{
|
||||
String name (MidiMessage::getControllerName (getControllerNumber()));
|
||||
|
||||
if (name.isEmpty())
|
||||
name = String (getControllerNumber());
|
||||
|
||||
return "Controller " + name + ": " + String (getControllerValue()) + " Channel " + String (getChannel());
|
||||
}
|
||||
|
||||
return String::toHexString (getRawData(), getRawDataSize());
|
||||
}
|
||||
|
||||
int MidiMessage::getChannel() const noexcept
|
||||
{
|
||||
const uint8* const data = getRawData();
|
||||
|
|
|
|||
|
|
@ -125,6 +125,12 @@ public:
|
|||
*/
|
||||
int getRawDataSize() const noexcept { return size; }
|
||||
|
||||
//==============================================================================
|
||||
/** Returns a human-readable description of the midi message as a string,
|
||||
for example "Note On C#3 Velocity 120 Channel 1".
|
||||
*/
|
||||
String getDescription() const;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the timestamp associated with this message.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue