@maruaudio/dsp/math/grid-coordinates maps a controller key index to a row and column on either a square 8 × 8 grid (64 keys) or the 61-key hex layout of the Exquis, whose rows alternate six and five keys (HEX_ROWS = 11). For hex, axialColumn converts an offset column to an axial one by subtracting floor(row / 2). All arithmetic is integer Math.floor, % and comparisons.
Functions
| Name | Inputs | Output | Domain as coded |
|---|---|---|---|
positionKeyRow | key, hex | row index, or −1 | Square: floor(key / 8) for 0..63. Hex: floor(key / 11) × 2, plus 1 when key % 11 >= 6, for 0..60. A negative, out-of-range or fractional key returns −1 |
positionKeyColumn | key, hex | column index, or −1 | −1 whenever the row is −1. Square: key % 8. Hex: key % 11, minus 6 on the five-key row |
axialColumn | column, row, hex | column | Hex: column - floor(row / 2). Square: column unchanged. No validation |
HEX_ROWS | constant | 11 |
Lifecycle
None. Stateless functions with no preparation or instance state.
When to use it
Compiled controller Processors that turn a pad press into a position on an isomorphic note layout. The Isomorphic Keyboard and Exquis Controller modules share it (shared behavior).
Limits
- Two fixed layouts only; the key count (61 or 64) is coded, not configurable.
- Packaged faces do not import DSP. The face keeps its own coordinate projection, which is checked against this DSP node.