{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mantismusic.app/docs/schemas/1.7/cues.schema.json",
  "title": "Mantis song cues (site/cues/{slug}.json), format 1.7",
  "description": "How a listener hears one song's shape, as markers a visualiser can follow. Times in seconds; strengths 0-1 within the song; curves are \"v1:<frames a second>:<base64>\", one byte per frame, byte / 255 = 0-1.",
  "type": "object",
  "required": ["cues", "analysis", "duration", "tempo", "beats", "bars", "sections", "moments", "parts", "feel"],
  "properties": {
    "cues": { "const": 1 },
    "analysis": { "enum": ["full", "basic"] },
    "duration": { "type": "number", "minimum": 0 },
    "tempo": {
      "type": "object",
      "required": ["bpm", "meter"],
      "properties": {
        "bpm": { "type": "number", "minimum": 0 },
        "meter": { "type": "integer", "minimum": 1 }
      }
    },
    "beats": { "$ref": "#/$defs/times" },
    "bars": { "$ref": "#/$defs/times" },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["start", "end", "kind", "number", "tune", "level"],
        "properties": {
          "start": { "type": "number", "minimum": 0 },
          "end": { "type": "number", "minimum": 0 },
          "kind": { "enum": ["intro", "verse", "chorus", "bridge", "instrumental", "solo", "outro"] },
          "number": { "type": "integer", "minimum": 1 },
          "tune": { "type": "string", "minLength": 1 },
          "level": { "enum": ["quiet", "mid", "loud"] },
          "lines": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "type": "integer", "minimum": 0 } },
          "hook": { "type": "boolean" },
          "last": { "type": "boolean" }
        }
      }
    },
    "moments": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["at", "kind"],
        "properties": {
          "at": { "type": "number", "minimum": 0 },
          "kind": { "enum": ["build", "drop", "lift", "breakdown", "stop", "peak", "solo", "enter", "exit"] },
          "end": { "type": "number", "minimum": 0 },
          "part": { "enum": ["drums", "bass", "other", "vocals"] }
        }
      }
    },
    "parts": {
      "type": "object",
      "required": ["drums", "bass", "other", "vocals"],
      "properties": {
        "drums": {
          "type": "object",
          "required": ["kick", "snare", "hat", "crash", "fills", "level"],
          "properties": {
            "kick": { "$ref": "#/$defs/hits" },
            "snare": { "$ref": "#/$defs/hits" },
            "hat": { "$ref": "#/$defs/hits" },
            "crash": { "$ref": "#/$defs/hits" },
            "fills": {
              "type": "array",
              "items": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "type": "number", "minimum": 0 } }
            },
            "level": { "$ref": "#/$defs/curve" }
          }
        },
        "bass": {
          "type": "object",
          "required": ["notes", "level"],
          "properties": {
            "notes": {
              "type": "array",
              "items": {
                "type": "array",
                "minItems": 3,
                "maxItems": 3,
                "items": { "type": "number", "minimum": 0 }
              }
            },
            "level": { "$ref": "#/$defs/curve" }
          }
        },
        "other": { "$ref": "#/$defs/level" },
        "vocals": { "$ref": "#/$defs/level" }
      }
    },
    "feel": { "$ref": "#/$defs/curve" }
  },
  "$defs": {
    "times": { "type": "array", "items": { "type": "number", "minimum": 0 } },
    "hits": {
      "type": "array",
      "items": {
        "type": "array",
        "minItems": 2,
        "maxItems": 2,
        "items": { "type": "number", "minimum": 0 }
      }
    },
    "curve": { "type": "string", "pattern": "^v1:[0-9]+:[A-Za-z0-9+/=]*$" },
    "level": {
      "type": "object",
      "required": ["level"],
      "properties": { "level": { "$ref": "#/$defs/curve" } }
    }
  }
}
