Midi¶
Stl.Midi
Import¶
import "_IVLS/std-library/nodes/components/midi.ksp"Node: Stl.Midi¶
Uses: Init, CC, KNCB, KRCB
Overview¶
Stl.Midi
Provides MIDI state tracking for the IVLS standard library. Maintains per-channel key-down, velocity, CC, and pedal state, ordered note and velocity stacks, and utility functions for note-octave and frequency conversion. Fires retrigger hooks for legato support.
Constants¶
| Constant | Value | Description |
|---|---|---|
midi.NOTES |
128 |
integer |
midi.CHANNELS |
64 |
integer |
midi.VELOCITIES |
128 |
integer |
midi.CC_RANGE |
128 |
integer |
midi.MIDDLE_C |
60 |
integer |
midi.A440 |
69 |
integer |
API¶
Nodes¶
| Name | Description |
|---|---|
node Stl.Midi |
Root node that initializes and maintains all MIDI state for the standard library... |
Defines¶
| Name | Description |
|---|---|
define CONDITION.IS_OUTSIDE_EVENT |
Evaluates to true when the current event originated outside Kontakt (i.e., the e... |
define CONDITION.IS_PEDAL_DOWN |
Evaluates to true when the sustain pedal (CC 64) is at or above the on threshold... |
define CONDITION.IS_PEDAL_UP |
Evaluates to true when the sustain pedal (CC 64) is below the on threshold (valu... |
Const Blocks¶
| Name | Description |
|---|---|
const Channel |
MIDI channel selector constants. |
const messages |
MIDI message type identifiers for note-on and note-off events. |
const release_type |
Release type identifiers indicating how a key release was triggered: normal phys... |
Functions¶
| Name | Description |
|---|---|
math.freq_to_note(freq, ref) -> return |
Converts a frequency in Hz to the nearest MIDI note number using equal temperame... |
math.note_to_freq(midi_note, ref) -> return |
Converts a MIDI note number to its corresponding frequency in Hz using equal tem... |
midi.get_note_octave(note) -> oct |
Returns the octave number for a given MIDI note number (Kontakt numbering, where... |
Nodes¶
node Stl.Midi¶
Callbacks: Init, CC, KNCB, KRCB
Root node that initializes and maintains all MIDI state for the standard library, including key-down tables, velocity stacks, CC tracking, pedal state, note name arrays, and ordered press/release lists across all MIDI channels.
Defines¶
define CONDITION.IS_OUTSIDE_EVENT¶
Evaluates to true when the current event originated outside Kontakt (i.e., the event source is -1).
define CONDITION.IS_PEDAL_DOWN¶
Evaluates to true when the sustain pedal (CC 64) is at or above the on threshold (value >= 64).
define CONDITION.IS_PEDAL_UP¶
Evaluates to true when the sustain pedal (CC 64) is below the on threshold (value < 64).
Const Blocks¶
const Channel¶
MIDI channel selector constants. Omni (-1) listens on all channels; Ch_1 through Ch_16 map to zero-based channel indices 0 through 15.
const messages¶
MIDI message type identifiers for note-on and note-off events.
const release_type¶
Release type identifiers indicating how a key release was triggered: normal physical release, sustain pedal hold, or sostenuto pedal hold.
Functions¶
math.freq_to_note(freq, ref) -> return¶
Converts a frequency in Hz to the nearest MIDI note number using equal temperament.
| Parameter | Type | Description |
|---|---|---|
freq |
real | the frequency of the note in question |
ref |
real | reference tuning for middle A (use 440 if unsure) |
Returns: return — MIDI note number closest to the given frequency
math.note_to_freq(midi_note, ref) -> return¶
Converts a MIDI note number to its corresponding frequency in Hz using equal temperament.
| Parameter | Type | Description |
|---|---|---|
midi_note |
integer | the MIDI note number in terms of Kontakt numbering, where middle C is 60. |
ref |
real | reference tuning for middle A (use 440 if unsure) |
Returns: return — frequency of the specified MIDI note in Hz
midi.get_note_octave(note) -> oct¶
Returns the octave number for a given MIDI note number (Kontakt numbering, where C-2 = octave 0).
| Parameter | Type | Description |
|---|---|---|
note |
integer | MIDI note number (0 to 127) |
Returns: oct — octave index (0 to 10)
Example¶
// TODO: Add usage example