{
  "schemaVersion": 1,
  "slug": "metronome-calculator",
  "category": "music",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "98ed97081cbab99978f01f6c2e9566c6627ab379f9fb7155e57d94a0be39bc13",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/metronome-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 = Σᵢ ((bars × beats ÷ n) × 60 ÷ (BPM + i × ΔBPM))",
    "vars": [
      [
        "Δt",
        "beat interval, ms"
      ],
      [
        "BPM",
        "beats per minute"
      ],
      [
        "beats",
        "beats per bar"
      ],
      [
        "bars",
        "bars to play"
      ],
      [
        "T",
        "total time, ms"
      ]
    ],
    "note": "For a ramp, total beats are divided evenly among BPM steps; duration at each step is summed. The generated schedule cannot exceed 400 BPM."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const high=bpm+(rampSteps-1)*rampIncrement;if(!Number.isFinite(high)||high>400)return{intervalMs:null,barDuration:null,totalTime:null,totalBeats:null,rampHigh:null,rampSchedule:null,__error:'inputError'};const interval=60000/bpm,bar=interval*beatsPerBar/1000,totalBeats=barsToPlay*beatsPerBar,beatsPerStep=totalBeats/rampSteps,list=[];let totalTime=0;for(let i=0;i<rampSteps;i++){const tempo=bpm+i*rampIncrement;list.push(tempo);totalTime+=beatsPerStep*60/tempo;}return{intervalMs:interval,barDuration:bar,totalTime,totalBeats,rampHigh:high,rampSchedule:list.join(' → ')};",
    "inputs": [
      {
        "name": "bpm",
        "type": "number",
        "default": 96,
        "min": 1,
        "max": 400,
        "step": 1,
        "slider": true
      },
      {
        "name": "beatsPerBar",
        "type": "number",
        "default": 4,
        "min": 1,
        "max": 32,
        "step": 1,
        "slider": true
      },
      {
        "name": "barsToPlay",
        "type": "number",
        "default": 16,
        "min": 1,
        "max": 10000,
        "step": 1
      },
      {
        "name": "rampIncrement",
        "type": "number",
        "default": 4,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "rampSteps",
        "type": "number",
        "default": 5,
        "min": 1,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "intervalMs",
        "precision": 2,
        "unit": "ms"
      },
      {
        "name": "barDuration",
        "precision": 2,
        "unit": "seconds"
      },
      {
        "name": "totalTime",
        "precision": 1,
        "unit": "seconds"
      },
      {
        "name": "totalBeats",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "rampHigh",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "rampSchedule",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
