{
  "format": "forge.graph/0",
  "name": "Tape Stop",
  "author": "Chirp",
  "license": "CC-BY-4.0",
  "remixed_from": null,
  "description": "Pulls the plug on the tape machine: the sound slows down, dropping in pitch until it grinds to a halt, then spins back up. Every bar and Every 2 bars stop on the last beat, in time with the song; Stopped holds it stopped and Running lets it play, so a DAW lane or a footswitch can stop it exactly where you want. Stop and Start set how long each takes.",
  "tags": ["tape", "stop", "glitch", "experimental", "tempo"],
  "face": {
    "display": { "kind": "meter", "label": "Speed", "source": "speed", "range": [0, 1] },
    "knobs": [
      { "id": "stop", "label": "Stop", "default": 0.5,
        "controls": [ { "target": "stop_speed.v", "from": 0.0004, "to": 0.00002, "curve": "exp" } ] },
      { "id": "start", "label": "Start", "default": 0.35,
        "controls": [ { "target": "start_speed.v", "from": 0.002, "to": 0.00005, "curve": "exp" } ] },
      { "id": "level", "label": "Level", "default": 0.5,
        "controls": [ { "target": "level.amount", "from": 0.6, "to": 1.6 } ] }
    ],
    "menus": [
      { "id": "tape", "label": "Tape", "options": ["Running", "Stopped", "Each bar", "2 bars"], "default": 2,
        "controls": [ { "target": "mode.choice" },
                      { "target": "bars.rate", "unit": "per_beat", "values": [0.25, 0.25, 0.25, 0.125] } ] }
    ]
  },
  "nodes": {
    "one": { "block": "value", "mono": true, "set": { "v": 1 } },
    "zero": { "block": "value", "mono": true, "set": { "v": 0 } },
    "bars": { "block": "rhythm", "mono": true, "set": { "steps": 1, "pattern": 1 } },
    "last_beat": { "block": "formula", "mono": true, "set": { "expr": "clamp((0.75 - a) * 1000, 0, 1)" }, "in": { "a": "bars:ramp" } },
    "mode": { "block": "select", "mono": true, "in": { "a": "one", "b": "zero", "c": "last_beat", "d": "last_beat" } },
    "stop_speed": { "block": "value", "mono": true },
    "start_speed": { "block": "value", "mono": true },
    "speed": { "block": "formula", "mono": true,
               "set": { "expr": "b + (a - b) * mix(c, d, clamp((a - b) * 1000, 0, 1))" },
               "in": { "a": "mode", "b": "speed_mem", "c": "stop_speed", "d": "start_speed" } },
    "speed_mem": { "block": "history", "mono": true, "in": { "x": "speed" } },
    "slow": { "block": "pitch", "set": { "ratio": 0.25, "window": 0.05 }, "in": { "x": "in" } },
    "out_mix": { "block": "formula", "set": { "expr": "mix(b * min(1, c * 1.5), a, c * c * c * c * c * c)" },
                 "in": { "a": "in", "b": "slow", "c": "speed" } },
    "level": { "block": "gain", "in": { "x": "out_mix" } }
  },
  "mods": {
    "pitch_follows": { "from": "speed", "target": "slow.ratio", "amount": 0.75 }
  },
  "out": "level"
}
