This struct represents a playing MPE note. More...

Public Types

enum  KeyState { off = 0, keyDown = 1, sustained = 2, keyDownAndSustained = 3 }
 

Public Member Functions

 MPENote (int midiChannel, int initialNote, MPEValue velocity, MPEValue pitchbend, MPEValue pressure, MPEValue timbre, KeyState keyState=MPENote::keyDown) noexcept
 Constructor. More...
 
 MPENote () noexcept
 Default constructor. More...
 
bool isValid () const noexcept
 Checks whether the MPE note is valid. More...
 
double getFrequencyInHertz (double frequencyOfA=440.0) const noexcept
 Returns the current frequency of the note in Hertz. More...
 
bool operator== (const MPENote &other) const noexcept
 Returns true if two notes are the same, determined by their unique ID. More...
 
bool operator!= (const MPENote &other) const noexcept
 Returns true if two notes are different notes, determined by their unique ID. More...
 

Public Attributes

uint16 noteID
 A unique ID. More...
 
uint8 midiChannel
 The MIDI channel which this note uses. More...
 
uint8 initialNote
 The MIDI note number that was sent when the note was triggered. More...
 
MPEValue noteOnVelocity
 The velocity ("strike") of the note-on. More...
 
MPEValue pitchbend
 Current per-note pitchbend of the note (in units of MIDI pitchwheel position). More...
 
MPEValue pressure
 Current pressure with which the note is held down. More...
 
MPEValue timbre
 Current value of the note's third expressive dimension, tyically encoding some kind of timbre parameter. More...
 
MPEValue noteOffVelocity
 The release velocity ("lift") of the note after a note-off has been received. More...
 
double totalPitchbendInSemitones
 Current effective pitchbend of the note in units of semitones, relative to initialNote. More...
 
KeyState keyState
 Current key state. More...
 

Detailed Description

This struct represents a playing MPE note.

A note is identified by a unique ID, or alternatively, by a MIDI channel and an initial note. It is characterised by five dimensions of continuous expressive control. Their current values are represented as MPEValue objects.

See also
MPEValue

Member Enumeration Documentation

◆ KeyState

Enumerator
off 
keyDown 
sustained 
keyDownAndSustained 

Constructor & Destructor Documentation

◆ MPENote() [1/2]

MPENote::MPENote ( int  midiChannel,
int  initialNote,
MPEValue  velocity,
MPEValue  pitchbend,
MPEValue  pressure,
MPEValue  timbre,
KeyState  keyState = MPENote::keyDown 
)
noexcept

Constructor.

Parameters
midiChannelThe MIDI channel of the note, between 2 and 16. (Channel 1 can never be a note channel in MPE).
initialNoteThe MIDI note number, between 0 and 127.
velocityThe note-on velocity of the note.
pitchbendThe initial per-note pitchbend of the note.
pressureThe initial pressure of the note.
timbreThe timbre value of the note.
keyStateThe key state of the note (whether the key is down and/or the note is sustained). This value must not be MPENote::off, since you are triggering a new note. (If not specified, the default value will be MPENOte::keyDown.)

◆ MPENote() [2/2]

MPENote::MPENote ( )
noexcept

Default constructor.

Constructs an invalid MPE note (a note with the key state MPENote::off and an invalid MIDI channel. The only allowed use for such a note is to call isValid() on it; everything else is undefined behaviour.

Member Function Documentation

◆ isValid()

bool MPENote::isValid ( ) const
noexcept

Checks whether the MPE note is valid.

◆ getFrequencyInHertz()

double MPENote::getFrequencyInHertz ( double  frequencyOfA = 440.0) const
noexcept

Returns the current frequency of the note in Hertz.

This is the a sum of the initialNote and the totalPitchbendInSemitones, converted to Hertz.

◆ operator==()

bool MPENote::operator== ( const MPENote other) const
noexcept

Returns true if two notes are the same, determined by their unique ID.

◆ operator!=()

bool MPENote::operator!= ( const MPENote other) const
noexcept

Returns true if two notes are different notes, determined by their unique ID.

Member Data Documentation

◆ noteID

uint16 MPENote::noteID

A unique ID.

Useful to distinguish the note from other simultaneously sounding notes that may use the same note number or MIDI channel. This should never change during the lifetime of a note object.

◆ midiChannel

uint8 MPENote::midiChannel

The MIDI channel which this note uses.

This should never change during the lifetime of an MPENote object.

◆ initialNote

uint8 MPENote::initialNote

The MIDI note number that was sent when the note was triggered.

This should never change during the lifetime of an MPENote object.

◆ noteOnVelocity

MPEValue MPENote::noteOnVelocity

The velocity ("strike") of the note-on.

This dimension will stay constant after the note has been turned on.

◆ pitchbend

MPEValue MPENote::pitchbend

Current per-note pitchbend of the note (in units of MIDI pitchwheel position).

This dimension can be modulated while the note sounds.

Note: This value is not aware of the currently used pitchbend range, or an additional master pitchbend that may be simultaneously applied. To compute the actual effective pitchbend of an MPENote, you should probably use the member totalPitchbendInSemitones instead.

See also
totalPitchbendInSemitones, getFrequencyInHertz

◆ pressure

MPEValue MPENote::pressure

Current pressure with which the note is held down.

This dimension can be modulated while the note sounds.

◆ timbre

MPEValue MPENote::timbre

Current value of the note's third expressive dimension, tyically encoding some kind of timbre parameter.

This dimension can be modulated while the note sounds.

◆ noteOffVelocity

MPEValue MPENote::noteOffVelocity

The release velocity ("lift") of the note after a note-off has been received.

This dimension will only have a meaningful value after a note-off has been received for the note (and keyState is set to MPENote::off or MPENOte::sustained). Initially, the value is undefined.

◆ totalPitchbendInSemitones

double MPENote::totalPitchbendInSemitones

Current effective pitchbend of the note in units of semitones, relative to initialNote.

You should use this to compute the actual effective pitch of the note. This value is computed and set by an MPEInstrument to the sum of the per-note pitchbend value (stored in MPEValue::pitchbend) and the master pitchbend of the MPE zone, weighted with the per-note pitchbend range and master pitchbend range of the zone, respectively.

See also
getFrequencyInHertz

◆ keyState

KeyState MPENote::keyState

Current key state.

Indicates whether the note key is currently down (pressed) and/or the note is sustained (by a sustain or sostenuto pedal).


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