Skip to content

Poly Legato

Poly Legato

Import

import "_IVLS/std-library/nodes/voice-logics/legato/poly-legato.ksp"

Node: Stl.PolyLegato

Uses: Init, NoteOn, NoteOff

Overview

Poly Legato

Polyphonic legato implementation that matches simultaneously pressed and released voices.

LIBRARY: std-library/nodes/voice-logics/legato

Uses a latency window to collect NoteOn and NoteOff events that arrive within a configurable time frame, then runs an assignment algorithm to pair each released voice with the most interval-optimal newly pressed voice. For equal-count pairs, voices are matched in order; for unequal counts, a minimax interval algorithm finds the combination that minimises the largest semitone jump across all pairings. Unpaired voices are treated as regular note-on or note-off events.

API

Nodes

Name Description
node Stl.PolyLegato Implements polyphonic legato by collecting simultaneous note events within a lat...

Defines

Name Description
define POLYLEG.TIME_ELAPSED(#thr#) Returns the time in milliseconds elapsed since the current poly legato window op...
define Stl.Legato += Stl.PolyLegato Adds Stl.PolyLegato to the Stl.Legato composition chain.

Functions

Name Description
polyleg.clear_inputs(thread) Clears the NoteOn and NoteOff voice buffers for the given thread after the legat...
polyleg.get_latency() -> lat Returns the effective latency in milliseconds, combining the release extension t...
polyleg.run(thread) Dispatches the poly legato matching algorithm for the given thread by forwarding...

Nodes

node Stl.PolyLegato

Callbacks: Init, NoteOn, NoteOff

Implements polyphonic legato by collecting simultaneous note events within a latency window and pairing voices optimally.


Defines

define POLYLEG.TIME_ELAPSED(#thr#)

Returns the time in milliseconds elapsed since the current poly legato window opened on the given thread.

Parameter Description
#thr# thread index (unused at expansion time; window_start is indexed by thread)

Post: (integer) return - elapsed time in milliseconds since polyleg.window_start[thread]


define Stl.Legato += Stl.PolyLegato

Adds Stl.PolyLegato to the Stl.Legato composition chain.


Functions

polyleg.clear_inputs(thread)

Clears the NoteOn and NoteOff voice buffers for the given thread after the legato window closes.

Parameter Type Description
thread integer the thread index whose input buffers are to be cleared

Side effects:

  • Clears polyleg.VoicesOn row for the given thread
    • Clears polyleg.VoicesOff row for the given thread

polyleg.get_latency() -> lat

Returns the effective latency in milliseconds, combining the release extension ticks and the configured polyleg latency value.

Returns: lat — total latency in milliseconds used for the poly legato window


polyleg.run(thread)

Dispatches the poly legato matching algorithm for the given thread by forwarding the thread index through the shared func.arg1 channel and calling the non-reentrant _run function.

Parameter Type Description
thread integer the thread index to run the matching algorithm for

Side effects:

  • Writes polyleg.func.arg1 with the thread value
    • Calls polyleg._run, which populates result.DestinationVoices and result.SourceVoices

Example

// TODO: Add usage example

See Also