1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added method MidiMessage::keySignatureMetaEvent

This commit is contained in:
jules 2013-09-27 19:43:43 +01:00
parent 329127ad87
commit 354b5d38ae
2 changed files with 18 additions and 5 deletions

View file

@ -777,22 +777,19 @@ MidiMessage MidiMessage::timeSignatureMetaEvent (const int numerator, const int
++powerOfTwo;
}
const uint8 d[] = { 0xff, 0x58, 0x04, (uint8) numerator,
(uint8) powerOfTwo, 1, 96 };
const uint8 d[] = { 0xff, 0x58, 0x04, (uint8) numerator, (uint8) powerOfTwo, 1, 96 };
return MidiMessage (d, 7, 0.0);
}
MidiMessage MidiMessage::midiChannelMetaEvent (const int channel) noexcept
{
const uint8 d[] = { 0xff, 0x20, 0x01, (uint8) jlimit (0, 0xff, channel - 1) };
return MidiMessage (d, 4, 0.0);
}
bool MidiMessage::isKeySignatureMetaEvent() const noexcept
{
return getMetaEventType() == 89;
return getMetaEventType() == 0x59;
}
int MidiMessage::getKeySignatureNumberOfSharpsOrFlats() const noexcept
@ -805,6 +802,14 @@ bool MidiMessage::isKeySignatureMajorKey() const noexcept
return getMetaEventData()[1] == 0;
}
MidiMessage MidiMessage::keySignatureMetaEvent (int numberOfSharpsOrFlats, bool isMinorKey)
{
jassert (numberOfSharpsOrFlats >= -7 && numberOfSharpsOrFlats <= 7);
const uint8 d[] = { 0xff, 0x59, 0x02, (uint8) numberOfSharpsOrFlats, isMinorKey ? (uint8) 1 : (uint8) 0 };
return MidiMessage (d, 5, 0.0);
}
MidiMessage MidiMessage::endOfTrack() noexcept
{
return MidiMessage (0xff, 0x2f, 0, 0.0);

View file

@ -622,6 +622,14 @@ public:
*/
bool isKeySignatureMajorKey() const noexcept;
/** Creates a key-signature meta-event.
@param numberOfSharpsOrFlats if positive, this indicates the number of sharps
in the key; if negative, the number of flats
@param isMinorKey if true, the key is minor; if false, it is major
@see isKeySignatureMetaEvent
*/
static MidiMessage keySignatureMetaEvent (int numberOfSharpsOrFlats, bool isMinorKey);
//==============================================================================
/** Returns true if this is a 'channel' meta-event.