{
  "openapi": "3.1.1",
  "info": {
    "title": "Tempo Ramp Planner (Speed Trainer) API",
    "version": "1.0.0",
    "summary": "Plan a speed-building ramp: +N BPM every M bars up to your goal, as a table and click track.",
    "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://tonegridtemporamp.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Plan a speed-building ramp: +N BPM every M bars up to your goal, as a table and click track.",
        "description": "Build a piece up to speed step by step: choose a start tempo, a target, the step in BPM and how many bars each tempo lasts. You get the plan with the time each stage starts, the total practice time, a song map for the Tonegrid metronome and the whole ramp as a MIDI file and a WAV click track. Works for slowing down too.\n\nMethodology:\n- Stages run from the start tempo towards the target in steps of the chosen size; the last stage is exactly the target and lasts the stage bars plus the extra bars. Each stage becomes one section of a song map, so the same plan plays in Tonegrid’s metronome (Practice view) and in the Click Track Maker.\n- Stage times add up bar lengths (beats × 60 / tempo). The MIDI file carries a tempo change at every stage; the WAV click track uses the same click timeline sample by sample.\n- Practising slowly and raising the tempo in small steps once a passage is clean is a common teaching approach; the step size and bars per stage are your choice.\n\nPractice aid only. Take breaks and stop if your hands or arms hurt.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "tonegrid_tempo_ramp",
        "x-owner-app": "tonegrid",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TonegridTempoRampInput"
              },
              "examples": {
                "example1": {
                  "summary": "From 80 to 120 BPM, +5 every 4 bars",
                  "value": {
                    "start": 80,
                    "target": 120,
                    "step": 5,
                    "every": 4,
                    "meter": "4/4",
                    "groups": "",
                    "sub": "1",
                    "hold": 4,
                    "sound": "wood",
                    "countIn": 1,
                    "audio": true
                  }
                },
                "example2": {
                  "summary": "Odd meter build-up: 7/8 from 140 to 200, groups 2+2+3",
                  "value": {
                    "start": 140,
                    "target": 200,
                    "step": 10,
                    "every": 8,
                    "meter": "7/8",
                    "groups": "2+2+3",
                    "sub": "1",
                    "hold": 8,
                    "sound": "beep",
                    "countIn": 1,
                    "audio": true
                  }
                },
                "example3": {
                  "summary": "Sixteenth-note scales: 60 to 92 BPM, +4 every 2 bars, plan only",
                  "value": {
                    "start": 60,
                    "target": 92,
                    "step": 4,
                    "every": 2,
                    "meter": "4/4",
                    "groups": "",
                    "sub": "4",
                    "hold": 0,
                    "sound": "soft",
                    "countIn": 0,
                    "audio": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TonegridTempoRampResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "TonegridTempoRampInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "start": {
            "title": "Start tempo (BPM)",
            "type": "number",
            "minimum": 20,
            "maximum": 400,
            "default": 80
          },
          "target": {
            "title": "Target tempo (BPM)",
            "type": "number",
            "minimum": 20,
            "maximum": 400,
            "default": 120
          },
          "step": {
            "title": "Change per stage (BPM)",
            "type": "number",
            "minimum": 0.5,
            "maximum": 50,
            "default": 5
          },
          "every": {
            "title": "Bars per stage",
            "type": "integer",
            "minimum": 1,
            "maximum": 64,
            "default": 4
          },
          "meter": {
            "title": "Meter",
            "type": "string",
            "maxLength": 6,
            "default": "4/4"
          },
          "groups": {
            "title": "Accent groups (optional)",
            "description": "Numbers joined by + that add up to the beats per bar; empty = accent only on beat 1.",
            "type": "string",
            "maxLength": 40,
            "default": ""
          },
          "sub": {
            "title": "Subdivision",
            "type": "string",
            "enum": [
              "1",
              "2",
              "3",
              "4"
            ],
            "default": "1"
          },
          "hold": {
            "title": "Extra bars at the target",
            "type": "integer",
            "minimum": 0,
            "maximum": 64,
            "default": 4
          },
          "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
          },
          "audio": {
            "title": "Render a WAV click track as well",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "TonegridTempoRampResult": {
        "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": [
              "stages",
              "seconds",
              "bars",
              "songMap",
              "midiFile",
              "wavFile"
            ],
            "properties": {
              "stages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "stage",
                    "tempo",
                    "bars",
                    "startSeconds",
                    "seconds"
                  ],
                  "properties": {
                    "stage": {
                      "type": "integer"
                    },
                    "tempo": {
                      "type": "number"
                    },
                    "bars": {
                      "type": "integer"
                    },
                    "startSeconds": {
                      "type": "number",
                      "description": "After the count-in."
                    },
                    "seconds": {
                      "type": "number"
                    }
                  }
                }
              },
              "seconds": {
                "type": "number",
                "description": "Total length including the count-in."
              },
              "bars": {
                "type": "integer"
              },
              "songMap": {
                "type": "string"
              },
              "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)."
                  }
                }
              },
              "wavFile": {
                "type": [
                  "object",
                  "null"
                ],
                "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"
              }
            }
          }
        }
      }
    }
  }
}