{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "tab-header.schema.json",
  "title": "Tab header",
  "description": "YAML front matter at the top of a .tab file. Required fields produce a warning when missing. An optional field that is omitted means 'unknown'. capo, pitch and tuning may hold a default value (0, 0, standard) only while status.state is 'review' or 'incomplete' and a todo item says to check them.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "title",
    "artist",
    "capo",
    "pitch",
    "tuning",
    "status",
    "source"
  ],
  "properties": {
    "title": {
      "type": "string",
      "title": "Title",
      "description": "Song title. Must match the part of the filename after ' - ' (or the whole filename if it has no artist).",
      "x-fix": "add \"title: <song title>\" matching the filename"
    },
    "artist": {
      "type": "string",
      "title": "Artist",
      "description": "Performer the song is credited to. Must match the part of the filename before ' - '. 'traditional' marks a folk song with no known author; its filename has no artist part.",
      "x-fix": "add \"artist: <name>\" and rename the file to \"<artist> - <title>.tab\", or \"artist: traditional\" for a folk song",
      "examples": [
        "Guns N' Roses",
        "traditional"
      ]
    },
    "composer": {
      "type": "string",
      "title": "Composer",
      "description": "Who wrote the music, if different from the artist or worth stating.",
      "x-fix": "write the composer's name as text"
    },
    "lyricist": {
      "type": "string",
      "title": "Lyricist",
      "description": "Who wrote the lyrics, if different from the artist or worth stating.",
      "x-fix": "write the lyricist's name as text"
    },
    "capo": {
      "type": "integer",
      "minimum": 0,
      "title": "Capo",
      "description": "Capo fret the tab is written for. 0 = no capo. The default 0 is allowed only with status 'review' or 'incomplete' and a todo item to check it.",
      "x-fix": "add \"capo: N\" with the fret number, or \"capo: 0\" if played without capo"
    },
    "pitch": {
      "type": "integer",
      "title": "Pitch",
      "description": "Semitone offset of the whole guitar relative to the tuning, as if the capo were at this fret. -1 = every string one semitone down (e.g. Eb standard). 0 = no offset. The default 0 is allowed only with status 'review' or 'incomplete' and a todo item to check it.",
      "x-fix": "add \"pitch: 0\" if the song sounds as written, or \"pitch: -1\" etc. if all strings must be tuned down/up to match the recording"
    },
    "tuning": {
      "type": "string",
      "title": "Tuning",
      "description": "Tuning of the strings relative to each other, before applying pitch: 'standard', 'drop D', 'DADGAD', ... The default 'standard' is allowed only with status 'review' or 'incomplete' and a todo item to check it.",
      "examples": [
        "standard",
        "drop D",
        "DADGAD"
      ],
      "x-fix": "add \"tuning: standard\" or the tuning name (e.g. \"tuning: drop D\")"
    },
    "status": {
      "type": "object",
      "title": "Status",
      "description": "How far the tab is checked. 'review' and 'incomplete' must list the remaining work in todo; 'complete' must have an empty todo (the checker warns otherwise).",
      "additionalProperties": false,
      "required": [
        "state"
      ],
      "x-fix": "add \"status:\" with \"state: review\" and a \"todo:\" list (or \"state: complete\" once a human checked the whole tab)",
      "properties": {
        "state": {
          "title": "State",
          "oneOf": [
            {
              "const": "complete",
              "title": "Complete",
              "description": "Checked by a human; nothing known to be missing or wrong."
            },
            {
              "const": "incomplete",
              "title": "Incomplete",
              "description": "Parts are missing or uncertain; listed in todo."
            },
            {
              "const": "review",
              "title": "Review",
              "description": "Filled with default values or not yet checked by a human; what to check is listed in todo."
            }
          ],
          "x-fix": "set \"state: complete\", \"state: incomplete\" or \"state: review\"",
          "description": "Whether the tab is checked and whether anything is known to be missing or wrong."
        },
        "todo": {
          "type": "array",
          "title": "To do",
          "description": "What has to be done or checked for the tab to be complete.",
          "items": {
            "type": "string"
          },
          "x-fix": "list each missing or uncertain part as a line \"- ...\""
        }
      }
    },
    "source": {
      "type": "array",
      "title": "Sources",
      "description": "References the tab is based on - its source of truth. At least one entry; use a note (e.g. 'by ear from the studio recording') when there is no link.",
      "x-fix": "add \"source:\" with an entry \"- url: <link>\", or \"- note: by ear from <recording>\" if there is no link",
      "items": {
        "$ref": "#/$defs/source"
      },
      "minItems": 1
    },
    "media": {
      "type": "array",
      "title": "Media",
      "description": "Recordings to listen or play along to, and tutorials.",
      "x-fix": "write media as a list of entries starting with \"- url: ...\"",
      "items": {
        "$ref": "#/$defs/media"
      }
    },
    "notes": {
      "type": "array",
      "title": "Notes",
      "description": "Free-text remarks about the song or the tab. Remaining work belongs in status.todo instead.",
      "items": {
        "type": "string"
      },
      "x-fix": "write notes as a list of lines \"- ...\""
    }
  },
  "$defs": {
    "source": {
      "type": "object",
      "title": "Source",
      "additionalProperties": false,
      "anyOf": [
        {
          "required": [
            "url"
          ]
        },
        {
          "required": [
            "note"
          ]
        }
      ],
      "x-fix": "give the source a \"url:\", or a \"note:\" describing it if there is no link",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "title": "URL",
          "x-fix": "put the link in \"url:\"",
          "description": "Link to the source."
        },
        "author": {
          "type": "string",
          "title": "Author",
          "description": "Who made the source (e.g. a user name on a tab site).",
          "x-fix": "write the author's name as text"
        },
        "used": {
          "type": "array",
          "title": "Used",
          "description": "Which parts of this source the tab uses, if known.",
          "minItems": 1,
          "x-fix": "open the source and list what you took from it, e.g. \"used: [chords, lyrics]\" (values: chords, lyrics, tab, solo, structure, inspiration)",
          "items": {
            "oneOf": [
              {
                "const": "chords",
                "title": "Chords",
                "description": "Chord names and where they change."
              },
              {
                "const": "lyrics",
                "title": "Lyrics",
                "description": "The song text."
              },
              {
                "const": "tab",
                "title": "Tab",
                "description": "Tablature / fingerstyle notation."
              },
              {
                "const": "solo",
                "title": "Solo",
                "description": "A solo part."
              },
              {
                "const": "structure",
                "title": "Structure",
                "description": "Order of sections."
              },
              {
                "const": "inspiration",
                "title": "Inspiration",
                "description": "General idea or arrangement approach; nothing copied directly."
              }
            ],
            "x-fix": "use one of: chords, lyrics, tab, solo, structure, inspiration"
          }
        },
        "changes": {
          "title": "Changes",
          "description": "How much the used parts were changed compared to this source, if known.",
          "oneOf": [
            {
              "const": "none",
              "title": "None",
              "description": "Taken as-is, only reformatted."
            },
            {
              "const": "minor",
              "title": "Minor",
              "description": "Some chords, timing or lyrics corrected."
            },
            {
              "const": "major",
              "title": "Major",
              "description": "Substantially reworked; the source was a starting point."
            }
          ],
          "x-fix": "compare the tab with the source and set \"changes: none\", \"minor\" or \"major\""
        },
        "note": {
          "type": "string",
          "title": "Note",
          "x-fix": "write the note as text",
          "description": "Free text about the source; describes it when there is no link."
        }
      },
      "description": "One reference the tab is based on. Needs a url or a note; the other fields are optional."
    },
    "media": {
      "type": "object",
      "title": "Media",
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "title": "URL",
          "x-fix": "put the link in \"url:\"",
          "description": "Link to the recording."
        },
        "type": {
          "title": "Type",
          "oneOf": [
            {
              "const": "audio",
              "title": "Audio",
              "description": "Sound only (or a static picture)."
            },
            {
              "const": "video",
              "title": "Video",
              "description": "Has moving picture."
            }
          ],
          "x-fix": "open the link and set \"type: audio\" (sound only) or \"type: video\"",
          "description": "Whether it has moving picture."
        },
        "setting": {
          "title": "Setting",
          "oneOf": [
            {
              "const": "studio",
              "title": "Studio",
              "description": "Recorded in a studio / produced recording."
            },
            {
              "const": "live",
              "title": "Live",
              "description": "Recorded at a live performance."
            }
          ],
          "x-fix": "open the link and set \"setting: studio\" or \"setting: live\"",
          "description": "Where it was performed (live is the counterpart of studio)."
        },
        "performer": {
          "title": "Performer",
          "oneOf": [
            {
              "const": "artist",
              "title": "Artist",
              "description": "Performed by the song's artist."
            },
            {
              "const": "other",
              "title": "Other",
              "description": "Performed by someone else (a cover)."
            }
          ],
          "x-fix": "open the link and set \"performer: artist\" or \"performer: other\" (cover)",
          "description": "Who performs it."
        },
        "release": {
          "title": "Release",
          "oneOf": [
            {
              "const": "official",
              "title": "Official",
              "description": "Published by the performer or their label."
            },
            {
              "const": "unofficial",
              "title": "Unofficial",
              "description": "E.g. a fan recording on a phone."
            }
          ],
          "x-fix": "open the link and set \"release: official\" or \"release: unofficial\" (e.g. fan recording)",
          "description": "Who recorded and published it."
        },
        "content": {
          "title": "Content",
          "oneOf": [
            {
              "const": "performance",
              "title": "Performance",
              "description": "The song being performed."
            },
            {
              "const": "tutorial",
              "title": "Tutorial",
              "description": "A lesson on how to play it."
            }
          ],
          "x-fix": "set \"content: performance\" or \"content: tutorial\"",
          "description": "Whether it is a performance of the song or a lesson."
        },
        "capo": {
          "type": "integer",
          "minimum": 0,
          "title": "Capo",
          "description": "Capo used in this recording, if stated.",
          "x-fix": "write the capo fret as a whole number"
        },
        "pitch": {
          "type": "integer",
          "title": "Pitch",
          "description": "Semitone offset used in this recording, if stated.",
          "x-fix": "write the pitch as a whole number, e.g. -1"
        },
        "tuning": {
          "type": "string",
          "title": "Tuning",
          "description": "String tuning used in this recording, if stated.",
          "x-fix": "write the tuning name as text"
        },
        "note": {
          "type": "string",
          "title": "Note",
          "x-fix": "write the note as text",
          "description": "Free text, e.g. how this recording differs from the tab."
        }
      },
      "description": "One recording or tutorial. All fields are optional. capo, pitch and tuning are set only when stated for this recording; omitted means unknown, not 'same as the tab'."
    }
  }
}
