OpenShot Library | libopenshot-audio  0.2.0
juce::MPENote Struct Reference

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

#include <juce_MPENote.h>

Public Types

enum  KeyState { off = 0, keyDown = 1, sustained = 2, keyDownAndSustained = 3 }
 Possible values for the note key state. More...
 

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 = 0
 A unique ID. More...
 
uint8 midiChannel = 0
 The MIDI channel which this note uses. More...
 
uint8 initialNote = 0
 The MIDI note number that was sent when the note was triggered. More...
 
MPEValue noteOnVelocity { MPEValue::minValue() }
 The velocity ("strike") of the note-on. More...
 
MPEValue pitchbend { MPEValue::centreValue() }
 Current per-note pitchbend of the note (in units of MIDI pitchwheel position). More...
 
MPEValue pressure { MPEValue::centreValue() }
 Current pressure with which the note is held down. More...
 
MPEValue initialTimbre { MPEValue::centreValue() }
 Initial value of timbre when the note was triggered. More...
 
MPEValue timbre { MPEValue::centreValue() }
 Current value of the note's third expressive dimension, typically encoding some kind of timbre parameter. More...
 
MPEValue noteOffVelocity { MPEValue::minValue() }
 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 { MPENote::off }
 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

Definition at line 43 of file juce_MPENote.h.

Member Enumeration Documentation

◆ KeyState

Possible values for the note key state.

Enumerator
off 

The key is up (off).

keyDown 

The note key is currently down (pressed).

sustained 

The note is sustained (by a sustain or sostenuto pedal).

keyDownAndSustained 

The note key is down and sustained (by a sustain or sostenuto pedal).

Definition at line 47 of file juce_MPENote.h.

Constructor & Destructor Documentation

◆ MPENote() [1/2]

juce::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 15. (Channel 1 and channel 16 can never be note channels 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.)

Definition at line 38 of file juce_MPENote.cpp.

References off.

◆ MPENote() [2/2]

juce::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.

Definition at line 59 of file juce_MPENote.cpp.

Member Function Documentation

◆ isValid()

bool juce::MPENote::isValid ( ) const
noexcept

Checks whether the MPE note is valid.

Definition at line 62 of file juce_MPENote.cpp.

References initialNote, and midiChannel.

Referenced by juce::MPESynthesiser::findVoiceToSteal(), operator!=(), operator==(), and juce::MPEInstrument::releaseAllNotes().

◆ getFrequencyInHertz()

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

Returns the current frequency of the note in Hertz.

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

Definition at line 68 of file juce_MPENote.cpp.

References initialNote, and totalPitchbendInSemitones.

Referenced by operator!=().

◆ operator==()

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

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

Definition at line 75 of file juce_MPENote.cpp.

References isValid(), and noteID.

◆ operator!=()

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

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

Definition at line 81 of file juce_MPENote.cpp.

References getFrequencyInHertz(), initialNote, isValid(), noteID, and totalPitchbendInSemitones.

Member Data Documentation

◆ noteID

uint16 juce::MPENote::noteID = 0

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.

Definition at line 102 of file juce_MPENote.h.

Referenced by juce::MPESynthesiserVoice::isCurrentlyPlayingNote(), operator!=(), and operator==().

◆ midiChannel

uint8 juce::MPENote::midiChannel = 0

The MIDI channel which this note uses.

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

Definition at line 107 of file juce_MPENote.h.

Referenced by juce::MPEInstrument::getMostRecentNoteOtherThan(), isValid(), juce::MPEInstrument::releaseAllNotes(), juce::MPEInstrument::sostenutoPedal(), and juce::MPEInstrument::timbre().

◆ initialNote

uint8 juce::MPENote::initialNote = 0

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

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

Definition at line 112 of file juce_MPENote.h.

Referenced by juce::MPESynthesiser::findVoiceToSteal(), getFrequencyInHertz(), juce::MPEInstrument::getMostRecentNoteOtherThan(), isValid(), operator!=(), and juce::MPEInstrument::releaseAllNotes().

◆ noteOnVelocity

MPEValue juce::MPENote::noteOnVelocity { MPEValue::minValue() }

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

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

Definition at line 120 of file juce_MPENote.h.

Referenced by juce::MPEInstrument::releaseAllNotes().

◆ pitchbend

MPEValue juce::MPENote::pitchbend { MPEValue::centreValue() }

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

Definition at line 132 of file juce_MPENote.h.

Referenced by juce::MPEInstrument::MPEInstrument(), juce::MPEInstrument::releaseAllNotes(), and juce::MPEInstrument::timbre().

◆ pressure

MPEValue juce::MPENote::pressure { MPEValue::centreValue() }

Current pressure with which the note is held down.

This dimension can be modulated while the note sounds.

Definition at line 137 of file juce_MPENote.h.

Referenced by juce::MPEInstrument::MPEInstrument(), and juce::MPEInstrument::releaseAllNotes().

◆ initialTimbre

MPEValue juce::MPENote::initialTimbre { MPEValue::centreValue() }

Initial value of timbre when the note was triggered.

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

Definition at line 142 of file juce_MPENote.h.

◆ timbre

MPEValue juce::MPENote::timbre { MPEValue::centreValue() }

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

This dimension can be modulated while the note sounds.

Definition at line 148 of file juce_MPENote.h.

Referenced by juce::MPEInstrument::MPEInstrument(), and juce::MPEInstrument::releaseAllNotes().

◆ noteOffVelocity

MPEValue juce::MPENote::noteOffVelocity { MPEValue::minValue() }

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.

Definition at line 156 of file juce_MPENote.h.

Referenced by juce::MPEInstrument::releaseAllNotes().

◆ totalPitchbendInSemitones

double juce::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

Definition at line 168 of file juce_MPENote.h.

Referenced by getFrequencyInHertz(), operator!=(), and juce::MPEInstrument::timbre().

◆ keyState

KeyState juce::MPENote::keyState { MPENote::off }

Current key state.

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

Definition at line 173 of file juce_MPENote.h.

Referenced by juce::MPESynthesiser::findVoiceToSteal(), juce::MPEInstrument::getMostRecentNoteOtherThan(), juce::MPESynthesiserVoice::isPlayingButReleased(), juce::MPEInstrument::releaseAllNotes(), and juce::MPEInstrument::sostenutoPedal().


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