Vital
|
Represents a single playing note/voice, including voice-state and event handling. More...
#include <voice_handler.h>
Public Types | |
enum | KeyState { kTriggering , kHeld , kSustained , kReleased , kDead , kNumStates } |
Describes the lifecycle stage of a voice: kTriggering -> kHeld -> kReleased -> kDead, with special states for sustain. More... | |
Public Member Functions | |
Voice (AggregateVoice *parent) | |
Constructs a Voice owned by a given AggregateVoice. | |
Voice ()=delete | |
Disabled default constructor: Voice must belong to an AggregateVoice. | |
virtual | ~Voice () |
Virtual destructor. | |
force_inline AggregateVoice * | parent () |
Returns the pointer to the parent AggregateVoice. | |
force_inline const VoiceState & | state () |
Returns a const reference to the VoiceState struct that holds all relevant data. | |
force_inline const KeyState | last_key_state () |
Returns the previous key state (before the most recent update). | |
force_inline const KeyState | key_state () |
Returns the current key state. | |
force_inline int | event_sample () |
Returns the sample index at which the latest event (on/off) was triggered. | |
force_inline int | voice_index () |
Returns the index of this voice within an AggregateVoice (also the SIMD lane grouping). | |
force_inline poly_mask | voice_mask () |
Returns the SIMD mask representing this voice's active lanes. | |
force_inline mono_float | aftertouch () |
Returns the current aftertouch value for this voice. | |
force_inline mono_float | aftertouch_sample () |
Returns the sample index at which the latest aftertouch event occurred. | |
force_inline mono_float | slide () |
Returns the current slide (MPE expression) value for this voice. | |
force_inline mono_float | slide_sample () |
Returns the sample index at which the latest slide event occurred. | |
force_inline void | activate (int midi_note, mono_float tuned_note, mono_float velocity, poly_float last_note, int note_pressed, int note_count, int sample, int channel) |
Activates (starts) the voice with the given note parameters. | |
force_inline void | setKeyState (KeyState key_state) |
Sets the key state of this voice (e.g., from Triggering to Held). | |
force_inline void | sustain () |
Switches this voice to the kSustained state, typically when a sustain pedal is active. | |
force_inline bool | sustained () |
Returns true if the voice is in the kSustained state. | |
force_inline bool | held () |
Returns true if the voice is in the kHeld state. | |
force_inline bool | released () |
Returns true if the voice is in the kReleased state. | |
force_inline bool | sostenuto () |
Returns true if the voice has sostenuto pressed. | |
force_inline void | setSostenuto (bool sostenuto) |
Sets the sostenuto flag on or off. | |
force_inline void | setLocalPitchBend (mono_float bend) |
Sets the local pitch bend (used for legato transitions or channel pitch bend). | |
force_inline void | setLiftVelocity (mono_float lift) |
Adjusts the lift velocity (release velocity) of the note-off. | |
force_inline void | deactivate (int sample=0) |
Deactivates (turns off) this voice with a note-off event, transitioning to kReleased. | |
force_inline void | kill (int sample=0) |
Immediately kills this voice (disregarding release). | |
force_inline void | markDead () |
Marks this voice as kDead, meaning it's completely inactive. | |
force_inline bool | hasNewEvent () |
Checks if there is a new (non-processed) on/off event for this voice. | |
force_inline void | setAftertouch (mono_float aftertouch, int sample=0) |
Sets the aftertouch (pressure) value for the voice. | |
force_inline void | setSlide (mono_float slide, int sample=0) |
Sets the MPE "slide" value for the voice (often CC#74). | |
force_inline bool | hasNewAftertouch () |
Returns true if there's a new aftertouch event not yet processed. | |
force_inline bool | hasNewSlide () |
Returns true if there's a new slide event not yet processed. | |
force_inline void | completeVoiceEvent () |
Completes (consumes) the voice event, marking it as processed. If the voice was kTriggering, transitions it to kHeld. | |
force_inline void | shiftVoiceEvent (int num_samples) |
Shifts the event sample index by num_samples (e.g., for partial block processing). | |
force_inline void | shiftAftertouchEvent (int num_samples) |
Shifts the aftertouch event sample index by num_samples . | |
force_inline void | shiftSlideEvent (int num_samples) |
Shifts the slide event sample index by num_samples . | |
force_inline void | clearAftertouchEvent () |
Clears the unprocessed aftertouch event, if any. | |
force_inline void | clearSlideEvent () |
Clears the unprocessed slide event, if any. | |
force_inline void | clearEvents () |
Clears both note-on/off events and aftertouch events, marking them processed. | |
force_inline void | setSharedVoices (std::vector< Voice * > shared_voices) |
Stores references to other Voices in the same parallel group for advanced sharing logic. | |
force_inline void | setVoiceInfo (int voice_index, poly_mask voice_mask) |
Sets the voice index within its parallel group and the corresponding SIMD mask. | |
Static Public Attributes | |
static constexpr mono_float | kDefaultLiftVelocity = 0.5f |
Default lift velocity to use if none is provided. | |
Represents a single playing note/voice, including voice-state and event handling.
Voices can be grouped into AggregateVoice sets, with each group sharing a Processor. This class stores the note data and manages transitions between states (on/off/sustain).
Describes the lifecycle stage of a voice: kTriggering -> kHeld -> kReleased -> kDead, with special states for sustain.
vital::Voice::Voice | ( | AggregateVoice * | parent | ) |
Constructs a Voice owned by a given AggregateVoice.
parent | Pointer to the owning AggregateVoice. |
|
delete |
Disabled default constructor: Voice must belong to an AggregateVoice.
|
inlinevirtual |
Virtual destructor.
|
inline |
Activates (starts) the voice with the given note parameters.
midi_note | MIDI note number. |
tuned_note | Possibly adjusted note frequency (from Tuning). |
velocity | Velocity of note-on. |
last_note | The previous note value (for legato). |
note_pressed | The count of pressed notes for note-on logic. |
note_count | A global note increment for event ordering. |
sample | The sample index at which note-on occurs. |
channel | The MIDI channel for this note. |
|
inline |
Returns the current aftertouch value for this voice.
|
inline |
Returns the sample index at which the latest aftertouch event occurred.
|
inline |
Clears the unprocessed aftertouch event, if any.
|
inline |
Clears both note-on/off events and aftertouch events, marking them processed.
|
inline |
Clears the unprocessed slide event, if any.
|
inline |
Completes (consumes) the voice event, marking it as processed. If the voice was kTriggering, transitions it to kHeld.
|
inline |
Deactivates (turns off) this voice with a note-off event, transitioning to kReleased.
sample | The sample index at which note-off occurs. |
|
inline |
Returns the sample index at which the latest event (on/off) was triggered.
|
inline |
Returns true if there's a new aftertouch event not yet processed.
|
inline |
Checks if there is a new (non-processed) on/off event for this voice.
|
inline |
Returns true if there's a new slide event not yet processed.
|
inline |
Returns true if the voice is in the kHeld state.
|
inline |
Returns the current key state.
|
inline |
Immediately kills this voice (disregarding release).
sample | The sample index at which kill occurs. |
|
inline |
Returns the previous key state (before the most recent update).
|
inline |
Marks this voice as kDead, meaning it's completely inactive.
|
inline |
Returns the pointer to the parent AggregateVoice.
|
inline |
Returns true if the voice is in the kReleased state.
|
inline |
Sets the aftertouch (pressure) value for the voice.
aftertouch | The new aftertouch value. |
sample | The sample index at which the event is received. |
|
inline |
Sets the key state of this voice (e.g., from Triggering to Held).
key_state | The new KeyState. |
|
inline |
Adjusts the lift velocity (release velocity) of the note-off.
|
inline |
Sets the local pitch bend (used for legato transitions or channel pitch bend).
|
inline |
Stores references to other Voices in the same parallel group for advanced sharing logic.
shared_voices | A list of pointers to parallel voices in the same AggregateVoice. |
|
inline |
Sets the MPE "slide" value for the voice (often CC#74).
slide | The new slide value. |
sample | The sample index at which the event is received. |
|
inline |
Sets the sostenuto flag on or off.
|
inline |
Sets the voice index within its parallel group and the corresponding SIMD mask.
voice_index | An integer index (0..kParallelVoices-1). |
voice_mask | A poly_mask enabling only the lanes relevant to this voice. |
|
inline |
Shifts the aftertouch event sample index by num_samples
.
|
inline |
Shifts the slide event sample index by num_samples
.
|
inline |
Shifts the event sample index by num_samples
(e.g., for partial block processing).
num_samples | How many samples to shift. |
|
inline |
Returns the current slide (MPE expression) value for this voice.
|
inline |
Returns the sample index at which the latest slide event occurred.
|
inline |
Returns true if the voice has sostenuto pressed.
|
inline |
Returns a const reference to the VoiceState struct that holds all relevant data.
|
inline |
Switches this voice to the kSustained
state, typically when a sustain pedal is active.
|
inline |
Returns true if the voice is in the kSustained state.
|
inline |
Returns the index of this voice within an AggregateVoice (also the SIMD lane grouping).
|
inline |
Returns the SIMD mask representing this voice's active lanes.
|
staticconstexpr |
Default lift velocity to use if none is provided.