{
  "schemaVersion": 1,
  "slug": "chord-transposer-calculator",
  "category": "music",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "1dbe7bbe249f889355c372ab6acc9fe358e23d78e23a96efe018d1563ff11ada",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/chord-transposer-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": "j = (i + s) mod 12;  capo = (−s) mod 12",
    "vars": [
      [
        "i",
        "Original pitch class (0 = C)"
      ],
      [
        "s",
        "Semitone shift"
      ],
      [
        "j",
        "New pitch class"
      ],
      [
        "capo",
        "Capo position (frets)"
      ]
    ],
    "note": "Wraps at 12 semitones; chord suffixes (m, 7…) are kept; choose sharp or flat spelling."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const empty={transposed:null,semitonesUsed:null,originalKey:null,transposedKey:null,capo:null};const raw=String(chords||'').trim(),tokens=raw?raw.split(/\\s+/):[];const re=/^([A-G](?:#|b)?)([^/\\s]*)(?:\\/([A-G](?:#|b)?))?$/;if(!tokens.length||!Number.isInteger(semitones)||semitones< -12||semitones>12||!['sharp','flat'].includes(accidentals)||tokens.some(t=>!re.test(t)))return{...empty,__error:'inputError'};const sharpNames=['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'],flatNames=['C','Db','D','Eb','E','F','Gb','G','Ab','A','Bb','B'],names=accidentals==='flat'?flatNames:sharpNames;const idx=n=>{const i=sharpNames.indexOf(n);return i>=0?i:flatNames.indexOf(n)};const shift=n=>names[((idx(n)+semitones)%12+12)%12];const move=t=>{const m=re.exec(t);return shift(m[1])+m[2]+(m[3]?'/'+shift(m[3]):'')};const list=tokens.map(move),capo=((semitones%12)+12)%12;return{transposed:list.join(' '),semitonesUsed:semitones,originalKey:tokens[0],transposedKey:list[0],capo:capo===0?'No capo needed':'Capo at fret '+capo};",
    "inputs": [
      {
        "name": "chords",
        "type": "text",
        "default": "C Am F G",
        "step": 1
      },
      {
        "name": "semitones",
        "type": "number",
        "default": 2,
        "min": -12,
        "max": 12,
        "step": 1,
        "slider": true
      },
      {
        "name": "accidentals",
        "type": "select",
        "default": "sharp",
        "options": [
          {
            "value": "sharp"
          },
          {
            "value": "flat"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "transposed",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "semitonesUsed",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "originalKey",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "transposedKey",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "capo",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
