Complete JSON Data Structure Documentation
This tool output strictly follows the specifications of @tonejs/midi. To assist developers in accurately parsing data within Unity, Godot, or Web front-ends, we provide this comprehensive parameter dictionary.
Root 1. Header (Metadata)
| Parameter | Type | Description |
|---|---|---|
| ppq | Number | Pulses Per Quarter. The time resolution. Formula: 1 Beat = ppq ticks |
| tempos | Array | List of tempo changes. Includes bpm, time (seconds), and ticks. |
| timeSignatures | Array | List of time signature changes (e.g., [4, 4]). |
Array 2. Tracks
Each object in the tracks array represents an instrument track.
| Parameter | Description |
|---|---|
| channel | MIDI Channel (0-15). Channel 9 (index 9) is reserved for Percussion/Drums. |
| instrument | Contains number (GM patch) and family (e.g., "piano"). |
| notes | [Core Data] An array of all note events in this track. |
Object 3. Note Object (The most important part)
| Parameter | Unity Mapping Guide |
|---|---|
| time | Start Time (Seconds). Calculated absolute time based on BPM curves. Unity: Compare with AudioSettings.dspTime. |
| ticks | Start Position (Ticks). Absolute grid position, unaffected by BPM changes. Unity: Use for grid-based sequencers. |
| midi | MIDI Note Number (0-127). 60 = Middle C. |
| velocity | Velocity (0.0 - 1.0). Represents volume or intensity. |
| duration | Duration in seconds (NoteOff - NoteOn). |
Unity Integration Code (C#)
// C# Example for Unity
using System;
[Serializable] public class NoteData { public float time; public int midi; public float duration; public float velocity; }
[Serializable] public class MidiTrack { public NoteData[] notes; }
[Serializable] public class MidiData { public MidiTrack[] tracks; }
public void LoadMidiJson(string jsonString) {
MidiData data = JsonUtility.FromJson<MidiData>(jsonString);
if(data.tracks.Length > 1) {
foreach (var note in data.tracks[1].notes) { Debug.Log($"Spawn: {note.midi} at {note.time}s"); }
}
}Frequently Asked Questions (FAQ)
Q: Why is the tempos array empty?
Many DAWs do not export "Set Tempo" events for simple clips. In this case, the tool defaults to 120 BPM.
Q: Should I use `time` or `ticks`?
Use time (seconds) for audio sync games (Guitar Hero). Use ticks for grid-based logic games.
Q: How do I access Drums?
MIDI Channel 10 (index 9) is percussion. Check where instrument.percussion is true.
Q: Is my data uploaded to a server?
No. This tool runs entirely in your browser using JavaScript. Your files never leave your device.
Q: The JSON file is huge!
Text-based JSON is verbose. For production, parse this JSON in Editor and save as binary ScriptableObject.
Q: How to parse in Unity?
Use JsonUtility or Newtonsoft.Json. You must define wrapper classes that match the JSON structure.