iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
IMidiMsg Struct Reference

Encapsulates a MIDI message and provides helper functions. More...

#include <IPlugMidi.h>

Public Types

enum  EStatusMsg {
  kNone = 0 , kNoteOff = 8 , kNoteOn = 9 , kPolyAftertouch = 10 ,
  kControlChange = 11 , kProgramChange = 12 , kChannelAftertouch = 13 , kPitchWheel = 14
}
 Constants for the status byte of a MIDI message. More...
 
enum  EControlChangeMsg {
  kNoCC = -1 , kModWheel = 1 , kBreathController = 2 , kUndefined003 = 3 ,
  kFootController = 4 , kPortamentoTime = 5 , kChannelVolume = 7 , kBalance = 8 ,
  kUndefined009 = 9 , kPan = 10 , kExpressionController = 11 , kEffectControl1 = 12 ,
  kEffectControl2 = 13 , kUndefined014 = 14 , kUndefined015 = 15 , kGeneralPurposeController1 = 16 ,
  kGeneralPurposeController2 = 17 , kGeneralPurposeController3 = 18 , kGeneralPurposeController4 = 19 , kUndefined020 = 20 ,
  kUndefined021 = 21 , kUndefined022 = 22 , kUndefined023 = 23 , kUndefined024 = 24 ,
  kUndefined025 = 25 , kUndefined026 = 26 , kUndefined027 = 27 , kUndefined028 = 28 ,
  kUndefined029 = 29 , kUndefined030 = 30 , kUndefined031 = 31 , kSustainOnOff = 64 ,
  kPortamentoOnOff = 65 , kSustenutoOnOff = 66 , kSoftPedalOnOff = 67 , kLegatoOnOff = 68 ,
  kHold2OnOff = 69 , kSoundVariation = 70 , kResonance = 71 , kReleaseTime = 72 ,
  kAttackTime = 73 , kCutoffFrequency = 74 , kDecayTime = 75 , kVibratoRate = 76 ,
  kVibratoDepth = 77 , kVibratoDelay = 78 , kSoundControllerUndefined = 79 , kUndefined085 = 85 ,
  kUndefined086 = 86 , kUndefined087 = 87 , kUndefined088 = 88 , kUndefined089 = 89 ,
  kUndefined090 = 90 , kTremoloDepth = 92 , kChorusDepth = 93 , kPhaserDepth = 95 ,
  kUndefined102 = 102 , kUndefined103 = 103 , kUndefined104 = 104 , kUndefined105 = 105 ,
  kUndefined106 = 106 , kUndefined107 = 107 , kUndefined108 = 108 , kUndefined109 = 109 ,
  kUndefined110 = 110 , kUndefined111 = 111 , kUndefined112 = 112 , kUndefined113 = 113 ,
  kUndefined114 = 114 , kUndefined115 = 115 , kUndefined116 = 116 , kUndefined117 = 117 ,
  kUndefined118 = 118 , kUndefined119 = 119 , kAllNotesOff = 123
}
 Constants for MIDI CC messages. More...
 

Public Member Functions

 IMidiMsg (int offset=0, uint8_t status=0, uint8_t data1=0, uint8_t data2=0)
 Create an IMidiMsg, an abstraction for a MIDI message. More...
 
void MakeNoteOnMsg (int noteNumber, int velocity, int offset, int channel=0)
 Make a Note On message. More...
 
void MakeNoteOffMsg (int noteNumber, int offset, int channel=0)
 Make a Note Off message. More...
 
void MakePitchWheelMsg (double value, int channel=0, int offset=0)
 Create a pitch wheel/bend message. More...
 
void MakeControlChangeMsg (EControlChangeMsg idx, double value, int channel=0, int offset=0)
 Create a CC message. More...
 
void MakeProgramChange (int program, int channel=0, int offset=0)
 Create a Program Change message. More...
 
void MakeChannelATMsg (int pressure, int offset, int channel)
 Create a Channel AfterTouch message. More...
 
void MakePolyATMsg (int noteNumber, int pressure, int offset, int channel)
 Create a Poly AfterTouch message. More...
 
int Channel () const
 Gets the channel of a MIDI message. More...
 
EStatusMsg StatusMsg () const
 Gets the MIDI Status message. More...
 
int NoteNumber () const
 Gets the MIDI note number. More...
 
int Velocity () const
 Get the velocity value of a NoteOn/NoteOff message. More...
 
int PolyAfterTouch () const
 Get the Pressure value from a PolyAfterTouch message. More...
 
int ChannelAfterTouch () const
 Get the Pressure value from an AfterTouch message. More...
 
int Program () const
 Get the program index from a Program Change message. More...
 
double PitchWheel () const
 Get the value from a Pitchwheel message. More...
 
EControlChangeMsg ControlChangeIdx () const
 Gets the controller index of a CC message. More...
 
double ControlChange (EControlChangeMsg idx) const
 Get the value of a CC message. More...
 
void Clear ()
 Clear the message. More...
 
void LogMsg ()
 Log a message (TRACER BUILDS) More...
 
void PrintMsg () const
 Print a message (DEBUG BUILDS) More...
 

Static Public Member Functions

static bool ControlChangeOnOff (double msgValue)
 Helper to get a boolean value from a CC messages. More...
 
static const char * StatusMsgStr (EStatusMsg msg)
 Get the Status Message as a CString. More...
 
static const char * CCNameStr (int idx)
 Get the CC name as a CString. More...
 

Public Attributes

int mOffset
 
uint8_t mStatus
 
uint8_t mData1
 
uint8_t mData2
 

Detailed Description

Encapsulates a MIDI message and provides helper functions.

Definition at line 30 of file IPlugMidi.h.

Member Enumeration Documentation

◆ EControlChangeMsg

Constants for MIDI CC messages.

Definition at line 49 of file IPlugMidi.h.

◆ EStatusMsg

Constants for the status byte of a MIDI message.

Definition at line 36 of file IPlugMidi.h.

Constructor & Destructor Documentation

◆ IMidiMsg()

IMidiMsg::IMidiMsg ( int  offset = 0,
uint8_t  status = 0,
uint8_t  data1 = 0,
uint8_t  data2 = 0 
)
inline

Create an IMidiMsg, an abstraction for a MIDI message.

Parameters
offsetSample offset in block
statusStatus byte
data1Data byte 1
data2Data byte 2

Definition at line 133 of file IPlugMidi.h.

Member Function Documentation

◆ CCNameStr()

static const char * IMidiMsg::CCNameStr ( int  idx)
inlinestatic

Get the CC name as a CString.

Parameters
idxIndex of the MIDI CC [0-127]
Returns
CString describing the controller

Definition at line 386 of file IPlugMidi.h.

◆ Channel()

int IMidiMsg::Channel ( ) const
inline

Gets the channel of a MIDI message.

Returns
[0, 15] for midi channels 1 ... 16.

Definition at line 236 of file IPlugMidi.h.

Referenced by LogMsg(), and PrintMsg().

◆ ChannelAfterTouch()

int IMidiMsg::ChannelAfterTouch ( ) const
inline

Get the Pressure value from an AfterTouch message.

Returns
[0, 127], -1 if NA.

Definition at line 297 of file IPlugMidi.h.

References StatusMsg().

◆ Clear()

void IMidiMsg::Clear ( )
inline

◆ ControlChange()

double IMidiMsg::ControlChange ( EControlChangeMsg  idx) const
inline

Get the value of a CC message.

Returns
[0, 1], -1 if NA.

Definition at line 340 of file IPlugMidi.h.

References ControlChangeIdx(), and StatusMsg().

Referenced by IWheelControl::OnMidi().

◆ ControlChangeIdx()

EControlChangeMsg IMidiMsg::ControlChangeIdx ( ) const
inline

Gets the controller index of a CC message.

Returns
EControlChangeMsg as an Enum of varying values, refert to the definition of EControlChangeMsg.

Definition at line 333 of file IPlugMidi.h.

Referenced by ControlChange(), IVKeyboardControl::OnMidi(), and IWheelControl::OnMidi().

◆ ControlChangeOnOff()

static bool IMidiMsg::ControlChangeOnOff ( double  msgValue)
inlinestatic

Helper to get a boolean value from a CC messages.

Parameters
msgValueThe normalized CC value [0, 1]
Returns
true = on

Definition at line 352 of file IPlugMidi.h.

◆ LogMsg()

void IMidiMsg::LogMsg ( )
inline

Log a message (TRACER BUILDS)

Definition at line 524 of file IPlugMidi.h.

References Channel(), StatusMsg(), and StatusMsgStr().

◆ MakeChannelATMsg()

void IMidiMsg::MakeChannelATMsg ( int  pressure,
int  offset,
int  channel 
)
inline

Create a Channel AfterTouch message.

Parameters
pressureRange [0, 127]
offsetSample offset in block
channelMIDI channel [0, 15]

Definition at line 211 of file IPlugMidi.h.

References Clear().

◆ MakeControlChangeMsg()

void IMidiMsg::MakeControlChangeMsg ( EControlChangeMsg  idx,
double  value,
int  channel = 0,
int  offset = 0 
)
inline

Create a CC message.

Parameters
idxController index
valueRange [0, 1]
channelMIDI channel [0, 15]
offsetSample offset in block

Definition at line 186 of file IPlugMidi.h.

References Clear().

Referenced by IWheelControl::IWheelControl().

◆ MakeNoteOffMsg()

void IMidiMsg::MakeNoteOffMsg ( int  noteNumber,
int  offset,
int  channel = 0 
)
inline

Make a Note Off message.

Parameters
noteNumberNote number
offsetSample offset in block
channelMIDI channel [0, 15]

Definition at line 158 of file IPlugMidi.h.

References Clear().

Referenced by IGraphics::SetQwertyMidiKeyHandlerFunc().

◆ MakeNoteOnMsg()

void IMidiMsg::MakeNoteOnMsg ( int  noteNumber,
int  velocity,
int  offset,
int  channel = 0 
)
inline

Make a Note On message.

Parameters
noteNumberNote number
velocityNote on velocity
offsetSample offset in block
channelMIDI channel [0, 15]

Definition at line 145 of file IPlugMidi.h.

References Clear().

Referenced by IGraphics::SetQwertyMidiKeyHandlerFunc().

◆ MakePitchWheelMsg()

void IMidiMsg::MakePitchWheelMsg ( double  value,
int  channel = 0,
int  offset = 0 
)
inline

Create a pitch wheel/bend message.

Parameters
valueRange [-1, 1], converts to [0, 16384) where 8192 = no pitch change
channelMIDI channel [0, 15]
offsetSample offset in block

Definition at line 170 of file IPlugMidi.h.

References Clear().

Referenced by IWheelControl::IWheelControl().

◆ MakePolyATMsg()

void IMidiMsg::MakePolyATMsg ( int  noteNumber,
int  pressure,
int  offset,
int  channel 
)
inline

Create a Poly AfterTouch message.

Parameters
noteNumberNote number
pressureRange [0, 127]
offsetSample offset in block
channelMIDI channel [0, 15]

Definition at line 225 of file IPlugMidi.h.

References Clear().

◆ MakeProgramChange()

void IMidiMsg::MakeProgramChange ( int  program,
int  channel = 0,
int  offset = 0 
)
inline

Create a Program Change message.

Parameters
programProgram index
channelMIDI channel [0, 15]
offsetSample offset in block

Definition at line 199 of file IPlugMidi.h.

References Clear().

◆ NoteNumber()

int IMidiMsg::NoteNumber ( ) const
inline

Gets the MIDI note number.

Returns
[0, 127], -1 if NA.

Definition at line 255 of file IPlugMidi.h.

References StatusMsg().

Referenced by IVKeyboardControl::OnMidi().

◆ PitchWheel()

double IMidiMsg::PitchWheel ( ) const
inline

Get the value from a Pitchwheel message.

Returns
[-1.0, 1.0], zero if NA.

Definition at line 321 of file IPlugMidi.h.

References StatusMsg().

Referenced by IWheelControl::OnMidi().

◆ PolyAfterTouch()

int IMidiMsg::PolyAfterTouch ( ) const
inline

Get the Pressure value from a PolyAfterTouch message.

Returns
[0, 127], -1 if NA.

Definition at line 284 of file IPlugMidi.h.

References StatusMsg().

◆ PrintMsg()

void IMidiMsg::PrintMsg ( ) const
inline

Print a message (DEBUG BUILDS)

Definition at line 530 of file IPlugMidi.h.

References Channel(), StatusMsg(), and StatusMsgStr().

◆ Program()

int IMidiMsg::Program ( ) const
inline

Get the program index from a Program Change message.

Returns
[0, 127], -1 if NA.

Definition at line 310 of file IPlugMidi.h.

References StatusMsg().

◆ StatusMsg()

EStatusMsg IMidiMsg::StatusMsg ( ) const
inline

Gets the MIDI Status message.

Returns
EStatusMsg

Definition at line 243 of file IPlugMidi.h.

Referenced by ChannelAfterTouch(), ControlChange(), LogMsg(), NoteNumber(), IVKeyboardControl::OnMidi(), IWheelControl::OnMidi(), PitchWheel(), PolyAfterTouch(), PrintMsg(), Program(), and Velocity().

◆ StatusMsgStr()

static const char * IMidiMsg::StatusMsgStr ( EStatusMsg  msg)
inlinestatic

Get the Status Message as a CString.

Parameters
msgThe Status Message
Returns
CString describing the status byte

Definition at line 367 of file IPlugMidi.h.

Referenced by LogMsg(), and PrintMsg().

◆ Velocity()

int IMidiMsg::Velocity ( ) const
inline

Get the velocity value of a NoteOn/NoteOff message.

Returns
returns [0, 127], -1 if NA.

Definition at line 270 of file IPlugMidi.h.

References StatusMsg().

Referenced by IVKeyboardControl::OnMidi().

Member Data Documentation

◆ mData1

uint8_t IMidiMsg::mData1

Definition at line 33 of file IPlugMidi.h.

◆ mData2

uint8_t IMidiMsg::mData2

Definition at line 33 of file IPlugMidi.h.

◆ mOffset

int IMidiMsg::mOffset

Definition at line 32 of file IPlugMidi.h.

◆ mStatus

uint8_t IMidiMsg::mStatus

Definition at line 33 of file IPlugMidi.h.


The documentation for this struct was generated from the following file: