{
  "openapi": "3.1.1",
  "info": {
    "title": "Membrane Sound Lab API",
    "version": "1.0.0",
    "summary": "Change a rectangular drum shape, strike point and pitch, then hear its modes.",
    "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://tonegridmembranelab.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Change a rectangular drum shape, strike point and pitch, then hear its modes.",
        "description": "Explore a rectangular membrane with spatial mode plots, interactive strike positions and configurable synthesized WAV samples.\n\nMethodology:\n- Fixed-edge rectangular membrane modes: frequency proportional to sqrt((m/width)^2+(n/height)^2). The first 24 modes from m,n=1..8 are shown with spatial phase plots.\n- Strike weights and modeled exponential decay produce a mono 22.05 kHz WAV, with inaudible modes omitted and a short fade at both ends. No autoplay. This is a synthesis model, not arbitrary-shape FEM or material prediction.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "tonegrid_membrane_lab",
        "x-owner-app": "tonegrid",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TonegridMembraneLabInput"
              },
              "examples": {
                "example1": {
                  "summary": "Try an example",
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TonegridMembraneLabResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "TonegridMembraneLabInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "width": {
            "title": "Relative width",
            "type": "number",
            "minimum": 0.1,
            "maximum": 10,
            "default": 1
          },
          "height": {
            "title": "Relative height",
            "type": "number",
            "minimum": 0.1,
            "maximum": 10,
            "default": 1.4
          },
          "strikeX": {
            "title": "Strike X (0–1)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.35
          },
          "strikeY": {
            "title": "Strike Y (0–1)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.4
          },
          "pitch": {
            "title": "Fundamental frequency (Hz)",
            "type": "number",
            "minimum": 30,
            "maximum": 1000,
            "default": 130
          },
          "seconds": {
            "title": "Sample duration (seconds)",
            "type": "number",
            "minimum": 0.25,
            "maximum": 5,
            "default": 2
          },
          "decay": {
            "title": "Decay rate",
            "type": "number",
            "minimum": 0.2,
            "maximum": 8,
            "default": 2
          }
        },
        "required": []
      },
      "TonegridMembraneLabResult": {
        "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": [
              "width",
              "height",
              "strikeX",
              "strikeY",
              "modes",
              "svg"
            ],
            "properties": {
              "width": {
                "type": "number"
              },
              "height": {
                "type": "number"
              },
              "strikeX": {
                "type": "number"
              },
              "strikeY": {
                "type": "number"
              },
              "modes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "m",
                    "n",
                    "hz",
                    "amplitude"
                  ],
                  "properties": {
                    "m": {
                      "type": "number"
                    },
                    "n": {
                      "type": "number"
                    },
                    "hz": {
                      "type": "number"
                    },
                    "amplitude": {
                      "type": "number"
                    }
                  }
                }
              },
              "svg": {
                "type": "string"
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}