Massive UI work
[juce-lv2.git] / juce / source / src / audio / midi / juce_MidiMessage.h
bloba05117101176bc186389c2188db6937c7d65ed4f
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_MIDIMESSAGE_JUCEHEADER__
27 #define __JUCE_MIDIMESSAGE_JUCEHEADER__
29 #include "../../text/juce_String.h"
32 //==============================================================================
33 /**
34 Encapsulates a MIDI message.
36 @see MidiMessageSequence, MidiOutput, MidiInput
38 class JUCE_API MidiMessage
40 public:
41 //==============================================================================
42 /** Creates a 3-byte short midi message.
44 @param byte1 message byte 1
45 @param byte2 message byte 2
46 @param byte3 message byte 3
47 @param timeStamp the time to give the midi message - this value doesn't
48 use any particular units, so will be application-specific
50 MidiMessage (int byte1, int byte2, int byte3, double timeStamp = 0) noexcept;
52 /** Creates a 2-byte short midi message.
54 @param byte1 message byte 1
55 @param byte2 message byte 2
56 @param timeStamp the time to give the midi message - this value doesn't
57 use any particular units, so will be application-specific
59 MidiMessage (int byte1, int byte2, double timeStamp = 0) noexcept;
61 /** Creates a 1-byte short midi message.
63 @param byte1 message byte 1
64 @param timeStamp the time to give the midi message - this value doesn't
65 use any particular units, so will be application-specific
67 MidiMessage (int byte1, double timeStamp = 0) noexcept;
69 /** Creates a midi message from a block of data. */
70 MidiMessage (const void* data, int numBytes, double timeStamp = 0);
72 /** Reads the next midi message from some data.
74 This will read as many bytes from a data stream as it needs to make a
75 complete message, and will return the number of bytes it used. This lets
76 you read a sequence of midi messages from a file or stream.
78 @param data the data to read from
79 @param maxBytesToUse the maximum number of bytes it's allowed to read
80 @param numBytesUsed returns the number of bytes that were actually needed
81 @param lastStatusByte in a sequence of midi messages, the initial byte
82 can be dropped from a message if it's the same as the
83 first byte of the previous message, so this lets you
84 supply the byte to use if the first byte of the message
85 has in fact been dropped.
86 @param timeStamp the time to give the midi message - this value doesn't
87 use any particular units, so will be application-specific
89 MidiMessage (const void* data, int maxBytesToUse,
90 int& numBytesUsed, uint8 lastStatusByte,
91 double timeStamp = 0);
93 /** Creates an active-sense message.
94 Since the MidiMessage has to contain a valid message, this default constructor
95 just initialises it with an empty sysex message.
97 MidiMessage() noexcept;
99 /** Creates a copy of another midi message. */
100 MidiMessage (const MidiMessage& other);
102 /** Creates a copy of another midi message, with a different timestamp. */
103 MidiMessage (const MidiMessage& other, double newTimeStamp);
105 /** Destructor. */
106 ~MidiMessage();
108 /** Copies this message from another one. */
109 MidiMessage& operator= (const MidiMessage& other);
111 //==============================================================================
112 /** Returns a pointer to the raw midi data.
114 @see getRawDataSize
116 uint8* getRawData() const noexcept { return data; }
118 /** Returns the number of bytes of data in the message.
120 @see getRawData
122 int getRawDataSize() const noexcept { return size; }
124 //==============================================================================
125 /** Returns the timestamp associated with this message.
127 The exact meaning of this time and its units will vary, as messages are used in
128 a variety of different contexts.
130 If you're getting the message from a midi file, this could be a time in seconds, or
131 a number of ticks - see MidiFile::convertTimestampTicksToSeconds().
133 If the message is being used in a MidiBuffer, it might indicate the number of
134 audio samples from the start of the buffer.
136 If the message was created by a MidiInput, see MidiInputCallback::handleIncomingMidiMessage()
137 for details of the way that it initialises this value.
139 @see setTimeStamp, addToTimeStamp
141 double getTimeStamp() const noexcept { return timeStamp; }
143 /** Changes the message's associated timestamp.
145 The units for the timestamp will be application-specific - see the notes for getTimeStamp().
147 @see addToTimeStamp, getTimeStamp
149 void setTimeStamp (double newTimestamp) noexcept { timeStamp = newTimestamp; }
151 /** Adds a value to the message's timestamp.
153 The units for the timestamp will be application-specific.
155 void addToTimeStamp (double delta) noexcept { timeStamp += delta; }
157 //==============================================================================
158 /** Returns the midi channel associated with the message.
160 @returns a value 1 to 16 if the message has a channel, or 0 if it hasn't (e.g.
161 if it's a sysex)
162 @see isForChannel, setChannel
164 int getChannel() const noexcept;
166 /** Returns true if the message applies to the given midi channel.
168 @param channelNumber the channel number to look for, in the range 1 to 16
169 @see getChannel, setChannel
171 bool isForChannel (int channelNumber) const noexcept;
173 /** Changes the message's midi channel.
175 This won't do anything for non-channel messages like sysexes.
177 @param newChannelNumber the channel number to change it to, in the range 1 to 16
179 void setChannel (int newChannelNumber) noexcept;
181 //==============================================================================
182 /** Returns true if this is a system-exclusive message.
184 bool isSysEx() const noexcept;
186 /** Returns a pointer to the sysex data inside the message.
188 If this event isn't a sysex event, it'll return 0.
190 @see getSysExDataSize
192 const uint8* getSysExData() const noexcept;
194 /** Returns the size of the sysex data.
196 This value excludes the 0xf0 header byte and the 0xf7 at the end.
198 @see getSysExData
200 int getSysExDataSize() const noexcept;
202 //==============================================================================
203 /** Returns true if this message is a 'key-down' event.
205 @param returnTrueForVelocity0 if true, then if this event is a note-on with
206 velocity 0, it will still be considered to be a note-on and the
207 method will return true. If returnTrueForVelocity0 is false, then
208 if this is a note-on event with velocity 0, it'll be regarded as
209 a note-off, and the method will return false
211 @see isNoteOff, getNoteNumber, getVelocity, noteOn
213 bool isNoteOn (bool returnTrueForVelocity0 = false) const noexcept;
215 /** Creates a key-down message (using a floating-point velocity).
217 @param channel the midi channel, in the range 1 to 16
218 @param noteNumber the key number, 0 to 127
219 @param velocity in the range 0 to 1.0
220 @see isNoteOn
222 static MidiMessage noteOn (int channel, int noteNumber, float velocity) noexcept;
224 /** Creates a key-down message (using an integer velocity).
226 @param channel the midi channel, in the range 1 to 16
227 @param noteNumber the key number, 0 to 127
228 @param velocity in the range 0 to 127
229 @see isNoteOn
231 static MidiMessage noteOn (int channel, int noteNumber, uint8 velocity) noexcept;
233 /** Returns true if this message is a 'key-up' event.
235 If returnTrueForNoteOnVelocity0 is true, then his will also return true
236 for a note-on event with a velocity of 0.
238 @see isNoteOn, getNoteNumber, getVelocity, noteOff
240 bool isNoteOff (bool returnTrueForNoteOnVelocity0 = true) const noexcept;
242 /** Creates a key-up message.
244 @param channel the midi channel, in the range 1 to 16
245 @param noteNumber the key number, 0 to 127
246 @param velocity in the range 0 to 127
247 @see isNoteOff
249 static MidiMessage noteOff (int channel, int noteNumber, uint8 velocity = 0) noexcept;
251 /** Returns true if this message is a 'key-down' or 'key-up' event.
253 @see isNoteOn, isNoteOff
255 bool isNoteOnOrOff() const noexcept;
257 /** Returns the midi note number for note-on and note-off messages.
259 If the message isn't a note-on or off, the value returned is undefined.
261 @see isNoteOff, getMidiNoteName, getMidiNoteInHertz, setNoteNumber
263 int getNoteNumber() const noexcept;
265 /** Changes the midi note number of a note-on or note-off message.
267 If the message isn't a note on or off, this will do nothing.
269 void setNoteNumber (int newNoteNumber) noexcept;
271 //==============================================================================
272 /** Returns the velocity of a note-on or note-off message.
274 The value returned will be in the range 0 to 127.
275 If the message isn't a note-on or off event, it will return 0.
277 @see getFloatVelocity
279 uint8 getVelocity() const noexcept;
281 /** Returns the velocity of a note-on or note-off message.
283 The value returned will be in the range 0 to 1.0
284 If the message isn't a note-on or off event, it will return 0.
286 @see getVelocity, setVelocity
288 float getFloatVelocity() const noexcept;
290 /** Changes the velocity of a note-on or note-off message.
292 If the message isn't a note on or off, this will do nothing.
294 @param newVelocity the new velocity, in the range 0 to 1.0
295 @see getFloatVelocity, multiplyVelocity
297 void setVelocity (float newVelocity) noexcept;
299 /** Multiplies the velocity of a note-on or note-off message by a given amount.
301 If the message isn't a note on or off, this will do nothing.
303 @param scaleFactor the value by which to multiply the velocity
304 @see setVelocity
306 void multiplyVelocity (float scaleFactor) noexcept;
308 //==============================================================================
309 /** Returns true if this message is a 'sustain pedal down' controller message. */
310 bool isSustainPedalOn() const noexcept;
311 /** Returns true if this message is a 'sustain pedal up' controller message. */
312 bool isSustainPedalOff() const noexcept;
314 /** Returns true if this message is a 'sostenuto pedal down' controller message. */
315 bool isSostenutoPedalOn() const noexcept;
316 /** Returns true if this message is a 'sostenuto pedal up' controller message. */
317 bool isSostenutoPedalOff() const noexcept;
319 /** Returns true if this message is a 'soft pedal down' controller message. */
320 bool isSoftPedalOn() const noexcept;
321 /** Returns true if this message is a 'soft pedal up' controller message. */
322 bool isSoftPedalOff() const noexcept;
324 //==============================================================================
325 /** Returns true if the message is a program (patch) change message.
327 @see getProgramChangeNumber, getGMInstrumentName
329 bool isProgramChange() const noexcept;
331 /** Returns the new program number of a program change message.
333 If the message isn't a program change, the value returned will be
334 nonsense.
336 @see isProgramChange, getGMInstrumentName
338 int getProgramChangeNumber() const noexcept;
340 /** Creates a program-change message.
342 @param channel the midi channel, in the range 1 to 16
343 @param programNumber the midi program number, 0 to 127
344 @see isProgramChange, getGMInstrumentName
346 static MidiMessage programChange (int channel, int programNumber) noexcept;
348 //==============================================================================
349 /** Returns true if the message is a pitch-wheel move.
351 @see getPitchWheelValue, pitchWheel
353 bool isPitchWheel() const noexcept;
355 /** Returns the pitch wheel position from a pitch-wheel move message.
357 The value returned is a 14-bit number from 0 to 0x3fff, indicating the wheel position.
358 If called for messages which aren't pitch wheel events, the number returned will be
359 nonsense.
361 @see isPitchWheel
363 int getPitchWheelValue() const noexcept;
365 /** Creates a pitch-wheel move message.
367 @param channel the midi channel, in the range 1 to 16
368 @param position the wheel position, in the range 0 to 16383
369 @see isPitchWheel
371 static MidiMessage pitchWheel (int channel, int position) noexcept;
373 //==============================================================================
374 /** Returns true if the message is an aftertouch event.
376 For aftertouch events, use the getNoteNumber() method to find out the key
377 that it applies to, and getAftertouchValue() to find out the amount. Use
378 getChannel() to find out the channel.
380 @see getAftertouchValue, getNoteNumber
382 bool isAftertouch() const noexcept;
384 /** Returns the amount of aftertouch from an aftertouch messages.
386 The value returned is in the range 0 to 127, and will be nonsense for messages
387 other than aftertouch messages.
389 @see isAftertouch
391 int getAfterTouchValue() const noexcept;
393 /** Creates an aftertouch message.
395 @param channel the midi channel, in the range 1 to 16
396 @param noteNumber the key number, 0 to 127
397 @param aftertouchAmount the amount of aftertouch, 0 to 127
398 @see isAftertouch
400 static MidiMessage aftertouchChange (int channel,
401 int noteNumber,
402 int aftertouchAmount) noexcept;
404 /** Returns true if the message is a channel-pressure change event.
406 This is like aftertouch, but common to the whole channel rather than a specific
407 note. Use getChannelPressureValue() to find out the pressure, and getChannel()
408 to find out the channel.
410 @see channelPressureChange
412 bool isChannelPressure() const noexcept;
414 /** Returns the pressure from a channel pressure change message.
416 @returns the pressure, in the range 0 to 127
417 @see isChannelPressure, channelPressureChange
419 int getChannelPressureValue() const noexcept;
421 /** Creates a channel-pressure change event.
423 @param channel the midi channel: 1 to 16
424 @param pressure the pressure, 0 to 127
425 @see isChannelPressure
427 static MidiMessage channelPressureChange (int channel, int pressure) noexcept;
429 //==============================================================================
430 /** Returns true if this is a midi controller message.
432 @see getControllerNumber, getControllerValue, controllerEvent
434 bool isController() const noexcept;
436 /** Returns the controller number of a controller message.
438 The name of the controller can be looked up using the getControllerName() method.
440 Note that the value returned is invalid for messages that aren't controller changes.
442 @see isController, getControllerName, getControllerValue
444 int getControllerNumber() const noexcept;
446 /** Returns the controller value from a controller message.
448 A value 0 to 127 is returned to indicate the new controller position.
450 Note that the value returned is invalid for messages that aren't controller changes.
452 @see isController, getControllerNumber
454 int getControllerValue() const noexcept;
456 /** Returns true if this message is a controller message and if it has the specified
457 controller type.
459 bool isControllerOfType (int controllerType) const noexcept;
461 /** Creates a controller message.
463 @param channel the midi channel, in the range 1 to 16
464 @param controllerType the type of controller
465 @param value the controller value
466 @see isController
468 static MidiMessage controllerEvent (int channel,
469 int controllerType,
470 int value) noexcept;
472 /** Checks whether this message is an all-notes-off message.
474 @see allNotesOff
476 bool isAllNotesOff() const noexcept;
478 /** Checks whether this message is an all-sound-off message.
480 @see allSoundOff
482 bool isAllSoundOff() const noexcept;
484 /** Creates an all-notes-off message.
486 @param channel the midi channel, in the range 1 to 16
487 @see isAllNotesOff
489 static MidiMessage allNotesOff (int channel) noexcept;
491 /** Creates an all-sound-off message.
493 @param channel the midi channel, in the range 1 to 16
494 @see isAllSoundOff
496 static MidiMessage allSoundOff (int channel) noexcept;
498 /** Creates an all-controllers-off message.
500 @param channel the midi channel, in the range 1 to 16
502 static MidiMessage allControllersOff (int channel) noexcept;
504 //==============================================================================
505 /** Returns true if this event is a meta-event.
507 Meta-events are things like tempo changes, track names, etc.
509 @see getMetaEventType, isTrackMetaEvent, isEndOfTrackMetaEvent,
510 isTextMetaEvent, isTrackNameEvent, isTempoMetaEvent, isTimeSignatureMetaEvent,
511 isKeySignatureMetaEvent, isMidiChannelMetaEvent
513 bool isMetaEvent() const noexcept;
515 /** Returns a meta-event's type number.
517 If the message isn't a meta-event, this will return -1.
519 @see isMetaEvent, isTrackMetaEvent, isEndOfTrackMetaEvent,
520 isTextMetaEvent, isTrackNameEvent, isTempoMetaEvent, isTimeSignatureMetaEvent,
521 isKeySignatureMetaEvent, isMidiChannelMetaEvent
523 int getMetaEventType() const noexcept;
525 /** Returns a pointer to the data in a meta-event.
527 @see isMetaEvent, getMetaEventLength
529 const uint8* getMetaEventData() const noexcept;
531 /** Returns the length of the data for a meta-event.
533 @see isMetaEvent, getMetaEventData
535 int getMetaEventLength() const noexcept;
537 //==============================================================================
538 /** Returns true if this is a 'track' meta-event. */
539 bool isTrackMetaEvent() const noexcept;
541 /** Returns true if this is an 'end-of-track' meta-event. */
542 bool isEndOfTrackMetaEvent() const noexcept;
544 /** Creates an end-of-track meta-event.
546 @see isEndOfTrackMetaEvent
548 static MidiMessage endOfTrack() noexcept;
550 /** Returns true if this is an 'track name' meta-event.
552 You can use the getTextFromTextMetaEvent() method to get the track's name.
554 bool isTrackNameEvent() const noexcept;
556 /** Returns true if this is a 'text' meta-event.
558 @see getTextFromTextMetaEvent
560 bool isTextMetaEvent() const noexcept;
562 /** Returns the text from a text meta-event.
564 @see isTextMetaEvent
566 String getTextFromTextMetaEvent() const;
568 //==============================================================================
569 /** Returns true if this is a 'tempo' meta-event.
571 @see getTempoMetaEventTickLength, getTempoSecondsPerQuarterNote
573 bool isTempoMetaEvent() const noexcept;
575 /** Returns the tick length from a tempo meta-event.
577 @param timeFormat the 16-bit time format value from the midi file's header.
578 @returns the tick length (in seconds).
579 @see isTempoMetaEvent
581 double getTempoMetaEventTickLength (short timeFormat) const noexcept;
583 /** Calculates the seconds-per-quarter-note from a tempo meta-event.
585 @see isTempoMetaEvent, getTempoMetaEventTickLength
587 double getTempoSecondsPerQuarterNote() const noexcept;
589 /** Creates a tempo meta-event.
591 @see isTempoMetaEvent
593 static MidiMessage tempoMetaEvent (int microsecondsPerQuarterNote) noexcept;
595 //==============================================================================
596 /** Returns true if this is a 'time-signature' meta-event.
598 @see getTimeSignatureInfo
600 bool isTimeSignatureMetaEvent() const noexcept;
602 /** Returns the time-signature values from a time-signature meta-event.
604 @see isTimeSignatureMetaEvent
606 void getTimeSignatureInfo (int& numerator, int& denominator) const noexcept;
608 /** Creates a time-signature meta-event.
610 @see isTimeSignatureMetaEvent
612 static MidiMessage timeSignatureMetaEvent (int numerator, int denominator);
614 //==============================================================================
615 /** Returns true if this is a 'key-signature' meta-event.
617 @see getKeySignatureNumberOfSharpsOrFlats
619 bool isKeySignatureMetaEvent() const noexcept;
621 /** Returns the key from a key-signature meta-event.
623 @see isKeySignatureMetaEvent
625 int getKeySignatureNumberOfSharpsOrFlats() const noexcept;
627 //==============================================================================
628 /** Returns true if this is a 'channel' meta-event.
630 A channel meta-event specifies the midi channel that should be used
631 for subsequent meta-events.
633 @see getMidiChannelMetaEventChannel
635 bool isMidiChannelMetaEvent() const noexcept;
637 /** Returns the channel number from a channel meta-event.
639 @returns the channel, in the range 1 to 16.
640 @see isMidiChannelMetaEvent
642 int getMidiChannelMetaEventChannel() const noexcept;
644 /** Creates a midi channel meta-event.
646 @param channel the midi channel, in the range 1 to 16
647 @see isMidiChannelMetaEvent
649 static MidiMessage midiChannelMetaEvent (int channel) noexcept;
651 //==============================================================================
652 /** Returns true if this is an active-sense message. */
653 bool isActiveSense() const noexcept;
655 //==============================================================================
656 /** Returns true if this is a midi start event.
658 @see midiStart
660 bool isMidiStart() const noexcept;
662 /** Creates a midi start event. */
663 static MidiMessage midiStart() noexcept;
665 /** Returns true if this is a midi continue event.
667 @see midiContinue
669 bool isMidiContinue() const noexcept;
671 /** Creates a midi continue event. */
672 static MidiMessage midiContinue() noexcept;
674 /** Returns true if this is a midi stop event.
676 @see midiStop
678 bool isMidiStop() const noexcept;
680 /** Creates a midi stop event. */
681 static MidiMessage midiStop() noexcept;
683 /** Returns true if this is a midi clock event.
685 @see midiClock, songPositionPointer
687 bool isMidiClock() const noexcept;
689 /** Creates a midi clock event. */
690 static MidiMessage midiClock() noexcept;
692 /** Returns true if this is a song-position-pointer message.
694 @see getSongPositionPointerMidiBeat, songPositionPointer
696 bool isSongPositionPointer() const noexcept;
698 /** Returns the midi beat-number of a song-position-pointer message.
700 @see isSongPositionPointer, songPositionPointer
702 int getSongPositionPointerMidiBeat() const noexcept;
704 /** Creates a song-position-pointer message.
706 The position is a number of midi beats from the start of the song, where 1 midi
707 beat is 6 midi clocks, and there are 24 midi clocks in a quarter-note. So there
708 are 4 midi beats in a quarter-note.
710 @see isSongPositionPointer, getSongPositionPointerMidiBeat
712 static MidiMessage songPositionPointer (int positionInMidiBeats) noexcept;
714 //==============================================================================
715 /** Returns true if this is a quarter-frame midi timecode message.
717 @see quarterFrame, getQuarterFrameSequenceNumber, getQuarterFrameValue
719 bool isQuarterFrame() const noexcept;
721 /** Returns the sequence number of a quarter-frame midi timecode message.
723 This will be a value between 0 and 7.
725 @see isQuarterFrame, getQuarterFrameValue, quarterFrame
727 int getQuarterFrameSequenceNumber() const noexcept;
729 /** Returns the value from a quarter-frame message.
731 This will be the lower nybble of the message's data-byte, a value
732 between 0 and 15
734 int getQuarterFrameValue() const noexcept;
736 /** Creates a quarter-frame MTC message.
738 @param sequenceNumber a value 0 to 7 for the upper nybble of the message's data byte
739 @param value a value 0 to 15 for the lower nybble of the message's data byte
741 static MidiMessage quarterFrame (int sequenceNumber, int value) noexcept;
743 /** SMPTE timecode types.
745 Used by the getFullFrameParameters() and fullFrame() methods.
747 enum SmpteTimecodeType
749 fps24 = 0,
750 fps25 = 1,
751 fps30drop = 2,
752 fps30 = 3
755 /** Returns true if this is a full-frame midi timecode message.
757 bool isFullFrame() const noexcept;
759 /** Extracts the timecode information from a full-frame midi timecode message.
761 You should only call this on messages where you've used isFullFrame() to
762 check that they're the right kind.
764 void getFullFrameParameters (int& hours,
765 int& minutes,
766 int& seconds,
767 int& frames,
768 SmpteTimecodeType& timecodeType) const noexcept;
770 /** Creates a full-frame MTC message.
772 static MidiMessage fullFrame (int hours,
773 int minutes,
774 int seconds,
775 int frames,
776 SmpteTimecodeType timecodeType);
778 //==============================================================================
779 /** Types of MMC command.
781 @see isMidiMachineControlMessage, getMidiMachineControlCommand, midiMachineControlCommand
783 enum MidiMachineControlCommand
785 mmc_stop = 1,
786 mmc_play = 2,
787 mmc_deferredplay = 3,
788 mmc_fastforward = 4,
789 mmc_rewind = 5,
790 mmc_recordStart = 6,
791 mmc_recordStop = 7,
792 mmc_pause = 9
795 /** Checks whether this is an MMC message.
797 If it is, you can use the getMidiMachineControlCommand() to find out its type.
799 bool isMidiMachineControlMessage() const noexcept;
801 /** For an MMC message, this returns its type.
803 Make sure it's actually an MMC message with isMidiMachineControlMessage() before
804 calling this method.
806 MidiMachineControlCommand getMidiMachineControlCommand() const noexcept;
808 /** Creates an MMC message.
810 static MidiMessage midiMachineControlCommand (MidiMachineControlCommand command);
812 /** Checks whether this is an MMC "goto" message.
814 If it is, the parameters passed-in are set to the time that the message contains.
816 @see midiMachineControlGoto
818 bool isMidiMachineControlGoto (int& hours,
819 int& minutes,
820 int& seconds,
821 int& frames) const noexcept;
823 /** Creates an MMC "goto" message.
825 This messages tells the device to go to a specific frame.
827 @see isMidiMachineControlGoto
829 static MidiMessage midiMachineControlGoto (int hours,
830 int minutes,
831 int seconds,
832 int frames);
834 //==============================================================================
835 /** Creates a master-volume change message.
837 @param volume the volume, 0 to 1.0
839 static MidiMessage masterVolume (float volume);
841 //==============================================================================
842 /** Creates a system-exclusive message.
844 The data passed in is wrapped with header and tail bytes of 0xf0 and 0xf7.
846 static MidiMessage createSysExMessage (const uint8* sysexData,
847 int dataSize);
850 //==============================================================================
851 /** Reads a midi variable-length integer.
853 @param data the data to read the number from
854 @param numBytesUsed on return, this will be set to the number of bytes that were read
856 static int readVariableLengthVal (const uint8* data,
857 int& numBytesUsed) noexcept;
859 /** Based on the first byte of a short midi message, this uses a lookup table
860 to return the message length (either 1, 2, or 3 bytes).
862 The value passed in must be 0x80 or higher.
864 static int getMessageLengthFromFirstByte (const uint8 firstByte) noexcept;
866 //==============================================================================
867 /** Returns the name of a midi note number.
869 E.g "C", "D#", etc.
871 @param noteNumber the midi note number, 0 to 127
872 @param useSharps if true, sharpened notes are used, e.g. "C#", otherwise
873 they'll be flattened, e.g. "Db"
874 @param includeOctaveNumber if true, the octave number will be appended to the string,
875 e.g. "C#4"
876 @param octaveNumForMiddleC if an octave number is being appended, this indicates the
877 number that will be used for middle C's octave
879 @see getMidiNoteInHertz
881 static String getMidiNoteName (int noteNumber,
882 bool useSharps,
883 bool includeOctaveNumber,
884 int octaveNumForMiddleC);
886 /** Returns the frequency of a midi note number.
888 The frequencyOfA parameter is an optional frequency for 'A', normally 440-444Hz for concert pitch.
889 @see getMidiNoteName
891 static const double getMidiNoteInHertz (int noteNumber, const double frequencyOfA = 440.0) noexcept;
893 /** Returns the standard name of a GM instrument.
895 @param midiInstrumentNumber the program number 0 to 127
896 @see getProgramChangeNumber
898 static String getGMInstrumentName (int midiInstrumentNumber);
900 /** Returns the name of a bank of GM instruments.
902 @param midiBankNumber the bank, 0 to 15
904 static String getGMInstrumentBankName (int midiBankNumber);
906 /** Returns the standard name of a channel 10 percussion sound.
908 @param midiNoteNumber the key number, 35 to 81
910 static String getRhythmInstrumentName (int midiNoteNumber);
912 /** Returns the name of a controller type number.
914 @see getControllerNumber
916 static String getControllerName (int controllerNumber);
918 private:
919 //==============================================================================
920 double timeStamp;
921 uint8* data;
922 int size;
924 #ifndef DOXYGEN
925 union
927 uint8 asBytes[4];
928 uint32 asInt32;
929 } preallocatedData;
930 #endif
933 #endif // __JUCE_MIDIMESSAGE_JUCEHEADER__