{
  "openapi": "3.1.1",
  "info": {
    "title": "Ambience Generator (rain, wind, stream, fire, hum, drone) API",
    "version": "1.0.0",
    "summary": "Synthesize rain, wind, water, fire, room hum or a drone as a seamless-loop WAV.",
    "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://soundscapeambiencegenerator.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Synthesize rain, wind, water, fire, room hum or a drone as a seamless-loop WAV.",
        "description": "Creates procedural background sound — rain with individual drops, gusty wind, a bubbling stream, a crackling campfire, room tone with mechanical hum, or an evolving drone — as a seamless-loop WAV. Every layer is synthesized from seeded noise and oscillators (no samples), with intensity, brightness and character controls and an optional room reverb.\n\nMethodology:\n- Rain: a pink-noise bed band-limited by the brightness, plus raindrops as a Poisson process (rate = drops per second × intensity), each a short decaying, slightly falling sine with a click, at a random stereo position.\n- Wind: pink noise through a band-pass filter whose centre frequency, sharpness and level follow a gust envelope made from three smoothed random curves (about 8 s, 2.5 s and 0.8 s), plus low rumble; the right channel hears each gust 0.25 s later.\n- Stream: four noise bands (≈300 Hz–4 kHz, lower for larger water) with fast random level changes, plus bubbles: short sines with rising pitch, as in physically based liquid-sound models.\n- Fire: low brown-noise roar and airy hiss with flicker, plus clusters of very short noise bursts (crackles) and occasional low pops. Hum: fundamental and harmonics with a 1/k^p roll-off (odd harmonics stronger) over low-passed pink room tone. Drone: band-limited (polyBLEP) sawtooth voices on root, fifth and octave, detuned, through a low-pass filter moved by slow LFOs.\n- Seamless loops: noise-like parts are rendered longer and the tail is crossfaded (equal power) onto the start; periodic parts (hum, drone, LFOs) are rounded to whole cycles per loop so they repeat exactly. Optional room reverb (Freeverb structure) is applied before looping, with a warm-up so the loop start is already reverberant.\n\nThese are synthesized impressions of natural sounds, not field recordings. Start playback quietly.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "soundscape_ambience_generator",
        "x-owner-app": "soundscape",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SoundscapeAmbienceGeneratorInput"
              },
              "examples": {
                "example1": {
                  "summary": "Steady rain, 6 s seamless loop",
                  "value": {
                    "kind": "rain",
                    "duration": 6,
                    "sampleRate": "44100",
                    "intensity": 0.6,
                    "density": 150,
                    "brightness": 0.5,
                    "seed": "1"
                  }
                },
                "example2": {
                  "summary": "Gusty wind in an open forest, 6 s",
                  "value": {
                    "kind": "wind",
                    "duration": 6,
                    "sampleRate": "32000",
                    "intensity": 0.7,
                    "gustiness": 0.8,
                    "pitch": 0.4,
                    "room": "forest",
                    "seed": "storm"
                  }
                },
                "example3": {
                  "summary": "Campfire with lots of crackles, 5 s mono",
                  "value": {
                    "kind": "fire",
                    "duration": 5,
                    "sampleRate": "44100",
                    "channels": "mono",
                    "intensity": 0.6,
                    "detail": 0.8,
                    "seed": "7"
                  }
                },
                "example4": {
                  "summary": "Server-room hum on 60 Hz mains, 4 s",
                  "value": {
                    "kind": "hum",
                    "duration": 4,
                    "sampleRate": "22050",
                    "frequency": 120,
                    "partials": 10,
                    "brightness": 0.6,
                    "roomToneDb": -18,
                    "seed": "1"
                  }
                },
                "example5": {
                  "summary": "Evolving drone in a hall, 8 s",
                  "value": {
                    "kind": "drone",
                    "duration": 8,
                    "sampleRate": "32000",
                    "frequency": 55,
                    "partials": 5,
                    "detuneCents": 12,
                    "motion": 0.6,
                    "lfoRate": 0.25,
                    "room": "hall",
                    "seed": "1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SoundscapeAmbienceGeneratorResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "SoundscapeAmbienceGeneratorInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "kind": {
            "title": "Sound",
            "type": "string",
            "enum": [
              "rain",
              "wind",
              "stream",
              "fire",
              "hum",
              "drone"
            ],
            "default": "rain"
          },
          "duration": {
            "title": "Loop length",
            "description": "Up to 60 seconds (stereo up to 48 kHz). A seamless loop can be repeated as long as you like in any player that loops. The WAV file is kept on the server for about 2 hours so you can download it, then deleted.",
            "type": "number",
            "minimum": 1,
            "maximum": 60,
            "default": 20,
            "x-unit": "s"
          },
          "sampleRate": {
            "title": "Sample rate",
            "type": "string",
            "enum": [
              "8000",
              "16000",
              "22050",
              "32000",
              "44100",
              "48000",
              "96000"
            ],
            "default": "44100"
          },
          "channels": {
            "title": "Channels",
            "type": "string",
            "enum": [
              "stereo",
              "mono"
            ],
            "default": "stereo"
          },
          "level": {
            "title": "Level (RMS)",
            "type": "number",
            "minimum": -60,
            "maximum": -6,
            "default": -20,
            "x-unit": "dBFS"
          },
          "loop": {
            "title": "Seamless loop",
            "type": "boolean",
            "default": true
          },
          "loopCrossfade": {
            "title": "Loop crossfade",
            "description": "Longer crossfades hide the seam better; at most a quarter of the loop length is used.",
            "type": "number",
            "minimum": 0.05,
            "maximum": 10,
            "default": 1,
            "x-unit": "s"
          },
          "room": {
            "title": "Room",
            "type": "string",
            "enum": [
              "none",
              "small-room",
              "living-room",
              "studio",
              "hall",
              "cathedral",
              "cave",
              "forest"
            ],
            "default": "none"
          },
          "intensity": {
            "title": "Intensity (rain, wind strength, water flow, fire size)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
          },
          "density": {
            "title": "Raindrops per second at full intensity (rain)",
            "type": "number",
            "minimum": 0,
            "maximum": 400,
            "default": 120
          },
          "brightness": {
            "title": "Brightness (rain, fire, hum, drone)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
          },
          "gustiness": {
            "title": "Gustiness (wind)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
          },
          "pitch": {
            "title": "Pitch (wind) or water size (stream: 0 brook … 1 river)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
          },
          "detail": {
            "title": "Bubbles (stream) or crackles (fire)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
          },
          "frequency": {
            "title": "Frequency (hum fundamental or drone root)",
            "description": "Empty = 100 Hz hum (transformer hum on 50 Hz mains; use 120 for 60 Hz mains) or a 55 Hz drone root.",
            "type": "number",
            "minimum": 20,
            "maximum": 1000,
            "x-unit": "Hz"
          },
          "partials": {
            "title": "Harmonics (hum, 1–16) or voices (drone, 2–8)",
            "description": "Empty = 8 harmonics or 4 voices.",
            "type": "integer",
            "minimum": 1,
            "maximum": 16
          },
          "detuneCents": {
            "title": "Detune spread (drone)",
            "type": "number",
            "minimum": 0,
            "maximum": 50,
            "default": 8,
            "x-unit": "cents"
          },
          "motion": {
            "title": "Slow movement (drone LFO depth, hum wobble)",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
          },
          "lfoRate": {
            "title": "LFO rate (drone)",
            "type": "number",
            "minimum": 0.01,
            "maximum": 1,
            "default": 0.08,
            "x-unit": "Hz"
          },
          "roomToneDb": {
            "title": "Room tone level relative to the hum (hum)",
            "type": "number",
            "minimum": -60,
            "maximum": 0,
            "default": -24,
            "x-unit": "dB"
          },
          "encoding": {
            "title": "File format",
            "type": "string",
            "enum": [
              "pcm16",
              "float32"
            ],
            "default": "pcm16"
          },
          "seed": {
            "title": "Seed",
            "description": "Same seed and settings = the same file. Change it for different drops, gusts and crackles.",
            "type": "string",
            "maxLength": 40,
            "default": "1"
          }
        },
        "required": []
      },
      "SoundscapeAmbienceGeneratorResult": {
        "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": [
              "kind",
              "sampleRate",
              "channels",
              "durationSeconds",
              "frames",
              "loop",
              "room",
              "seed",
              "encoding",
              "parameters",
              "events",
              "quantisedFrequencyHz",
              "levelReduced",
              "spectrum",
              "seam",
              "artifact"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "rain",
                  "wind",
                  "stream",
                  "fire",
                  "hum",
                  "drone"
                ]
              },
              "sampleRate": {
                "type": "integer"
              },
              "channels": {
                "type": "integer"
              },
              "durationSeconds": {
                "type": "number"
              },
              "frames": {
                "type": "integer"
              },
              "loop": {
                "type": "boolean"
              },
              "room": {
                "type": "string"
              },
              "seed": {
                "type": "string"
              },
              "encoding": {
                "type": "string"
              },
              "parameters": {
                "type": "object",
                "description": "All synthesis parameters after defaults and clamping (what was rendered)."
              },
              "events": {
                "type": "integer",
                "description": "Raindrops, bubbles or crackles that were synthesized."
              },
              "quantisedFrequencyHz": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Hum fundamental or drone root after rounding to whole cycles per loop (looped files only)."
              },
              "levelReduced": {
                "type": "boolean"
              },
              "spectrum": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "centroidHz",
                  "rolloffHz",
                  "slopeDbPerOctave",
                  "peaks",
                  "rmsDb",
                  "peakDb",
                  "crestDb",
                  "octaveBands"
                ],
                "properties": {
                  "centroidHz": {
                    "type": "number",
                    "description": "Power-weighted mean frequency (spectral centroid)."
                  },
                  "rolloffHz": {
                    "type": "number",
                    "description": "Frequency below which 85 % of the power lies."
                  },
                  "slopeDbPerOctave": {
                    "type": "number",
                    "description": "Least-squares slope of the 1/3-octave power spectrum between 100 Hz and min(10 kHz, sample rate / 4)."
                  },
                  "peaks": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "frequencyHz",
                        "levelDb"
                      ],
                      "properties": {
                        "frequencyHz": {
                          "type": "number"
                        },
                        "levelDb": {
                          "type": "number"
                        }
                      }
                    }
                  },
                  "rmsDb": {
                    "type": "number"
                  },
                  "peakDb": {
                    "type": "number"
                  },
                  "crestDb": {
                    "type": "number"
                  },
                  "octaveBands": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "centerHz",
                        "relativeDb"
                      ],
                      "properties": {
                        "centerHz": {
                          "type": "number"
                        },
                        "relativeDb": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              },
              "seam": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "seamJump",
                  "maxInnerJump"
                ],
                "properties": {
                  "seamJump": {
                    "type": "number"
                  },
                  "maxInnerJump": {
                    "type": "number"
                  }
                }
              },
              "artifact": {
                "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"
              }
            }
          }
        }
      }
    }
  }
}