{
  "openapi": "3.1.1",
  "info": {
    "title": "Synth Patch to WAV API",
    "version": "1.0.0",
    "summary": "Play notes or a MIDI file through a synthesizer sound and download the result as a WAV file.",
    "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://sinebloompatchtowav.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Play notes or a MIDI file through a synthesizer sound and download the result as a WAV file.",
        "description": "Renders a polyphonic synthesizer sound — one of 32 built-in presets or a patch copied from the Sinebloom app — playing your notes on the server and returns a 16-bit stereo WAV with its waveform, spectrum and levels. Type notes as text (C4+E4+G4:2 G4:0.5), paste a JSON note list or upload a Standard MIDI File; an optional arpeggiator turns held chords into patterns. Same engine and same bytes as Sinebloom’s WAV export.\n\nMethodology:\n- Each note becomes a voice of a polyphonic subtractive/wavetable synthesizer: up to three oscillators (PolyBLEP-band-limited saw, square, pulse, triangle, sine, or mip-mapped wavetables built by inverse FFT so no partial passes Nyquist) with unison detune and stereo spread, a sub oscillator and noise, a zero-delay-feedback 24 dB ladder or 12 dB state-variable filter with its own envelope and key tracking, an amplitude envelope, two LFOs and an 8-row modulation matrix (updated every 16 samples).\n- The voices pass distortion, chorus, delay and a Freeverb-style reverb, then a look-ahead peak limiter with a −1 dBFS ceiling. Notes are placed sample-accurately from beats and tempo; everything is deterministic (seeded noise), so the same inputs give the same bytes.\n- The arpeggiator turns held notes into one note per grid step (up, down, up-and-down, as played or seeded random) at half the step length. Limits: 30 s including the tail, 2,000 notes, 1 MB MIDI files.\n\nSynthesized with original presets — no samples of other instruments or products. You may use the audio you render freely.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "sinebloom_patch_to_wav",
        "x-owner-app": "sinebloom",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SinebloomPatchToWavInput"
              },
              "examples": {
                "example1": {
                  "summary": "Warm pad chords",
                  "value": {
                    "preset": "pad-warm-strings",
                    "notes": "C4+E4+G4:2 A3+C4+E4:2",
                    "bpm": 90,
                    "patch": "",
                    "arp": "off",
                    "arpRate": "1/16",
                    "tail": 2,
                    "sampleRate": "44100"
                  }
                },
                "example2": {
                  "summary": "Acid bass arpeggio",
                  "value": {
                    "preset": "bass-acidic-line",
                    "notes": "C2+G2+C3:4",
                    "bpm": 124,
                    "patch": "{\"filter\": {\"resonance\": 0.85}}",
                    "arp": "updown",
                    "arpRate": "1/16",
                    "tail": 1,
                    "sampleRate": "44100"
                  }
                },
                "example3": {
                  "summary": "Pluck melody with a custom filter",
                  "value": {
                    "preset": "pluck-crystal",
                    "notes": "E5:0.5 B4:0.5 G4:0.5 E5:0.5 D5 B4",
                    "bpm": 110,
                    "patch": "{\"filter\": {\"cutoff\": 1800}}",
                    "arp": "off",
                    "arpRate": "1/16",
                    "tail": 2,
                    "sampleRate": "48000"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SinebloomPatchToWavResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "SinebloomPatchToWavInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "preset": {
            "title": "Sound (preset)",
            "type": "string",
            "enum": [
              "",
              "bass-round-sub",
              "bass-acidic-line",
              "bass-fat-saw",
              "bass-pluck-wood",
              "bass-reese",
              "lead-bright-saw",
              "lead-square-chip",
              "lead-sync-sweep",
              "lead-soft-whistle",
              "lead-gritty",
              "pad-warm-strings",
              "pad-glass-choir",
              "pad-dark-drift",
              "pad-organ-swell",
              "pad-shimmer",
              "keys-electric",
              "keys-soft-piano",
              "keys-organ-perc",
              "keys-clav",
              "pluck-crystal",
              "pluck-house",
              "pluck-kalimba",
              "pluck-harp",
              "fx-riser",
              "fx-laser",
              "fx-wind",
              "fx-bitcrush-bleep",
              "drum-synth-kick",
              "drum-snappy-snare",
              "drum-metal-hat",
              "arp-bouncy",
              "arp-glassy-steps"
            ],
            "default": "pad-warm-strings"
          },
          "notes": {
            "title": "Notes",
            "description": "Steps separated by spaces: a note name (C4, F#3, Bb2) or chord (C4+E4+G4), then :beats (default 1) and @velocity (1–127, default 100); r is a rest. A JSON list of {pitch, start, duration, velocity} in beats or a uw-note-clip works too. Ignored when a MIDI file is uploaded.",
            "type": "string",
            "maxLength": 20000,
            "default": "C4+E4+G4:2 A3+C4+E4:2"
          },
          "midi": {
            "title": "MIDI file (optional)",
            "description": "Standard MIDI File (type 0 or 1). All tracks are played by the one sound; the tempo field below is used, not the file’s tempo. Upload as {filename, contentType?, contentBase64}. Max 1024 KiB. Accepts .mid,.midi,audio/midi,audio/x-midi.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "bpm": {
            "title": "Tempo",
            "type": "number",
            "minimum": 20,
            "maximum": 300,
            "default": 120,
            "x-unit": "BPM"
          },
          "patch": {
            "title": "Patch JSON (optional)",
            "description": "A whole patch from Sinebloom (File → Copy patch JSON) replaces the preset; a partial object changes only the settings it names. Format: docs/AUDIO_ENGINE.md (uw-synth-patch).",
            "type": "string",
            "maxLength": 20000,
            "default": ""
          },
          "arp": {
            "title": "Arpeggiator",
            "type": "string",
            "enum": [
              "off",
              "up",
              "down",
              "updown",
              "random",
              "played"
            ],
            "default": "off"
          },
          "arpRate": {
            "title": "Arpeggiator rate",
            "type": "string",
            "enum": [
              "1/4",
              "1/8",
              "1/8t",
              "1/16",
              "1/16t",
              "1/32"
            ],
            "default": "1/16"
          },
          "tail": {
            "title": "Tail after the last note",
            "description": "Time for releases, delay and reverb to ring out.",
            "type": "number",
            "minimum": 0,
            "maximum": 10,
            "default": 2,
            "x-unit": "s"
          },
          "sampleRate": {
            "title": "Sample rate",
            "type": "string",
            "enum": [
              "44100",
              "48000"
            ],
            "default": "44100"
          }
        },
        "required": []
      },
      "SinebloomPatchToWavResult": {
        "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": [
              "name",
              "category",
              "source",
              "notes",
              "bpm",
              "sampleRate",
              "seconds",
              "peakDb",
              "rmsDb",
              "voicesMax",
              "limiterDb",
              "lowestNote",
              "highestNote",
              "patch",
              "wavFile"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Patch name."
              },
              "category": {
                "type": "string"
              },
              "source": {
                "type": "string",
                "enum": [
                  "text",
                  "json",
                  "midi"
                ],
                "description": "Where the notes came from."
              },
              "notes": {
                "type": "integer",
                "description": "Notes played (after the arpeggiator)."
              },
              "bpm": {
                "type": "number"
              },
              "sampleRate": {
                "type": "integer"
              },
              "seconds": {
                "type": "number",
                "description": "File length including the tail."
              },
              "peakDb": {
                "type": "number",
                "description": "Sample peak (the master limiter keeps it at or below −1 dBFS)."
              },
              "rmsDb": {
                "type": "number"
              },
              "voicesMax": {
                "type": "integer",
                "description": "Most voices sounding at once."
              },
              "limiterDb": {
                "type": "number",
                "description": "Strongest gain reduction of the master limiter (0 = never limited)."
              },
              "lowestNote": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "highestNote": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "patch": {
                "type": "object",
                "description": "The complete patch used (uw-synth-patch)."
              },
              "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)."
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}