NAP
MidiEvent Class Reference

#include <midievent.h>

Public Types

enum  Type {
  noteOff = 0x80, noteOn = 0x90, afterTouch = 0xA0, controlChange = 0xB0,
  programChange = 0xC0, channelPressure = 0xD0, pitchBend = 0xE0
}
 

Public Member Functions

 MidiEvent ()=default
 
 MidiEvent (Type aType, MidiValue number=MIDI_NUMBER_OMNI, MidiValue value=MIDI_VALUE_OMNI, MidiValue channel=MIDI_CHANNEL_OMNI, const std::string &port="")
 
 MidiEvent (const std::vector< unsigned char > &data, const std::string &port)
 
virtual ~MidiEvent ()=default
 
bool corresponds (const MidiEvent &b) const
 
bool operator== (const MidiEvent &rhs) const
 
bool operator> (const MidiEvent &rhs) const
 
bool operator< (const MidiEvent &rhs) const
 
Type getType () const
 
MidiValue getNumber () const
 
MidiValue getValue () const
 
MidiValue getNoteNumber () const
 
MidiValue getVelocity () const
 
MidiValue getCCNumber () const
 
MidiValue getCCValue () const
 
float getPitchBendValue () const
 
MidiValue getProgramNumber () const
 
MidiValue getChannel () const
 
std::string getPort () const
 
std::string toString () const
 
std::vector< unsigned char > getData () const
 
- Public Member Functions inherited from Event
virtual ~Event ()=default
 
 Event ()=default
 
 Event (Event &)=delete
 
Eventoperator= (const Event &)=delete
 

Static Public Attributes

static constexpr MidiValue MIDI_MAX_VALUE = 127
 
static constexpr MidiValue MIDI_CONTROLLER_SUSTAIN = 64
 
static constexpr MidiValue MIDI_VALUE_OMNI = -1
 
static constexpr MidiValue MIDI_NUMBER_OMNI = MIDI_VALUE_OMNI
 
static constexpr MidiValue MIDI_CHANNEL_OMNI = MIDI_VALUE_OMNI
 
static constexpr MidiValue MIDI_NUMBER_NONE = 0
 

Detailed Description

Event representation of a midi message Storing a readable representation of the raw midi message and optionally the port number through which it is sent.

Inheritance diagram for MidiEvent:
[legend]
Collaboration diagram for MidiEvent:
[legend]

Member Enumeration Documentation

◆ Type

enum Type
strong

Different kinds of midi events

Enumerator
noteOff 

Note off message.

noteOn 

Note on message.

afterTouch 

After touch message.

controlChange 

Control change message.

programChange 

Program change message.

channelPressure 

Channel pressure message.

pitchBend 

Pitch band change.

Constructor & Destructor Documentation

◆ MidiEvent() [1/3]

MidiEvent ( )
default

◆ MidiEvent() [2/3]

MidiEvent ( Type  aType,
MidiValue  number = MIDI_NUMBER_OMNI,
MidiValue  value = MIDI_VALUE_OMNI,
MidiValue  channel = MIDI_CHANNEL_OMNI,
const std::string &  port = "" 
)

Constructor passing in values

◆ MidiEvent() [3/3]

MidiEvent ( const std::vector< unsigned char > &  data,
const std::string &  port 
)

Construct event from raw message data

◆ ~MidiEvent()

virtual ~MidiEvent ( )
virtualdefault

Member Function Documentation

◆ corresponds()

bool corresponds ( const MidiEvent b) const

this method checks if the messages described with b correspond to this message (using the OMNI wildcards)

◆ getCCNumber()

MidiValue getCCNumber ( ) const

If a control change event, this returns the controller number

◆ getCCValue()

MidiValue getCCValue ( ) const

If a control change event, this returns the controller value

◆ getChannel()

MidiValue getChannel ( ) const

The midi channel this event is emitted on

◆ getData()

std::vector<unsigned char> getData ( ) const

Returns a raw data midi message that corresponds to the event and can be sent through midi output port.

◆ getNoteNumber()

MidiValue getNoteNumber ( ) const

If a note on or off event, this returns the note number

◆ getNumber()

MidiValue getNumber ( ) const

Returns the first byte: note number, cc number or program number

◆ getPitchBendValue()

float getPitchBendValue ( ) const

If a pitch bend event, this returns the pitchbend amount between -1 and 1.

◆ getPort()

std::string getPort ( ) const

the mID of the port object through which the message is received, not to be confused with the physical portname

◆ getProgramNumber()

MidiValue getProgramNumber ( ) const

If a program change event, this returns the program number

◆ getType()

Type getType ( ) const

The type of the event

◆ getValue()

MidiValue getValue ( ) const

Returns the second byte: velocity, CC value

◆ getVelocity()

MidiValue getVelocity ( ) const

If a note on or off event, this returns the velocity

◆ operator<()

bool operator< ( const MidiEvent rhs) const

◆ operator==()

bool operator== ( const MidiEvent rhs) const

◆ operator>()

bool operator> ( const MidiEvent rhs) const

◆ toString()

std::string toString ( ) const

Returns the contents of the event as a formatted text string for logging

Member Data Documentation

◆ MIDI_CHANNEL_OMNI

constexpr MidiValue MIDI_CHANNEL_OMNI = MIDI_VALUE_OMNI
static

Wildcard value for midi channels

◆ MIDI_CONTROLLER_SUSTAIN

constexpr MidiValue MIDI_CONTROLLER_SUSTAIN = 64
static

CC number for sustain pedal

◆ MIDI_MAX_VALUE

constexpr MidiValue MIDI_MAX_VALUE = 127
static

Maximum value of a midi byte

◆ MIDI_NUMBER_NONE

constexpr MidiValue MIDI_NUMBER_NONE = 0
static

◆ MIDI_NUMBER_OMNI

constexpr MidiValue MIDI_NUMBER_OMNI = MIDI_VALUE_OMNI
static

Wildcard value for midi numbers

◆ MIDI_VALUE_OMNI

constexpr MidiValue MIDI_VALUE_OMNI = -1
static

Wildcard value for midi values