Note On Off Pairing Tool
Pair explicitly typed sorted note-on/off events FIFO per channel and pitch; retain unmatched events and do not infer MIDI velocity-zero semantics.
Description
Pair explicitly typed sorted note-on/off events FIFO per channel and pitch; retain unmatched events and do not infer MIDI velocity-zero semantics.
Repeated note-ons of the same channel and pitch need a pairing policy. This tool uses the oldest unmatched on first.
When to use this tool
Pair explicitly typed sorted note-on/off events FIFO per channel and pitch; retain unmatched events and do not infer MIDI velocity-zero semantics.
- Prepare the supplied eventsJson fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter eventsJson. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.pairs, result.unmatchedOn, result.unmatchedOff. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Require nondecreasing event time, type exactly on/off, valid channel and pitch. Queue on indexes by channel/pitch; each off consumes the earliest queued on or becomes unmatchedOff. Return index pairs with duration plus all remaining unmatchedOn indexes.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| eventsJson | JSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file. | Text |
For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.
[
{
"field": "eventsJson",
"decoded": [
{
"time": 0,
"pitch": 60,
"channel": 0,
"type": "on"
},
{
"time": 2,
"pitch": 60,
"channel": 0,
"type": "off"
}
]
}
] | Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.pairs | The pairs list in the ordering and representation described above. |
| result.unmatchedOn | The unmatched on list in the ordering and representation described above. |
| result.unmatchedOff | The unmatched off list in the ordering and representation described above. |
{
"input": {
"eventsJson": "[{\"time\":0,\"pitch\":60,\"channel\":0,\"type\":\"on\"},{\"time\":2,\"pitch\":60,\"channel\":0,\"type\":\"off\"}]"
},
"output": {
"result": {
"pairs": [
{
"onIndex": 0,
"offIndex": 1,
"duration": 2
}
],
"unmatchedOn": [],
"unmatchedOff": []
}
}
} Limitations and assumptions
- Equal-time events retain source order. No velocity-zero convention, sustain pedal, running status or actual MIDI bytes are interpreted.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- Lists are limited to 128 entries. JSON text must meet bounded size and depth checks, and numeric outputs beyond the safe finite magnitude are rejected. Exact large integers use decimal strings.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Retain the tick unit, channel numbering and event-pairing policy with the result. Use a MIDI-file parser or audio analysis when the task requires actual messages, playback behavior or recorded sound.
References
Similar or alternative tools
- chord inversion from bass note
Inversion identifies which spelled chord member is the supplied actual bass.
- delay time synced to note value
Tempo-synced delay time in milliseconds for a note expressed in quarter-note multiples.