{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://clipiz.app/schema/track.v1.json",
  "title": "Clipiz track cue sheet",
  "description": "Everything an editing agent needs to choose a track by emotion and cut picture to it. Times are seconds from the start of the full master.",
  "type": "object",
  "required": [
    "id",
    "title",
    "tier",
    "duration",
    "bpm",
    "key",
    "moods",
    "valence",
    "arousal",
    "beat_grid",
    "sections",
    "energy_curve",
    "cut_points",
    "hit_points",
    "loops",
    "dialogue",
    "endings",
    "loudness",
    "versions",
    "license",
    "key_root",
    "mode",
    "vocals",
    "stems",
    "intro_silence"
  ],
  "$defs": {
    "time": {
      "type": "number",
      "minimum": 0
    },
    "span": {
      "type": "object",
      "required": [
        "start",
        "end"
      ],
      "properties": {
        "start": {
          "$ref": "#/$defs/time"
        },
        "end": {
          "$ref": "#/$defs/time"
        }
      }
    }
  },
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9-]+$"
    },
    "slug": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "artist": {
      "type": "string"
    },
    "tier": {
      "enum": [
        "free",
        "pro"
      ]
    },
    "description": {
      "type": "string"
    },
    "is_demo": {
      "type": "boolean",
      "description": "True for synthesized demonstration tracks."
    },
    "duration": {
      "$ref": "#/$defs/time",
      "description": "Length of the full master including the ringing tail."
    },
    "musical_end": {
      "$ref": "#/$defs/time",
      "description": "Time of the final downbeat."
    },
    "bpm": {
      "type": "number",
      "minimum": 20,
      "maximum": 300
    },
    "time_signature": {
      "type": "string",
      "examples": [
        "4/4"
      ]
    },
    "key": {
      "type": "string",
      "examples": [
        "A minor"
      ]
    },
    "camelot": {
      "type": [
        "string",
        "null"
      ],
      "examples": [
        "8A"
      ]
    },
    "genres": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "moods": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "label",
          "weight"
        ],
        "properties": {
          "label": {
            "type": "string"
          },
          "weight": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          }
        }
      }
    },
    "valence": {
      "type": "number",
      "minimum": -1,
      "maximum": 1,
      "description": "Negative (-1) to positive (1) emotion."
    },
    "arousal": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Calm (0) to intense (1)."
    },
    "intensity": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Peak of the energy curve."
    },
    "instruments": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "vocals": {
      "type": "object",
      "required": [
        "has_vocals",
        "type"
      ],
      "properties": {
        "has_vocals": {
          "type": "boolean"
        },
        "type": {
          "enum": [
            "instrumental",
            "vocal"
          ]
        },
        "regions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/span"
          },
          "description": "Where a voice sings."
        }
      }
    },
    "use_cases": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "avoid_for": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "loudness": {
      "type": "object",
      "properties": {
        "integrated_lufs": {
          "type": "number"
        },
        "true_peak_dbfs": {
          "type": "number"
        }
      }
    },
    "beat_grid": {
      "type": "object",
      "required": [
        "bpm",
        "first_downbeat",
        "beat_interval",
        "bar_interval",
        "downbeats"
      ],
      "properties": {
        "bpm": {
          "type": "number"
        },
        "first_downbeat": {
          "$ref": "#/$defs/time"
        },
        "beat_interval": {
          "type": "number"
        },
        "bar_interval": {
          "type": "number"
        },
        "downbeats": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/time"
          }
        }
      }
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "label",
          "start",
          "end"
        ],
        "properties": {
          "label": {
            "type": "string",
            "examples": [
              "intro",
              "verse",
              "build",
              "chorus",
              "drop",
              "breakdown",
              "swell",
              "peak",
              "finale",
              "outro"
            ]
          },
          "start": {
            "$ref": "#/$defs/time"
          },
          "end": {
            "$ref": "#/$defs/time"
          },
          "bars": {
            "type": "integer"
          },
          "energy_target": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          }
        }
      }
    },
    "energy_curve": {
      "type": "object",
      "properties": {
        "step": {
          "type": "number"
        },
        "points": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "t": {
                "$ref": "#/$defs/time"
              },
              "e": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              }
            }
          }
        },
        "builds": {
          "type": "array",
          "description": "Spans that ramp into a louder section.",
          "items": {
            "type": "object",
            "required": [
              "start",
              "end"
            ],
            "properties": {
              "start": {
                "$ref": "#/$defs/time"
              },
              "end": {
                "$ref": "#/$defs/time"
              },
              "section": {
                "type": "string"
              },
              "peak_at": {
                "$ref": "#/$defs/time"
              }
            }
          }
        },
        "drops": {
          "type": "array",
          "description": "Where energy jumps in. energy_jump is measured on the master: mean energy 2 s after minus 2 s before.",
          "items": {
            "type": "object",
            "required": [
              "t",
              "energy_jump"
            ],
            "properties": {
              "t": {
                "$ref": "#/$defs/time"
              },
              "section": {
                "type": "string"
              },
              "energy_jump": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "cut_points": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "t",
          "kind",
          "strength"
        ],
        "properties": {
          "t": {
            "$ref": "#/$defs/time"
          },
          "kind": {
            "enum": [
              "section",
              "phrase",
              "bar",
              "ending"
            ]
          },
          "strength": {
            "type": "number"
          },
          "label": {
            "type": "string"
          }
        }
      }
    },
    "loops": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "start",
          "end",
          "bars"
        ],
        "properties": {
          "start": {
            "$ref": "#/$defs/time"
          },
          "end": {
            "$ref": "#/$defs/time"
          },
          "bars": {
            "type": "integer"
          },
          "section": {
            "type": "string"
          },
          "crossfade_ms": {
            "type": "number"
          }
        }
      }
    },
    "hit_points": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "t",
          "type"
        ],
        "properties": {
          "t": {
            "$ref": "#/$defs/time"
          },
          "type": {
            "enum": [
              "impact",
              "riser_peak",
              "button_end",
              "drop",
              "stop"
            ]
          },
          "strength": {
            "type": "number"
          }
        }
      }
    },
    "dialogue": {
      "type": "object",
      "properties": {
        "safe_regions": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/span"
              },
              {
                "properties": {
                  "section": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "recommended_duck_db": {
          "type": "number"
        }
      }
    },
    "endings": {
      "type": "object",
      "properties": {
        "type": {
          "enum": [
            "button",
            "fade",
            "ring_out"
          ]
        },
        "button_at": {
          "$ref": "#/$defs/time"
        },
        "tail_until": {
          "$ref": "#/$defs/time"
        },
        "fade_out_ok_from": {
          "$ref": "#/$defs/time"
        }
      }
    },
    "peak_moment": {
      "type": "object",
      "properties": {
        "t": {
          "$ref": "#/$defs/time"
        },
        "section": {
          "type": "string"
        }
      }
    },
    "versions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "type",
          "file"
        ],
        "properties": {
          "type": {
            "enum": [
              "full",
              "sting",
              "preview",
              "loop",
              "cutdown"
            ]
          },
          "file": {
            "type": "string"
          },
          "duration": {
            "type": [
              "number",
              "null"
            ]
          },
          "source_start": {
            "type": "number"
          }
        }
      }
    },
    "license": {
      "type": "object",
      "required": [
        "id",
        "name",
        "url",
        "class"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "commercial_use": {
          "type": "boolean"
        },
        "attribution_required": {
          "type": "boolean"
        },
        "class": {
          "enum": [
            "open",
            "commercial-plus"
          ],
          "description": "open: CC0, free tracks. commercial-plus: premium tracks, granted per download to an active subscriber."
        },
        "version": {
          "type": "string"
        },
        "requires_subscription": {
          "type": "boolean"
        }
      }
    },
    "waveform": {
      "type": "array",
      "items": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "description": "Normalized peaks for drawing (present in API responses)."
    },
    "key_root": {
      "enum": [
        "C",
        "C#",
        "D",
        "Eb",
        "E",
        "F",
        "F#",
        "G",
        "Ab",
        "A",
        "Bb",
        "B"
      ],
      "description": "Root of the key, spelled as the catalog spells it."
    },
    "mode": {
      "enum": [
        "major",
        "minor"
      ]
    },
    "stems": {
      "type": "object",
      "required": [
        "available",
        "items"
      ],
      "properties": {
        "available": {
          "type": "boolean"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "file"
            ],
            "properties": {
              "name": {
                "enum": [
                  "drums",
                  "bass",
                  "harmony",
                  "melody",
                  "fx"
                ]
              },
              "file": {
                "type": "string"
              },
              "description": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "intro_silence": {
      "$ref": "#/$defs/time",
      "description": "Seconds before the first sound rises above -60 dBFS."
    }
  }
}
