# Data to MIDI

> Play a JSON list of notes in beats as MIDI on each trigger, scheduled on the transport.

Source: https://docs.tune.toys/nodes/midi.from-data/

Data to MIDI plays a list of notes written as JSON through any MIDI input, such as the [Polyphonic instrument](https://docs.tune.toys/nodes/std.poly/).

## What it does

`notes` takes a JSON list such as `[{ "note": 60, "velocity": 0.8, "start": 0, "duration": 0.5 }]`: MIDI note numbers, velocity 0–1 (0.8 when missing), and start and duration in beats. Up to 1 024 notes per list. With `trigger` cabled, each trigger plays the whole list from the next grid point; without it, every new list plays as it arrives. Playing again cancels notes still scheduled from the previous list.

The notes become note-on and note-off messages on the node's `midi` output, stamped with audio frames from the transport's tempo, and enter the engine's MIDI input through the bridge. In the browser the scheduling runs on the main thread, so timing is as tight as its timers allow, not sample-exact. Hosts without the data domain (the Player, exports) play nothing from this node.

## When to use it

Use it to play generated melodies, from an [LLM chat](https://docs.tune.toys/nodes/ai.chat/) answer, a [Dataset](https://docs.tune.toys/nodes/data.set/) or a [Value](https://docs.tune.toys/nodes/data.value/), every bar of a [Cron](https://docs.tune.toys/nodes/time.cron/) in Beat mode.

## Ports

<!-- ports:start -->

| Port      | Direction | Signal         | Lanes            |
| --------- | --------- | -------------- | ---------------- |
| `notes`   | Input     | Data (json)    | 1                |
| `trigger` | Input     | Data (trigger) | 1                |
| `midi`    | Output    | MIDI           | 16 MIDI channels |

<!-- ports:end -->

## Parameters

<!-- parameters:start -->

| Parameter   | Label     | Range     | Default | Unit | Scale  | Notes                                                                                              |
| ----------- | --------- | --------- | ------- | ---- | ------ | -------------------------------------------------------------------------------------------------- |
| `channel`   | Channel   | 1 to 16   | 1       |      | linear | MIDI channel of the generated notes.                                                               |
| `transpose` | Transpose | -48 to 48 | 0       | st   | linear | Semitones added to every note.                                                                     |
| `quantize`  | Quantize  | 0 to 3    | 0       |      | linear | Snap note starts to this grid before scheduling. Choices: 0 Off, 1 Quarter, 2 Eighth, 3 Sixteenth. |

<!-- parameters:end -->

### Channel (`channel`)

The MIDI channel, 1 to 16, of the generated notes.

### Transpose (`transpose`)

Semitones added to every note, -48 to 48. Notes pushed outside 0–127 are skipped.

### Quantize (`quantize`)

Off starts the list at the current beat. Quarter, Eighth or Sixteenth waits for the next grid point and snaps each note's start to that grid.

## Tips

- An invalid list (a missing `start`, a negative duration) is reported in the inspector and nothing plays.
- Keep durations shorter than the gap to the next note for clean retriggers.

## See also

[Polyphonic instrument](https://docs.tune.toys/nodes/std.poly/), [LLM chat](https://docs.tune.toys/nodes/ai.chat/), [Cron](https://docs.tune.toys/nodes/time.cron/), [MIDI cables](https://docs.tune.toys/concepts/midi-cables/), [Data cables](https://docs.tune.toys/concepts/data-cables/).
