{
  "format": "forge.graph/0",
  "name": "Beat Repeat",
  "author": "Chirp",
  "license": "CC-BY-4.0",
  "remixed_from": null,
  "description": "A glitch stutter locked to the tempo: on the beats the Pattern picks, it grabs the last slice you played and repeats it like a stuck record, then lets go on the next beat. Size sets the slice (an eighth down to a 32nd), Fade how fast the repeats die away, and Mix how much of it you hear.",
  "tags": ["glitch", "stutter", "rhythm", "tempo"],
  "face": {
    "display": { "kind": "lamp", "label": "Repeat", "source": "beats:gate", "range": [0, 1] },
    "knobs": [
      { "id": "fade", "label": "Fade", "default": 0.8,
        "controls": [ { "target": "keep.v", "from": 0.6, "to": 1 } ] },
      { "id": "mix", "label": "Mix", "default": 1,
        "controls": [ { "target": "mixer.mix", "from": 0, "to": 1 } ] }
    ],
    "menus": [
      { "id": "size", "label": "Size", "options": ["1/8", "1/16", "1/32", "1/16T"], "default": 1,
        "controls": [ { "target": "loop.time", "unit": "beats", "values": [0.5, 0.25, 0.125, 0.1667] } ] },
      { "id": "pattern", "label": "Pattern", "options": ["Bar ends", "Alt beat", "Fill", "Offbeats"], "default": 0,
        "controls": [ { "target": "beats.pattern", "values": [136, 170, 192, 170] },
                      { "target": "beats.rate", "unit": "per_beat", "values": [1, 1, 1, 2] } ] }
    ]
  },
  "nodes": {
    "beats": { "block": "rhythm", "mono": true, "set": { "steps": 8, "smooth": 0.03 } },
    "keep": { "block": "value", "mono": true },
    "capture": { "block": "formula", "set": { "expr": "a * (1 - b)" }, "in": { "a": "in", "b": "beats:gate" } },
    "held": { "block": "formula", "set": { "expr": "a * b * c" }, "in": { "a": "loop", "b": "beats:gate", "c": "keep" } },
    "loop": { "block": "delay", "set": { "glide": 1, "max": 1.6 }, "in": { "x": ["capture", "held"] } },
    "stutter": { "block": "formula", "set": { "expr": "a * (1 - c) + b * c" },
                 "in": { "a": "in", "b": "loop", "c": "beats:gate" } },
    "mixer": { "block": "blend", "in": { "dry": "in", "wet": "stutter" } }
  },
  "out": "mixer"
}
