LMMS
Loading...
Searching...
No Matches
water::MidiMessage Class Reference

#include <MidiMessage.h>

Classes

union  PackedData

Public Types

enum  SmpteTimecodeType { fps24 = 0 , fps25 = 1 , fps30drop = 2 , fps30 = 3 }
enum  MidiMachineControlCommand {
  mmc_stop = 1 , mmc_play = 2 , mmc_deferredplay = 3 , mmc_fastforward = 4 ,
  mmc_rewind = 5 , mmc_recordStart = 6 , mmc_recordStop = 7 , mmc_pause = 9
}

Public Member Functions

 MidiMessage (int byte1, int byte2, int byte3, double timeStamp=0) noexcept
 MidiMessage (int byte1, int byte2, double timeStamp=0) noexcept
 MidiMessage (int byte1, double timeStamp=0) noexcept
 MidiMessage (const void *data, int numBytes, double timeStamp=0)
 MidiMessage (const void *data, int maxBytesToUse, int &numBytesUsed, uint8 lastStatusByte, double timeStamp=0, bool sysexHasEmbeddedLength=true)
 MidiMessage () noexcept
 MidiMessage (const MidiMessage &)
 MidiMessage (const MidiMessage &, double newTimeStamp)
 ~MidiMessage () noexcept
MidiMessageoperator= (const MidiMessage &other)
const uint8getRawData () const noexcept
int getRawDataSize () const noexcept
double getTimeStamp () const noexcept
void setTimeStamp (double newTimestamp) noexcept
void addToTimeStamp (double delta) noexcept
int getChannel () const noexcept
bool isForChannel (int channelNumber) const noexcept
void setChannel (int newChannelNumber) noexcept
bool isSysEx () const noexcept
const uint8getSysExData () const noexcept
int getSysExDataSize () const noexcept
bool isNoteOn (bool returnTrueForVelocity0=false) const noexcept
bool isNoteOff (bool returnTrueForNoteOnVelocity0=true) const noexcept
bool isNoteOnOrOff () const noexcept
int getNoteNumber () const noexcept
void setNoteNumber (int newNoteNumber) noexcept
uint8 getVelocity () const noexcept
float getFloatVelocity () const noexcept
void setVelocity (float newVelocity) noexcept
void multiplyVelocity (float scaleFactor) noexcept
bool isSustainPedalOn () const noexcept
bool isSustainPedalOff () const noexcept
bool isSostenutoPedalOn () const noexcept
bool isSostenutoPedalOff () const noexcept
bool isSoftPedalOn () const noexcept
bool isSoftPedalOff () const noexcept
bool isProgramChange () const noexcept
int getProgramChangeNumber () const noexcept
bool isPitchWheel () const noexcept
int getPitchWheelValue () const noexcept
bool isAftertouch () const noexcept
int getAfterTouchValue () const noexcept
bool isChannelPressure () const noexcept
int getChannelPressureValue () const noexcept
bool isController () const noexcept
int getControllerNumber () const noexcept
int getControllerValue () const noexcept
bool isControllerOfType (int controllerType) const noexcept
bool isAllNotesOff () const noexcept
bool isAllSoundOff () const noexcept
bool isMetaEvent () const noexcept
int getMetaEventType () const noexcept
const uint8getMetaEventData () const noexcept
int getMetaEventLength () const noexcept
bool isTempoMetaEvent () const noexcept
double getTempoMetaEventTickLength (short timeFormat) const noexcept
double getTempoSecondsPerQuarterNote () const noexcept
bool isTimeSignatureMetaEvent () const noexcept
void getTimeSignatureInfo (int &numerator, int &denominator) const noexcept
bool isKeySignatureMetaEvent () const noexcept
int getKeySignatureNumberOfSharpsOrFlats () const noexcept
bool isKeySignatureMajorKey () const noexcept
bool isMidiChannelMetaEvent () const noexcept
int getMidiChannelMetaEventChannel () const noexcept
bool isActiveSense () const noexcept
bool isMidiStart () const noexcept
bool isMidiContinue () const noexcept
bool isMidiStop () const noexcept
bool isMidiClock () const noexcept
bool isSongPositionPointer () const noexcept
int getSongPositionPointerMidiBeat () const noexcept
bool isQuarterFrame () const noexcept
int getQuarterFrameSequenceNumber () const noexcept
int getQuarterFrameValue () const noexcept
bool isFullFrame () const noexcept
void getFullFrameParameters (int &hours, int &minutes, int &seconds, int &frames, SmpteTimecodeType &timecodeType) const noexcept
bool isMidiMachineControlMessage () const noexcept
MidiMachineControlCommand getMidiMachineControlCommand () const noexcept
bool isMidiMachineControlGoto (int &hours, int &minutes, int &seconds, int &frames) const noexcept

Static Public Member Functions

static MidiMessage noteOn (int channel, int noteNumber, float velocity) noexcept
static MidiMessage noteOn (int channel, int noteNumber, uint8 velocity) noexcept
static MidiMessage noteOff (int channel, int noteNumber, float velocity) noexcept
static MidiMessage noteOff (int channel, int noteNumber, uint8 velocity) noexcept
static MidiMessage noteOff (int channel, int noteNumber) noexcept
static MidiMessage programChange (int channel, int programNumber) noexcept
static MidiMessage pitchWheel (int channel, int position) noexcept
static MidiMessage aftertouchChange (int channel, int noteNumber, int aftertouchAmount) noexcept
static MidiMessage channelPressureChange (int channel, int pressure) noexcept
static MidiMessage controllerEvent (int channel, int controllerType, int value) noexcept
static MidiMessage allNotesOff (int channel) noexcept
static MidiMessage allSoundOff (int channel) noexcept
static MidiMessage allControllersOff (int channel) noexcept
static MidiMessage tempoMetaEvent (int microsecondsPerQuarterNote) noexcept
static MidiMessage timeSignatureMetaEvent (int numerator, int denominator)
static MidiMessage keySignatureMetaEvent (int numberOfSharpsOrFlats, bool isMinorKey)
static MidiMessage midiChannelMetaEvent (int channel) noexcept
static MidiMessage midiStart () noexcept
static MidiMessage midiContinue () noexcept
static MidiMessage midiStop () noexcept
static MidiMessage midiClock () noexcept
static MidiMessage songPositionPointer (int positionInMidiBeats) noexcept
static MidiMessage quarterFrame (int sequenceNumber, int value) noexcept
static MidiMessage fullFrame (int hours, int minutes, int seconds, int frames, SmpteTimecodeType timecodeType)
static MidiMessage midiMachineControlCommand (MidiMachineControlCommand command)
static MidiMessage midiMachineControlGoto (int hours, int minutes, int seconds, int frames)
static MidiMessage masterVolume (float volume)
static MidiMessage createSysExMessage (const void *sysexData, int dataSize)
static int readVariableLengthVal (const uint8 *data, int &numBytesUsed) noexcept
static int getMessageLengthFromFirstByte (uint8 firstByte) noexcept
static double getMidiNoteInHertz (int noteNumber, double frequencyOfA=440.0) noexcept
static bool isMidiNoteBlack (int noteNumber) noexcept
static uint8 floatValueToMidiByte (float valueBetween0and1) noexcept
static uint16 pitchbendToPitchwheelPos (float pitchbendInSemitones, float pitchbendRangeInSemitones) noexcept

Private Member Functions

bool isHeapAllocated () const noexcept
uint8getData () noexcept
const uint8getData () const noexcept
uint8allocateSpace (int)

Private Attributes

PackedData packedData
double timeStamp
int size

Detailed Description

Encapsulates a MIDI message.

See also
MidiMessageSequence, MidiOutput, MidiInput

Member Enumeration Documentation

◆ MidiMachineControlCommand

Types of MMC command.

See also
isMidiMachineControlMessage, getMidiMachineControlCommand, midiMachineControlCommand
Enumerator
mmc_stop 
mmc_play 
mmc_deferredplay 
mmc_fastforward 
mmc_rewind 
mmc_recordStart 
mmc_recordStop 
mmc_pause 

◆ SmpteTimecodeType

SMPTE timecode types. Used by the getFullFrameParameters() and fullFrame() methods.

Enumerator
fps24 
fps25 
fps30drop 
fps30 

Constructor & Destructor Documentation

◆ MidiMessage() [1/8]

water::MidiMessage::MidiMessage ( int byte1,
int byte2,
int byte3,
double timeStamp = 0 )
noexcept

Creates a 3-byte short midi message.

Parameters
byte1message byte 1
byte2message byte 2
byte3message byte 3
timeStampthe time to give the midi message - this value doesn't use any particular units, so will be application-specific

◆ MidiMessage() [2/8]

water::MidiMessage::MidiMessage ( int byte1,
int byte2,
double timeStamp = 0 )
noexcept

Creates a 2-byte short midi message.

Parameters
byte1message byte 1
byte2message byte 2
timeStampthe time to give the midi message - this value doesn't use any particular units, so will be application-specific

◆ MidiMessage() [3/8]

water::MidiMessage::MidiMessage ( int byte1,
double timeStamp = 0 )
noexcept

Creates a 1-byte short midi message.

Parameters
byte1message byte 1
timeStampthe time to give the midi message - this value doesn't use any particular units, so will be application-specific

◆ MidiMessage() [4/8]

water::MidiMessage::MidiMessage ( const void * data,
int numBytes,
double timeStamp = 0 )

Creates a midi message from a block of data.

◆ MidiMessage() [5/8]

water::MidiMessage::MidiMessage ( const void * data,
int maxBytesToUse,
int & numBytesUsed,
uint8 lastStatusByte,
double timeStamp = 0,
bool sysexHasEmbeddedLength = true )

Reads the next midi message from some data.

This will read as many bytes from a data stream as it needs to make a complete message, and will return the number of bytes it used. This lets you read a sequence of midi messages from a file or stream.

Parameters
datathe data to read from
maxBytesToUsethe maximum number of bytes it's allowed to read
numBytesUsedreturns the number of bytes that were actually needed
lastStatusBytein a sequence of midi messages, the initial byte can be dropped from a message if it's the same as the first byte of the previous message, so this lets you supply the byte to use if the first byte of the message has in fact been dropped.
timeStampthe time to give the midi message - this value doesn't use any particular units, so will be application-specific
sysexHasEmbeddedLengthwhen reading sysexes, this flag indicates whether to expect the data to begin with a variable-length field indicating its size

◆ MidiMessage() [6/8]

water::MidiMessage::MidiMessage ( )
noexcept

Creates an active-sense message. Since the MidiMessage has to contain a valid message, this default constructor just initialises it with an empty sysex message.

◆ MidiMessage() [7/8]

water::MidiMessage::MidiMessage ( const MidiMessage & other)

Creates a copy of another midi message.

◆ MidiMessage() [8/8]

water::MidiMessage::MidiMessage ( const MidiMessage & other,
double newTimeStamp )

Creates a copy of another midi message, with a different timestamp.

◆ ~MidiMessage()

water::MidiMessage::~MidiMessage ( )
noexcept

Destructor.

Member Function Documentation

◆ addToTimeStamp()

void water::MidiMessage::addToTimeStamp ( double delta)
inlinenoexcept

Adds a value to the message's timestamp. The units for the timestamp will be application-specific.

◆ aftertouchChange()

MidiMessage water::MidiMessage::aftertouchChange ( int channel,
int noteNumber,
int aftertouchAmount )
staticnoexcept

Creates an aftertouch message.

Parameters
channelthe midi channel, in the range 1 to 16
noteNumberthe key number, 0 to 127
aftertouchAmountthe amount of aftertouch, 0 to 127
See also
isAftertouch

◆ allControllersOff()

MidiMessage water::MidiMessage::allControllersOff ( int channel)
staticnoexcept

Creates an all-controllers-off message.

Parameters
channelthe midi channel, in the range 1 to 16

◆ allNotesOff()

MidiMessage water::MidiMessage::allNotesOff ( int channel)
staticnoexcept

Creates an all-notes-off message.

Parameters
channelthe midi channel, in the range 1 to 16
See also
isAllNotesOff

◆ allocateSpace()

uint8 * water::MidiMessage::allocateSpace ( int bytes)
private

◆ allSoundOff()

MidiMessage water::MidiMessage::allSoundOff ( int channel)
staticnoexcept

Creates an all-sound-off message.

Parameters
channelthe midi channel, in the range 1 to 16
See also
isAllSoundOff

◆ channelPressureChange()

MidiMessage water::MidiMessage::channelPressureChange ( int channel,
int pressure )
staticnoexcept

Creates a channel-pressure change event.

Parameters
channelthe midi channel: 1 to 16
pressurethe pressure, 0 to 127
See also
isChannelPressure

◆ controllerEvent()

MidiMessage water::MidiMessage::controllerEvent ( int channel,
int controllerType,
int value )
staticnoexcept

Creates a controller message.

Parameters
channelthe midi channel, in the range 1 to 16
controllerTypethe type of controller
valuethe controller value
See also
isController

◆ createSysExMessage()

MidiMessage water::MidiMessage::createSysExMessage ( const void * sysexData,
int dataSize )
static

Creates a system-exclusive message. The data passed in is wrapped with header and tail bytes of 0xf0 and 0xf7.

◆ floatValueToMidiByte()

uint8 water::MidiMessage::floatValueToMidiByte ( float valueBetween0and1)
staticnoexcept

Converts a floating-point value between 0 and 1 to a MIDI 7-bit value between 0 and 127.

◆ fullFrame()

MidiMessage water::MidiMessage::fullFrame ( int hours,
int minutes,
int seconds,
int frames,
MidiMessage::SmpteTimecodeType timecodeType )
static

Creates a full-frame MTC message.

◆ getAfterTouchValue()

int water::MidiMessage::getAfterTouchValue ( ) const
noexcept

Returns the amount of aftertouch from an aftertouch messages.

The value returned is in the range 0 to 127, and will be nonsense for messages other than aftertouch messages.

See also
isAftertouch

◆ getChannel()

int water::MidiMessage::getChannel ( ) const
noexcept

Returns the midi channel associated with the message.

Returns
a value 1 to 16 if the message has a channel, or 0 if it hasn't (e.g. if it's a sysex)
See also
isForChannel, setChannel

◆ getChannelPressureValue()

int water::MidiMessage::getChannelPressureValue ( ) const
noexcept

Returns the pressure from a channel pressure change message.

Returns
the pressure, in the range 0 to 127
See also
isChannelPressure, channelPressureChange

◆ getControllerNumber()

int water::MidiMessage::getControllerNumber ( ) const
noexcept

Returns the controller number of a controller message.

The name of the controller can be looked up using the getControllerName() method. Note that the value returned is invalid for messages that aren't controller changes.

See also
isController, getControllerName, getControllerValue

◆ getControllerValue()

int water::MidiMessage::getControllerValue ( ) const
noexcept

Returns the controller value from a controller message.

A value 0 to 127 is returned to indicate the new controller position. Note that the value returned is invalid for messages that aren't controller changes.

See also
isController, getControllerNumber

◆ getData() [1/2]

const uint8 * water::MidiMessage::getData ( ) const
inlineprivatenoexcept

◆ getData() [2/2]

uint8 * water::MidiMessage::getData ( )
inlineprivatenoexcept

◆ getFloatVelocity()

float water::MidiMessage::getFloatVelocity ( ) const
noexcept

Returns the velocity of a note-on or note-off message.

The value returned will be in the range 0 to 1.0 If the message isn't a note-on or off event, it will return 0.

See also
getVelocity, setVelocity

◆ getFullFrameParameters()

void water::MidiMessage::getFullFrameParameters ( int & hours,
int & minutes,
int & seconds,
int & frames,
MidiMessage::SmpteTimecodeType & timecodeType ) const
noexcept

Extracts the timecode information from a full-frame midi timecode message.

You should only call this on messages where you've used isFullFrame() to check that they're the right kind.

◆ getKeySignatureNumberOfSharpsOrFlats()

int water::MidiMessage::getKeySignatureNumberOfSharpsOrFlats ( ) const
noexcept

Returns the key from a key-signature meta-event. This method must only be called if isKeySignatureMetaEvent() is true. A positive number here indicates the number of sharps in the key signature, and a negative number indicates a number of flats. So e.g. 3 = F# + C# + G#, -2 = Bb + Eb

See also
isKeySignatureMetaEvent, isKeySignatureMajorKey

◆ getMessageLengthFromFirstByte()

int water::MidiMessage::getMessageLengthFromFirstByte ( uint8 firstByte)
staticnoexcept

Based on the first byte of a short midi message, this uses a lookup table to return the message length (either 1, 2, or 3 bytes).

The value passed in must be 0x80 or higher.

◆ getMetaEventData()

const uint8 * water::MidiMessage::getMetaEventData ( ) const
noexcept

Returns a pointer to the data in a meta-event.

See also
isMetaEvent, getMetaEventLength

◆ getMetaEventLength()

int water::MidiMessage::getMetaEventLength ( ) const
noexcept

Returns the length of the data for a meta-event.

See also
isMetaEvent, getMetaEventData

◆ getMetaEventType()

int water::MidiMessage::getMetaEventType ( ) const
noexcept

Returns a meta-event's type number.

If the message isn't a meta-event, this will return -1.

See also
isMetaEvent, isTempoMetaEvent, isTimeSignatureMetaEvent, isKeySignatureMetaEvent, isMidiChannelMetaEvent

◆ getMidiChannelMetaEventChannel()

int water::MidiMessage::getMidiChannelMetaEventChannel ( ) const
noexcept

Returns the channel number from a channel meta-event.

Returns
the channel, in the range 1 to 16.
See also
isMidiChannelMetaEvent

◆ getMidiMachineControlCommand()

MidiMessage::MidiMachineControlCommand water::MidiMessage::getMidiMachineControlCommand ( ) const
noexcept

For an MMC message, this returns its type.

Make sure it's actually an MMC message with isMidiMachineControlMessage() before calling this method.

◆ getMidiNoteInHertz()

double water::MidiMessage::getMidiNoteInHertz ( int noteNumber,
double frequencyOfA = 440.0 )
staticnoexcept

Returns the frequency of a midi note number.

The frequencyOfA parameter is an optional frequency for 'A', normally 440-444Hz for concert pitch.

See also
getMidiNoteName

◆ getNoteNumber()

int water::MidiMessage::getNoteNumber ( ) const
noexcept

Returns the midi note number for note-on and note-off messages. If the message isn't a note-on or off, the value returned is undefined.

See also
isNoteOff, getMidiNoteName, getMidiNoteInHertz, setNoteNumber

◆ getPitchWheelValue()

int water::MidiMessage::getPitchWheelValue ( ) const
noexcept

Returns the pitch wheel position from a pitch-wheel move message.

The value returned is a 14-bit number from 0 to 0x3fff, indicating the wheel position. If called for messages which aren't pitch wheel events, the number returned will be nonsense.

See also
isPitchWheel

◆ getProgramChangeNumber()

int water::MidiMessage::getProgramChangeNumber ( ) const
noexcept

Returns the new program number of a program change message. If the message isn't a program change, the value returned is undefined.

See also
isProgramChange

◆ getQuarterFrameSequenceNumber()

int water::MidiMessage::getQuarterFrameSequenceNumber ( ) const
noexcept

Returns the sequence number of a quarter-frame midi timecode message. This will be a value between 0 and 7.

See also
isQuarterFrame, getQuarterFrameValue, quarterFrame

◆ getQuarterFrameValue()

int water::MidiMessage::getQuarterFrameValue ( ) const
noexcept

Returns the value from a quarter-frame message. This will be the lower nybble of the message's data-byte, a value between 0 and 15

◆ getRawData()

const uint8 * water::MidiMessage::getRawData ( ) const
inlinenoexcept

Returns a pointer to the raw midi data.

See also
getRawDataSize

◆ getRawDataSize()

int water::MidiMessage::getRawDataSize ( ) const
inlinenoexcept

Returns the number of bytes of data in the message.

See also
getRawData

◆ getSongPositionPointerMidiBeat()

int water::MidiMessage::getSongPositionPointerMidiBeat ( ) const
noexcept

Returns the midi beat-number of a song-position-pointer message.

See also
isSongPositionPointer, songPositionPointer

◆ getSysExData()

const uint8 * water::MidiMessage::getSysExData ( ) const
noexcept

Returns a pointer to the sysex data inside the message. If this event isn't a sysex event, it'll return 0.

See also
getSysExDataSize

◆ getSysExDataSize()

int water::MidiMessage::getSysExDataSize ( ) const
noexcept

Returns the size of the sysex data. This value excludes the 0xf0 header byte and the 0xf7 at the end.

See also
getSysExData

◆ getTempoMetaEventTickLength()

double water::MidiMessage::getTempoMetaEventTickLength ( short timeFormat) const
noexcept

Returns the tick length from a tempo meta-event.

Parameters
timeFormatthe 16-bit time format value from the midi file's header.
Returns
the tick length (in seconds).
See also
isTempoMetaEvent

◆ getTempoSecondsPerQuarterNote()

double water::MidiMessage::getTempoSecondsPerQuarterNote ( ) const
noexcept

Calculates the seconds-per-quarter-note from a tempo meta-event.

See also
isTempoMetaEvent, getTempoMetaEventTickLength

◆ getTimeSignatureInfo()

void water::MidiMessage::getTimeSignatureInfo ( int & numerator,
int & denominator ) const
noexcept

Returns the time-signature values from a time-signature meta-event.

See also
isTimeSignatureMetaEvent

◆ getTimeStamp()

double water::MidiMessage::getTimeStamp ( ) const
inlinenoexcept

Returns the timestamp associated with this message.

The exact meaning of this time and its units will vary, as messages are used in a variety of different contexts.

If you're getting the message from a midi file, this could be a time in seconds, or a number of ticks - see MidiFile::convertTimestampTicksToSeconds().

If the message is being used in a MidiBuffer, it might indicate the number of audio samples from the start of the buffer.

If the message was created by a MidiInput, see MidiInputCallback::handleIncomingMidiMessage() for details of the way that it initialises this value.

See also
setTimeStamp, addToTimeStamp

◆ getVelocity()

uint8 water::MidiMessage::getVelocity ( ) const
noexcept

Returns the velocity of a note-on or note-off message.

The value returned will be in the range 0 to 127. If the message isn't a note-on or off event, it will return 0.

See also
getFloatVelocity

◆ isActiveSense()

bool water::MidiMessage::isActiveSense ( ) const
noexcept

Returns true if this is an active-sense message.

◆ isAftertouch()

bool water::MidiMessage::isAftertouch ( ) const
noexcept

Returns true if the message is an aftertouch event.

For aftertouch events, use the getNoteNumber() method to find out the key that it applies to, and getAftertouchValue() to find out the amount. Use getChannel() to find out the channel.

See also
getAftertouchValue, getNoteNumber

◆ isAllNotesOff()

bool water::MidiMessage::isAllNotesOff ( ) const
noexcept

Checks whether this message is an all-notes-off message.

See also
allNotesOff

◆ isAllSoundOff()

bool water::MidiMessage::isAllSoundOff ( ) const
noexcept

Checks whether this message is an all-sound-off message.

See also
allSoundOff

◆ isChannelPressure()

bool water::MidiMessage::isChannelPressure ( ) const
noexcept

Returns true if the message is a channel-pressure change event.

This is like aftertouch, but common to the whole channel rather than a specific note. Use getChannelPressureValue() to find out the pressure, and getChannel() to find out the channel.

See also
channelPressureChange

◆ isController()

bool water::MidiMessage::isController ( ) const
noexcept

Returns true if this is a midi controller message.

See also
getControllerNumber, getControllerValue, controllerEvent

◆ isControllerOfType()

bool water::MidiMessage::isControllerOfType ( int controllerType) const
noexcept

Returns true if this message is a controller message and if it has the specified controller type.

◆ isForChannel()

bool water::MidiMessage::isForChannel ( int channelNumber) const
noexcept

Returns true if the message applies to the given midi channel.

Parameters
channelNumberthe channel number to look for, in the range 1 to 16
See also
getChannel, setChannel

◆ isFullFrame()

bool water::MidiMessage::isFullFrame ( ) const
noexcept

Returns true if this is a full-frame midi timecode message.

◆ isHeapAllocated()

bool water::MidiMessage::isHeapAllocated ( ) const
inlineprivatenoexcept

◆ isKeySignatureMajorKey()

bool water::MidiMessage::isKeySignatureMajorKey ( ) const
noexcept

Returns true if this key-signature event is major, or false if it's minor. This method must only be called if isKeySignatureMetaEvent() is true.

◆ isKeySignatureMetaEvent()

bool water::MidiMessage::isKeySignatureMetaEvent ( ) const
noexcept

Returns true if this is a 'key-signature' meta-event.

See also
getKeySignatureNumberOfSharpsOrFlats, isKeySignatureMajorKey

◆ isMetaEvent()

bool water::MidiMessage::isMetaEvent ( ) const
noexcept

Returns true if this event is a meta-event.

Meta-events are things like tempo changes, track names, etc.

See also
getMetaEventType, isTempoMetaEvent, isTimeSignatureMetaEvent, isKeySignatureMetaEvent, isMidiChannelMetaEvent

◆ isMidiChannelMetaEvent()

bool water::MidiMessage::isMidiChannelMetaEvent ( ) const
noexcept

Returns true if this is a 'channel' meta-event.

A channel meta-event specifies the midi channel that should be used for subsequent meta-events.

See also
getMidiChannelMetaEventChannel

◆ isMidiClock()

bool water::MidiMessage::isMidiClock ( ) const
noexcept

Returns true if this is a midi clock event.

See also
midiClock, songPositionPointer

◆ isMidiContinue()

bool water::MidiMessage::isMidiContinue ( ) const
noexcept

Returns true if this is a midi continue event.

See also
midiContinue

◆ isMidiMachineControlGoto()

bool water::MidiMessage::isMidiMachineControlGoto ( int & hours,
int & minutes,
int & seconds,
int & frames ) const
noexcept

Checks whether this is an MMC "goto" message. If it is, the parameters passed-in are set to the time that the message contains.

See also
midiMachineControlGoto

◆ isMidiMachineControlMessage()

bool water::MidiMessage::isMidiMachineControlMessage ( ) const
noexcept

Checks whether this is an MMC message. If it is, you can use the getMidiMachineControlCommand() to find out its type.

◆ isMidiNoteBlack()

bool water::MidiMessage::isMidiNoteBlack ( int noteNumber)
staticnoexcept

Returns true if the given midi note number is a black key.

◆ isMidiStart()

bool water::MidiMessage::isMidiStart ( ) const
noexcept

Returns true if this is a midi start event.

See also
midiStart

◆ isMidiStop()

bool water::MidiMessage::isMidiStop ( ) const
noexcept

Returns true if this is a midi stop event.

See also
midiStop

◆ isNoteOff()

bool water::MidiMessage::isNoteOff ( bool returnTrueForNoteOnVelocity0 = true) const
noexcept

Returns true if this message is a 'key-up' event.

If returnTrueForNoteOnVelocity0 is true, then his will also return true for a note-on event with a velocity of 0.

See also
isNoteOn, getNoteNumber, getVelocity, noteOff

◆ isNoteOn()

bool water::MidiMessage::isNoteOn ( bool returnTrueForVelocity0 = false) const
noexcept

Returns true if this message is a 'key-down' event.

Parameters
returnTrueForVelocity0if true, then if this event is a note-on with velocity 0, it will still be considered to be a note-on and the method will return true. If returnTrueForVelocity0 is false, then if this is a note-on event with velocity 0, it'll be regarded as a note-off, and the method will return false
See also
isNoteOff, getNoteNumber, getVelocity, noteOn

◆ isNoteOnOrOff()

bool water::MidiMessage::isNoteOnOrOff ( ) const
noexcept

Returns true if this message is a 'key-down' or 'key-up' event.

See also
isNoteOn, isNoteOff

◆ isPitchWheel()

bool water::MidiMessage::isPitchWheel ( ) const
noexcept

Returns true if the message is a pitch-wheel move.

See also
getPitchWheelValue, pitchWheel

◆ isProgramChange()

bool water::MidiMessage::isProgramChange ( ) const
noexcept

Returns true if the message is a program (patch) change message.

See also
getProgramChangeNumber

◆ isQuarterFrame()

bool water::MidiMessage::isQuarterFrame ( ) const
noexcept

Returns true if this is a quarter-frame midi timecode message.

See also
quarterFrame, getQuarterFrameSequenceNumber, getQuarterFrameValue

◆ isSoftPedalOff()

bool water::MidiMessage::isSoftPedalOff ( ) const
noexcept

Returns true if this message is a 'soft pedal up' controller message.

◆ isSoftPedalOn()

bool water::MidiMessage::isSoftPedalOn ( ) const
noexcept

Returns true if this message is a 'soft pedal down' controller message.

◆ isSongPositionPointer()

bool water::MidiMessage::isSongPositionPointer ( ) const
noexcept

Returns true if this is a song-position-pointer message.

See also
getSongPositionPointerMidiBeat, songPositionPointer

◆ isSostenutoPedalOff()

bool water::MidiMessage::isSostenutoPedalOff ( ) const
noexcept

Returns true if this message is a 'sostenuto pedal up' controller message.

◆ isSostenutoPedalOn()

bool water::MidiMessage::isSostenutoPedalOn ( ) const
noexcept

Returns true if this message is a 'sostenuto pedal down' controller message.

◆ isSustainPedalOff()

bool water::MidiMessage::isSustainPedalOff ( ) const
noexcept

Returns true if this message is a 'sustain pedal up' controller message.

◆ isSustainPedalOn()

bool water::MidiMessage::isSustainPedalOn ( ) const
noexcept

Returns true if this message is a 'sustain pedal down' controller message.

◆ isSysEx()

bool water::MidiMessage::isSysEx ( ) const
noexcept

Returns true if this is a system-exclusive message.

◆ isTempoMetaEvent()

bool water::MidiMessage::isTempoMetaEvent ( ) const
noexcept

Returns true if this is a 'tempo' meta-event.

See also
getTempoMetaEventTickLength, getTempoSecondsPerQuarterNote

◆ isTimeSignatureMetaEvent()

bool water::MidiMessage::isTimeSignatureMetaEvent ( ) const
noexcept

Returns true if this is a 'time-signature' meta-event.

See also
getTimeSignatureInfo

◆ keySignatureMetaEvent()

MidiMessage water::MidiMessage::keySignatureMetaEvent ( int numberOfSharpsOrFlats,
bool isMinorKey )
static

Creates a key-signature meta-event.

Parameters
numberOfSharpsOrFlatsif positive, this indicates the number of sharps in the key; if negative, the number of flats
isMinorKeyif true, the key is minor; if false, it is major
See also
isKeySignatureMetaEvent

◆ masterVolume()

MidiMessage water::MidiMessage::masterVolume ( float volume)
static

Creates a master-volume change message.

Parameters
volumethe volume, 0 to 1.0

◆ midiChannelMetaEvent()

MidiMessage water::MidiMessage::midiChannelMetaEvent ( int channel)
staticnoexcept

Creates a midi channel meta-event.

Parameters
channelthe midi channel, in the range 1 to 16
See also
isMidiChannelMetaEvent

◆ midiClock()

MidiMessage water::MidiMessage::midiClock ( )
staticnoexcept

Creates a midi clock event.

◆ midiContinue()

MidiMessage water::MidiMessage::midiContinue ( )
staticnoexcept

Creates a midi continue event.

◆ midiMachineControlCommand()

MidiMessage water::MidiMessage::midiMachineControlCommand ( MidiMessage::MidiMachineControlCommand command)
static

Creates an MMC message.

◆ midiMachineControlGoto()

MidiMessage water::MidiMessage::midiMachineControlGoto ( int hours,
int minutes,
int seconds,
int frames )
static

Creates an MMC "goto" message. This messages tells the device to go to a specific frame.

See also
isMidiMachineControlGoto

◆ midiStart()

MidiMessage water::MidiMessage::midiStart ( )
staticnoexcept

Creates a midi start event.

◆ midiStop()

MidiMessage water::MidiMessage::midiStop ( )
staticnoexcept

Creates a midi stop event.

◆ multiplyVelocity()

void water::MidiMessage::multiplyVelocity ( float scaleFactor)
noexcept

Multiplies the velocity of a note-on or note-off message by a given amount.

If the message isn't a note on or off, this will do nothing.

Parameters
scaleFactorthe value by which to multiply the velocity
See also
setVelocity

◆ noteOff() [1/3]

MidiMessage water::MidiMessage::noteOff ( int channel,
int noteNumber )
staticnoexcept

Creates a key-up message.

Parameters
channelthe midi channel, in the range 1 to 16
noteNumberthe key number, 0 to 127
See also
isNoteOff

◆ noteOff() [2/3]

MidiMessage water::MidiMessage::noteOff ( int channel,
int noteNumber,
float velocity )
staticnoexcept

Creates a key-up message.

Parameters
channelthe midi channel, in the range 1 to 16
noteNumberthe key number, 0 to 127
velocityin the range 0 to 1.0
See also
isNoteOff

◆ noteOff() [3/3]

MidiMessage water::MidiMessage::noteOff ( int channel,
int noteNumber,
uint8 velocity )
staticnoexcept

Creates a key-up message.

Parameters
channelthe midi channel, in the range 1 to 16
noteNumberthe key number, 0 to 127
velocityin the range 0 to 127
See also
isNoteOff

◆ noteOn() [1/2]

MidiMessage water::MidiMessage::noteOn ( int channel,
int noteNumber,
float velocity )
staticnoexcept

Creates a key-down message (using a floating-point velocity).

Parameters
channelthe midi channel, in the range 1 to 16
noteNumberthe key number, 0 to 127
velocityin the range 0 to 1.0
See also
isNoteOn

◆ noteOn() [2/2]

MidiMessage water::MidiMessage::noteOn ( int channel,
int noteNumber,
uint8 velocity )
staticnoexcept

Creates a key-down message (using an integer velocity).

Parameters
channelthe midi channel, in the range 1 to 16
noteNumberthe key number, 0 to 127
velocityin the range 0 to 127
See also
isNoteOn

◆ operator=()

MidiMessage & water::MidiMessage::operator= ( const MidiMessage & other)

Copies this message from another one.

◆ pitchbendToPitchwheelPos()

uint16 water::MidiMessage::pitchbendToPitchwheelPos ( float pitchbendInSemitones,
float pitchbendRangeInSemitones )
staticnoexcept

Converts a pitchbend value in semitones to a MIDI 14-bit pitchwheel position value.

◆ pitchWheel()

MidiMessage water::MidiMessage::pitchWheel ( int channel,
int position )
staticnoexcept

Creates a pitch-wheel move message.

Parameters
channelthe midi channel, in the range 1 to 16
positionthe wheel position, in the range 0 to 16383
See also
isPitchWheel

◆ programChange()

MidiMessage water::MidiMessage::programChange ( int channel,
int programNumber )
staticnoexcept

Creates a program-change message.

Parameters
channelthe midi channel, in the range 1 to 16
programNumberthe midi program number, 0 to 127
See also
isProgramChange

◆ quarterFrame()

MidiMessage water::MidiMessage::quarterFrame ( int sequenceNumber,
int value )
staticnoexcept

Creates a quarter-frame MTC message.

Parameters
sequenceNumbera value 0 to 7 for the upper nybble of the message's data byte
valuea value 0 to 15 for the lower nybble of the message's data byte

◆ readVariableLengthVal()

int water::MidiMessage::readVariableLengthVal ( const uint8 * data,
int & numBytesUsed )
staticnoexcept

Reads a midi variable-length integer.

Parameters
datathe data to read the number from
numBytesUsedon return, this will be set to the number of bytes that were read

◆ setChannel()

void water::MidiMessage::setChannel ( int newChannelNumber)
noexcept

Changes the message's midi channel. This won't do anything for non-channel messages like sysexes.

Parameters
newChannelNumberthe channel number to change it to, in the range 1 to 16

◆ setNoteNumber()

void water::MidiMessage::setNoteNumber ( int newNoteNumber)
noexcept

Changes the midi note number of a note-on or note-off message. If the message isn't a note on or off, this will do nothing.

◆ setTimeStamp()

void water::MidiMessage::setTimeStamp ( double newTimestamp)
inlinenoexcept

Changes the message's associated timestamp. The units for the timestamp will be application-specific - see the notes for getTimeStamp().

See also
addToTimeStamp, getTimeStamp

◆ setVelocity()

void water::MidiMessage::setVelocity ( float newVelocity)
noexcept

Changes the velocity of a note-on or note-off message.

If the message isn't a note on or off, this will do nothing.

Parameters
newVelocitythe new velocity, in the range 0 to 1.0
See also
getFloatVelocity, multiplyVelocity

◆ songPositionPointer()

MidiMessage water::MidiMessage::songPositionPointer ( int positionInMidiBeats)
staticnoexcept

Creates a song-position-pointer message.

The position is a number of midi beats from the start of the song, where 1 midi beat is 6 midi clocks, and there are 24 midi clocks in a quarter-note. So there are 4 midi beats in a quarter-note.

See also
isSongPositionPointer, getSongPositionPointerMidiBeat

◆ tempoMetaEvent()

MidiMessage water::MidiMessage::tempoMetaEvent ( int microsecondsPerQuarterNote)
staticnoexcept

Creates a tempo meta-event.

See also
isTempoMetaEvent

◆ timeSignatureMetaEvent()

MidiMessage water::MidiMessage::timeSignatureMetaEvent ( int numerator,
int denominator )
static

Creates a time-signature meta-event.

See also
isTimeSignatureMetaEvent

Member Data Documentation

◆ packedData

PackedData water::MidiMessage::packedData
private

◆ size

int water::MidiMessage::size
private

◆ timeStamp

double water::MidiMessage::timeStamp
private

The documentation for this class was generated from the following files: