@maruaudio/dsp/voices/keymap is three pure predicates that a sampler uses to select zones: whether a zone or layer admits a note and velocity byte by its key and velocity ranges, whether its keyswitch span admits the selected articulation, and whether a note falls inside an instrument's keyswitch range. They return the integers 0 or 1 rather than booleans, so they lower and compose without boolean types. The source header says they were extracted unchanged from @maru/voices-sampler-zone.
Parameters
| Function | Returns 1 when |
|---|---|
keymapWindowAdmits(note, lowKey, highKey, velocityByte, lowVelocity, highVelocity) | note is in [lowKey, highKey] and velocityByte is in [lowVelocity, highVelocity], bounds inclusive |
keyswitchWindowAdmits(selected, low, high) | selected is in [low, high]; the default full span 0..127 admits every articulation |
keyswitchRangeContains(low, high, note) | high >= low and note is in [low, high]; high < low means no range is declared and always returns 0 |
Lifecycle
None. The functions hold no state; the composing instrument reads the bounds from its own zone table and decides what a zone is.
When to use it
Zone and layer selection in a multisampled instrument: key splits, velocity layers and keyswitched articulations. Pair it with @maru/voices-round-robin when a zone has several takes.
Limits
- Integer comparisons only; the caller supplies MIDI-range integers and the functions do not clamp or round them.
- No audio output, no event handling.