{
  "openapi": "3.1.1",
  "info": {
    "title": "Click Track Maker (Metronome WAV \u0026 MIDI) API",
    "version": "1.0.0",
    "summary": "Turn a song map with tempo and meter changes into a metronome click track as WAV and MIDI.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://tonegridmetronomeclick.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Turn a song map with tempo and meter changes into a metronome click track as WAV and MIDI.",
        "description": "Write the sections of a song — bars, meter, tempo, tempo changes, accent groups, subdivisions and a polyrhythm layer — and get a sample-accurate metronome click track as a WAV file and a MIDI file, with an optional count-in, gap click (muted bars to test your inner time) and seeded random muting. The same engine as the metronome in the Tonegrid app.\n\nMethodology:\n- Every bar gets its tempo (a tempo change inside a section moves in equal steps from the first to the last bar) and lasts beats × 60 / tempo seconds; the bar start times are added up in order. Click times inside a bar: beats at j × 60/tempo, subdivisions in between, polyrhythm clicks at m × bar length / n.\n- The WAV file (16-bit mono, 44.1 kHz) places each click on the sample nearest to its time, so clicks never drift. Click sounds are short synthesized tones: the first beat of the bar is the highest, the first beat of every accent group is a little lower and softer, other beats lower still; subdivisions are quiet and the polyrhythm layer has its own lower pitch.\n- The MIDI file (type 0, 480 ticks per quarter note) has tempo and time-signature changes per bar, section names as markers and the clicks on channel 10 (General MIDI wood blocks; cowbell for the polyrhythm layer). Gap click mutes bars in a fixed play/mute cycle after the count-in; random mute draws each bar from a seeded generator, so the same seed mutes the same bars.\n\nPractice aid. The click track is synthesized and free to use; check the timing against your own recording software before relying on it in a session.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "tonegrid_metronome_click",
        "x-owner-app": "tonegrid",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TonegridMetronomeClickInput"
              },
              "examples": {
                "example1": {
                  "summary": "Song with a 7/8 bridge and a slowing outro",
                  "value": {
                    "map": "Intro: 4 bars 4/4 at 96\nVerse: 8 bars 4/4 at 96\nBridge: 4 bars 7/8 at 168 groups 2+2+3\nOutro: 4 bars 4/4 at 96 to 80",
                    "sound": "wood",
                    "countIn": 1,
                    "gapPlay": 0,
                    "gapMute": 0,
                    "randomMute": 0,
                    "seed": "practice"
                  }
                },
                "example2": {
                  "summary": "Gap click: 2 bars on, 2 bars off at 100 BPM",
                  "value": {
                    "map": "16 bars 4/4 at 100 sub 2",
                    "sound": "beep",
                    "countIn": 1,
                    "gapPlay": 2,
                    "gapMute": 2,
                    "randomMute": 0,
                    "seed": "practice"
                  }
                },
                "example3": {
                  "summary": "Three against two (3:2 polyrhythm) in 2/4",
                  "value": {
                    "map": "8 bars 2/4 at 80 poly 3",
                    "sound": "soft",
                    "countIn": 0,
                    "gapPlay": 0,
                    "gapMute": 0,
                    "randomMute": 0,
                    "seed": "practice"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TonegridMetronomeClickResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "TonegridMetronomeClickInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "map": {
            "title": "Song map (one section per line)",
            "description": "Each line: optional name and colon, number of bars, meter, \"at\" tempo. Optional: \"to\" end tempo (changes bar by bar), \"groups 2+2+3\" (accents), \"sub 2\" (eighths), \"sub 3\" (triplets), \"sub 4\" (sixteenths), \"poly 3\" (three evenly spaced clicks per bar). Tempo counts the lower number of the meter: 7/8 at 168 = 168 eighths per minute.",
            "type": "string",
            "maxLength": 20000,
            "default": "Intro: 4 bars 4/4 at 96\nVerse: 8 bars 4/4 at 96\nBridge: 4 bars 7/8 at 168 groups 2+2+3\nOutro: 4 bars 4/4 at 96 to 80"
          },
          "sound": {
            "title": "Click sound",
            "type": "string",
            "enum": [
              "wood",
              "beep",
              "soft"
            ],
            "default": "wood"
          },
          "countIn": {
            "title": "Count-in bars",
            "type": "integer",
            "minimum": 0,
            "maximum": 4,
            "default": 1
          },
          "gapPlay": {
            "title": "Gap click: bars with clicks",
            "description": "With “bars muted” above 0: play this many bars, then mute, and repeat. 0 = off.",
            "type": "integer",
            "minimum": 0,
            "maximum": 16,
            "default": 0
          },
          "gapMute": {
            "title": "Gap click: bars muted",
            "type": "integer",
            "minimum": 0,
            "maximum": 16,
            "default": 0
          },
          "randomMute": {
            "title": "Random mute (% of bars)",
            "description": "Each bar after the first is muted with this chance. The seed fixes which bars.",
            "type": "number",
            "minimum": 0,
            "maximum": 90,
            "default": 0
          },
          "seed": {
            "title": "Random seed",
            "type": "string",
            "maxLength": 60,
            "default": "practice"
          }
        },
        "required": []
      },
      "TonegridMetronomeClickResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "songMap",
              "seconds",
              "bars",
              "clicks",
              "mutedBars",
              "sections",
              "wavFile",
              "midiFile"
            ],
            "properties": {
              "songMap": {
                "type": "string",
                "description": "The song map in its canonical form (paste it into Tonegrid’s Practice view)."
              },
              "seconds": {
                "type": "number"
              },
              "bars": {
                "type": "integer",
                "description": "Bars including the count-in."
              },
              "clicks": {
                "type": "integer",
                "description": "Clicks that sound (muted bars excluded)."
              },
              "mutedBars": {
                "type": "integer"
              },
              "sections": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "label",
                    "startSeconds",
                    "bars",
                    "meter",
                    "tempo",
                    "seconds",
                    "mutedBars"
                  ],
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "startSeconds": {
                      "type": "number"
                    },
                    "bars": {
                      "type": "integer"
                    },
                    "meter": {
                      "type": "string"
                    },
                    "tempo": {
                      "type": "string",
                      "description": "BPM of the meter’s note value; \"a → b\" for a tempo change across the section."
                    },
                    "seconds": {
                      "type": "number"
                    },
                    "mutedBars": {
                      "type": "integer"
                    }
                  }
                }
              },
              "wavFile": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "midiFile": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}