{
  "schemaVersion": 1,
  "slug": "delay-reverb-calculator",
  "category": "music",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "ad5178e4e05cfbd44d050862d6f24388daf7dc7aceb03f3a855cb25198e9c284",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/delay-reverb-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "t = (60000 ÷ BPM) × 4v; N = 0 (f = 0), ln(0.05) ÷ ln(f) (f > 0)",
    "vars": [
      [
        "BPM",
        "Tempo"
      ],
      [
        "v",
        "Note value"
      ],
      [
        "t",
        "Delay time (ms)"
      ],
      [
        "f",
        "Feedback fraction"
      ],
      [
        "N",
        "Repeats before fade"
      ]
    ],
    "note": "Pre-delay = 0.2 × delay time (heuristic); decay = room preset × [1 + (1 − feedback fraction)/2]. Both are illustrative starting points."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const allowed=[1,0.5,0.375,0.3333,0.25,0.1875,0.1667,0.125,0.0625];if(![bpm,noteValue,feedback].every(Number.isFinite)||bpm<1||bpm>400||feedback<0||feedback>95||!allowed.includes(Number(noteValue))||!['room','plate','hall','cathedral'].includes(reverbSize))return {delayMs:null,delaySeconds:null,preDelayMs:null,decaySeconds:null,feedbackPercent:null,delayNote:null,repeatsBeforeFade:null,__error:'inputError'};const beat=60000/bpm,delay=beat*4*noteValue,fb=feedback/100,repeats=fb>0?Math.log(0.05)/Math.log(fb):0,base={room:0.8,plate:1.6,hall:2.6,cathedral:5}[reverbSize],names={1:'Whole note',0.5:'Half note',0.375:'Dotted quarter',0.3333:'Quarter triplet',0.25:'Quarter note',0.1875:'Dotted eighth',0.1667:'Eighth triplet',0.125:'Eighth note',0.0625:'Sixteenth note'};return {delayMs:delay,delaySeconds:delay/1000,preDelayMs:delay*0.2,decaySeconds:base*(1+(1-fb)*0.5),feedbackPercent:feedback,delayNote:names[noteValue]||'Custom',repeatsBeforeFade:repeats};",
    "inputs": [
      {
        "name": "bpm",
        "type": "number",
        "default": 120,
        "min": 1,
        "max": 400,
        "step": 1,
        "slider": true
      },
      {
        "name": "noteValue",
        "type": "select",
        "default": 0.375,
        "options": [
          {
            "value": 1
          },
          {
            "value": 0.5
          },
          {
            "value": 0.375
          },
          {
            "value": 0.3333
          },
          {
            "value": 0.25
          },
          {
            "value": 0.1875
          },
          {
            "value": 0.1667
          },
          {
            "value": 0.125
          },
          {
            "value": 0.0625
          }
        ]
      },
      {
        "name": "feedback",
        "type": "number",
        "default": 30,
        "min": 0,
        "max": 95,
        "step": 1,
        "slider": true
      },
      {
        "name": "reverbSize",
        "type": "select",
        "default": "hall",
        "options": [
          {
            "value": "room"
          },
          {
            "value": "plate"
          },
          {
            "value": "hall"
          },
          {
            "value": "cathedral"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "delayMs",
        "precision": 2,
        "unit": "ms"
      },
      {
        "name": "delaySeconds",
        "precision": 4,
        "unit": "s"
      },
      {
        "name": "preDelayMs",
        "precision": 1,
        "unit": "ms"
      },
      {
        "name": "decaySeconds",
        "precision": 2,
        "unit": "s"
      },
      {
        "name": "feedbackPercent",
        "precision": 0,
        "unit": "%"
      },
      {
        "name": "delayNote",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "repeatsBeforeFade",
        "precision": 1,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
