{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Miafy local arrangement",
  "type": "object",
  "properties": {
    "format": {
      "const": "mia-arrangement-1"
    },
    "title": {
      "type": "string",
      "x-trim-before-validation": true,
      "minLength": 1,
      "maxLength": 100
    },
    "bpm": {
      "type": "integer",
      "minimum": 40,
      "maximum": 220
    },
    "origin": {
      "type": "string",
      "enum": [
        "ai-declared",
        "procedural-test",
        "unspecified"
      ]
    },
    "space": {
      "type": "number",
      "minimum": 0,
      "maximum": 0.4
    },
    "tracks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "x-trim-before-validation": true,
            "minLength": 1,
            "maxLength": 40
          },
          "instrument": {
            "type": "string",
            "enum": [
              "keys",
              "pluck",
              "pad",
              "bass",
              "bell",
              "flute",
              "drums",
              "sine",
              "triangle"
            ]
          },
          "gain": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "pan": {
            "type": "number",
            "minimum": -1,
            "maximum": 1
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "pitch": {
                  "type": "integer",
                  "minimum": 24,
                  "maximum": 96
                },
                "start": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 660
                },
                "duration": {
                  "type": "number",
                  "minimum": 0.05,
                  "maximum": 16
                },
                "velocity": {
                  "type": "number",
                  "minimum": 0.01,
                  "maximum": 1
                }
              },
              "required": [
                "pitch",
                "start",
                "duration",
                "velocity"
              ],
              "additionalProperties": false
            },
            "minItems": 1,
            "maxItems": 4096
          }
        },
        "required": [
          "name",
          "instrument",
          "gain",
          "pan",
          "notes"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 8
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "x-trim-before-validation": true,
            "minLength": 1,
            "maxLength": 40
          },
          "start": {
            "type": "number",
            "minimum": 0,
            "maximum": 660
          },
          "end": {
            "type": "number",
            "minimum": 0.05,
            "maximum": 660
          }
        },
        "required": [
          "name",
          "start",
          "end"
        ],
        "additionalProperties": false
      },
      "maxItems": 16
    }
  },
  "required": [
    "format",
    "title",
    "bpm",
    "origin",
    "space",
    "tracks",
    "sections"
  ],
  "additionalProperties": false,
  "description": "Also run the provided validator: total 4096 notes, <=180s, <=16 overlapping notated notes, ordered nonoverlapping sections within the score, one drums track with pitches 36/38/42/46/49. This format is local-only, not accepted by the protected catalogue."
}
