Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ArticulationDataManager

File: Rhapsodist/Core/Includes/ArticulationDataManager.js · Namespace: ArticulationDataManager

Overview

ArticulationDataManager builds the effective per-patch articulation list by merging Manifest.articulations with a patch’s own patch.articulations overrides (matched by id), and resolves keyswitch/Program Change values to articulation indices. It rebuilds automatically whenever knbPatch changes.

This script is also included in the ConfigurationHandler, which applies the merged data to modules.

Behaviour

A "Defaults" entry in Manifest.articulations (or a patch level articulations entry), if present, fills in properties an articulation doesn’t already define.

Each articulation gets a keyswitch note (its own ks, or patch.firstKs + index) and a program number (its own program, or its index). See The Manifest for the full schema.

Usage

ArticulationDataManager rebuilds itself automatically whenever knbPatch changes, there’s nothing to set up.

Call its getters from other scripts to look up the merged, resolved articulation data, the way ArticulationSwitcher does when translating a keyswitch note into an articulation:

local index = ArticulationDataManager.getArticulationIndexForKeyswitch(noteNumber);
local articulation = ArticulationDataManager.getArticulation(index);

Public API

FunctionDescriptionReturns
getArticulation(index: number)Returns the merged articulation object at index.object
getAllArticulations()Returns the full merged articulation array.Array
getNumArticulations()Returns the number of merged articulations.number
getArticulationIndexForKeyswitch(noteNumber: number)Returns the articulation index whose keyswitch matches noteNumber.number
getArticulationIndexForProgram(programNumber: number)Returns the articulation index whose program number matches programNumber.number

Internal Reference

FunctionDescriptionReturns
updateArticulationData(patch)Rebuilds the articulations array by merging Manifest.articulations with patch.articulations, applying a "Defaults" entry if present. Runs on every knbPatch change.—
updateTriggers(patch: JSON)Rebuilds the keyswitches and programs lookup arrays from the merged articulations, filling in keyswitch/program numbers that aren’t explicitly set.—
merge(base, source, allowOverride)Recursively merges source into base, following the same rules updateArticulationData uses for the "Defaults" entry and patch-level overrides.object
mergeArray(baseArray: Array, sourceArray: Array, allowOverride: number)Merges two arrays of objects by id, used by merge for array-valued properties.Array
isObject(variable)Returns whether variable is a plain object (not an array).number

Broadcasters

BroadcasterDescription
bcPatchChangedFires when knbPatch changes value. Looks up the matching Manifest.patches entry and rebuilds the articulation and trigger data for it via updateArticulationData()/updateTriggers().