{
  "$type": "at.atmosynth.module",
  "descriptionVersion": 1,
  "moduleId": "instrument-brass",
  "versionKey": "3",
  "name": "Brass",
  "description": "A blown voice that opens as it is held, as an Oberheim's does: two sawtooths a few cents apart through a mixer that leans on them and a state-variable filter whose contour swells with the attack and settles half open. Filter contour is how far, in cents, the filter's own contour opens it, Filter decay and Filter sustain that contour's shape, and Emphasis how far the filter rings, singing past one.",
  "audioInputs": [
    {
      "id": "in",
      "label": "In"
    }
  ],
  "audioOutputs": [
    {
      "id": "out",
      "label": "Out"
    }
  ],
  "midiInputs": [
    {
      "id": "midi",
      "label": "Note"
    }
  ],
  "nodes": [
    {
      "id": "note",
      "kind": "midiInput",
      "options": {
        "midiInput": "midi"
      }
    },
    {
      "id": "vel",
      "kind": "midiInput",
      "options": {
        "midiInput": "midi",
        "signal": "velocity"
      }
    },
    {
      "id": "in",
      "kind": "moduleInput",
      "options": {
        "input": "in"
      }
    },
    {
      "id": "one",
      "kind": "constantSource",
      "options": {}
    },
    {
      "id": "sum",
      "kind": "gain",
      "options": {}
    },
    {
      "id": "sumset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          "0.9375",
          "-0.9375"
        ]
      }
    },
    {
      "id": "osc1",
      "kind": "dsp",
      "options": {
        "code": "// The oscillator of an analog monosynth, as one module: a wave that morphs\n// from a triangle through a sawtooth and a square to a narrow pulse, a sub\n// oscillator locked to it, a phase that does not start where the last note's\n// did, and a pitch that never quite sits still. The vocabulary's own\n// `oscillator` reaches none of the four. It has no phase anything can read,\n// so nothing can count its cycles to divide them into a sub; nothing can tell\n// it where to start, and every voice built for a note starts it at nothing;\n// nothing can start it over, so it cannot be synced; and its waves are four\n// fixed shapes, so a knob between them is a crossfade of four oscillators\n// that only sound like one while they stay in step.\n//\n// **Wave** travels triangle, sawtooth, square at nought to two, each pair\n// mixed sample for sample between, and from two to three the square narrows\n// from a half of the cycle to a tenth of it rather than fading into anything.\n// A tenth because the pulse loses its fundamental fast below it — its level\n// falls with the sine of the width times pi, a third of the square's at a\n// tenth and a sixth at a twentieth — and because its two edges must stay\n// further apart than the two samples each one's correction spans, which at a\n// tenth they do up to C7 and at a twentieth only up to C6. A pulse spends more\n// of its cycle low than high, so it sits off centre by that much; the offset\n// is taken off as the width moves, rather than by a filter after it, so a\n// narrow pulse starts a note centred instead of thumping into place.\n//\n// Every wave starts where the platform's other oscillators start theirs: the\n// triangle and the sawtooth at nothing on their way up, the square at the\n// start of its high half. So **Phase** at reset starts every note exactly as\n// an `oscillator` would, and free starts each one somewhere else in its\n// cycle, drawn from the module's generator — which is what an analog\n// oscillator does, since it never stopped running between notes. Two notes in\n// a row, or two of these detuned against each other, then never start their\n// attack the same way twice.\n//\n// **The sub** is a square one octave or two below, and is the main phase\n// divided rather than an oscillator of its own: it changes sides every time\n// the main phase comes round, or every second time, so it cannot drift\n// against it. It has an output of its own, at full level whatever the mix is,\n// and the module mixes it into Out through a gain outside this code.\n//\n// **Drift** is a slow wander of the pitch, in cents: a new target from the\n// dice every three tenths of a second, approached through a one-pole with the\n// same time constant, worked out every 32 samples rather than every one,\n// since nothing that slow needs more. It is the instability that makes two\n// analog oscillators beat against each other, and at nothing it is gone.\n//\n// **Sync** takes the phase back to its start on the rising zero crossings of\n// whatever is patched there, as the sync oscillator's Sync input does, a\n// sample late and never a fraction of one jittery. While it is driving, the\n// pitch heard is the thing driving it, so that is what the sub divides; when\n// it lets go, the sub divides the main phase's own turns again.\n//\n// Every discontinuity is corrected where it falls between two samples: a\n// polyBLEP scaled by however far the wave jumped for the sawtooth's fall, the\n// pulse's two edges, the sub's edges and a reset, and that residual\n// integrated once — a polyBLAMP — for the triangle's corners. The output\n// leaves through a one-pole at 5 Hz, as the sync oscillator's does and for\n// its reason: a wave cut off mid-cycle no longer sits either side of nothing.\nimport { AtmoProcessor, Rng } from \"atmosynth:dsp\";\n\n/** The narrowest the pulse gets, as a fraction of the cycle spent high. */\nconst NARROWEST = 0.1;\n/** Samples between two steps of the drift. */\nconst DRIFT_TICK = 32;\n/** Seconds between two of its targets, and its time constant. */\nconst DRIFT_SECONDS = 0.3;\n\n/** No more than a wave a sample, and never backwards; nothing at all where it is not finite. */\nfunction limit(step) {\n  return !(step - step === 0) ? 0 : step > 0.49 ? 0.49 : step < 0 ? 0 : step;\n}\n\nexport default class AtmosynthAnalog extends AtmoProcessor {\n  static spec = 1;\n  static inputs = [];\n  // Out, then the sub on its own.\n  static outputs = [1, 1];\n  // Not smoothed here: a knob's move reaches these already eased, and the\n  // note and the inputs wired in are followed exactly.\n  static params = {\n    // The note, in hertz, off the module's MIDI input.\n    frequency: { min: 0, max: 24000, default: 0, rate: \"a\", smooth: 0 },\n    // The knob and whatever is patched into Detune, together.\n    detune: { min: -9600, max: 9600, default: 0, rate: \"a\", smooth: 0 },\n    // 0 triangle, 1 sawtooth, 2 square, 3 narrow pulse, and every place between.\n    wave: { min: 0, max: 3, default: 1, rate: \"a\", smooth: 0 },\n    // Whatever is patched into Sync. Silence never crosses, so an input with\n    // nothing in it starts nothing over.\n    reset: { min: -1000, max: 1000, default: 0, rate: \"a\", smooth: 0 },\n    // How far the pitch wanders, in cents.\n    drift: { min: 0, max: 15, default: 3, rate: \"a\", smooth: 0 },\n    // 0 one octave down, 1 two.\n    octave: { min: 0, max: 1, default: 0, rate: \"k\", smooth: 0 },\n    // 0 free, 1 reset. Read once, when the note begins.\n    phase: { min: 0, max: 1, default: 0, rate: \"k\", smooth: 0 },\n  };\n\n  constructor() {\n    super();\n    // Where a free note starts and the drift's targets. Nothing is drawn\n    // until the first call, which is when the note begins.\n    this.rng = new Rng(this.seed);\n    this.phase = 0;\n    /** The main phase's turns, counted round four: the sub is read off it. */\n    this.count = 0;\n    /** Whether the first block has drawn where this note starts. */\n    this.begun = false;\n    /** The Detune the ratio was last worked out for. */\n    this.cents = 0;\n    this.ratio = 1;\n    /** What the Wave knob was last worked out for (not a number until it has\n     *  been, so the first sample works it out), and what it came to. */\n    this.wave = 0 / 0;\n    this.tri = 0;\n    this.saw = 1;\n    this.pulse = 0;\n    this.width = 0.5;\n    this.offset = 0;\n    this.start = 0;\n    /** The Sync input as it was a sample ago, and samples it still drives for. */\n    this.lastLevel = 0;\n    this.external = 0;\n    /** Band-limiting owed to this sample and the next, for each output. */\n    this.owed = 0;\n    this.carry = 0;\n    this.subOwed = 0;\n    this.subCarry = 0;\n    /** The 5 Hz one-pole on the way out, and the two samples it remembers. */\n    this.pole = 1 - (2 * Math.PI * 5) / sampleRate;\n    this.lastRaw = 0;\n    this.centred = 0;\n    /** The drift: samples to its next step and to its next target, where it is\n     *  heading, where it has got to, and the ratio that comes to. */\n    this.tick = 0;\n    this.every = DRIFT_SECONDS * sampleRate;\n    this.wait = this.every;\n    this.glide = 1 - Math.exp(-DRIFT_TICK / this.every);\n    this.target = 0;\n    this.wander = 0;\n    this.drifted = 1;\n  }\n\n  /** The Wave knob's travel, as weights on three waves and a pulse's width. */\n  shape(position) {\n    const place = position < 0 ? 0 : position > 3 ? 3 : position;\n    this.tri = place < 1 ? 1 - place : 0;\n    this.saw = place < 1 ? place : place < 2 ? 2 - place : 0;\n    this.pulse = place < 1 ? 0 : place < 2 ? place - 1 : 1;\n    this.width = place < 2 ? 0.5 : 0.5 - (place - 2) * (0.5 - NARROWEST);\n    // A pulse high for a fraction w of its cycle sits 2w − 1 off centre.\n    this.offset = this.pulse * (2 * this.width - 1);\n    this.start = this.level(0);\n  }\n\n  /** The wave at a phase, before any band-limiting. */\n  level(phase) {\n    let value = 0;\n    if (this.tri !== 0) {\n      const turned = phase < 0.75 ? phase + 0.25 : phase - 0.75;\n      value = this.tri * (1 - 4 * Math.abs(turned - 0.5));\n    }\n    if (this.saw !== 0) value += this.saw * (phase < 0.5 ? 2 * phase : 2 * phase - 2);\n    if (this.pulse !== 0) value += this.pulse * (phase < this.width ? 1 : -1) - this.offset;\n    return value;\n  }\n\n  /** A band-limited step of `height`, `when` samples after this instant. */\n  jump(height, when) {\n    const half = height / 2;\n    this.owed += half * (1 - when) * (1 - when);\n    this.carry -= half * when * when;\n  }\n\n  /** The same for the sub's own output. */\n  subJump(height, when) {\n    const half = height / 2;\n    this.subOwed += half * (1 - when) * (1 - when);\n    this.subCarry -= half * when * when;\n  }\n\n  /** A band-limited corner: the slope changes by `change` a sample. */\n  bend(change, when) {\n    const sixth = change / 6;\n    this.owed += sixth * (1 - when) * (1 - when) * (1 - when);\n    this.carry += sixth * when * when * when;\n  }\n\n  /** One more turn for the sub to divide, `when` samples after this instant. */\n  turn(mask, when) {\n    const before = (this.count & mask) !== 0 ? -1 : 1;\n    this.count = (this.count + 1) & 3;\n    const after = (this.count & mask) !== 0 ? -1 : 1;\n    if (after !== before) this.subJump(after - before, when);\n  }\n\n  process(inputs, outputs, params) {\n    const channel = outputs[0][0];\n    const below = outputs[1][0];\n    const frequency = params.frequency;\n    const detune = params.detune;\n    const wave = params.wave;\n    const reset = params.reset;\n    const drift = params.drift;\n    const mask = params.octave[0] < 0.5 ? 1 : 2;\n    const rate = sampleRate;\n\n    if (!this.begun) {\n      this.begun = true;\n      if (params.phase[0] < 0.5) {\n        this.phase = this.rng.uniform();\n        this.count = Math.floor(this.rng.uniform() * 4);\n        this.wander = this.rng.bipolar();\n      }\n      this.target = this.rng.bipolar();\n    }\n\n    for (let index = 0; index < channel.length; index += 1) {\n      const position = wave[index];\n      if (!(position === this.wave)) {\n        this.shape(position);\n        this.wave = position;\n      }\n      const cents = detune[index];\n      if (cents !== this.cents) {\n        this.cents = cents;\n        this.ratio = Math.pow(2, cents / 1200);\n      }\n      if (this.tick === 0) {\n        this.tick = DRIFT_TICK;\n        this.wait -= DRIFT_TICK;\n        if (this.wait <= 0) {\n          this.wait += this.every;\n          this.target = this.rng.bipolar();\n        }\n        this.wander += (this.target - this.wander) * this.glide;\n        this.drifted = Math.pow(2, (drift[index] * this.wander) / 1200);\n      }\n      this.tick -= 1;\n      const step = limit((frequency[index] * this.ratio * this.drifted) / rate);\n\n      // The Sync input's rising zero crossings, placed the same fraction into\n      // this sample as they fell into the last.\n      let syncAt = -1;\n      const level = reset[index];\n      if (this.lastLevel < 0 && level >= 0) {\n        syncAt = -this.lastLevel / (level - this.lastLevel);\n        if (syncAt >= 1) syncAt = 0.999999;\n        this.external = rate | 0;\n      }\n      this.lastLevel = level;\n      const driven = this.external > 0;\n      if (driven) this.external -= 1;\n\n      // What the last sample's discontinuities left for this one.\n      this.owed = this.carry;\n      this.carry = 0;\n      this.subOwed = this.subCarry;\n      this.subCarry = 0;\n\n      // Both outputs at this instant, before the interval to the next one is\n      // walked for everything that happens in it.\n      const value = this.level(this.phase);\n      const sub = (this.count & mask) !== 0 ? -1 : 1;\n\n      const tri = this.tri;\n      const saw = this.saw;\n      const pulse = this.pulse;\n      const width = this.width;\n      let phase = this.phase;\n      let where = 0;\n      for (let guard = 0; guard < 8; guard += 1) {\n        let boundary = 1;\n        if (tri !== 0) {\n          if (phase < 0.25) boundary = 0.25;\n          else if (phase < 0.75) boundary = 0.75;\n        }\n        if (saw !== 0 && phase < 0.5 && 0.5 < boundary) boundary = 0.5;\n        if (pulse !== 0 && phase < width && width < boundary) boundary = width;\n        let when = step > 0 ? where + (boundary - phase) / step : 2;\n        if (when < where) when = where;\n\n        if (syncAt >= where && syncAt <= when) {\n          // Back to the start, from wherever the wave had got to, and the\n          // triangle's slope with it where it was on its way down.\n          phase += (syncAt - where) * step;\n          where = syncAt;\n          syncAt = -1;\n          this.jump(this.start - this.level(phase), where);\n          if (tri !== 0 && phase >= 0.25 && phase < 0.75) this.bend(8 * tri * step, where);\n          phase = 0;\n          this.turn(mask, where);\n          continue;\n        }\n        if (when > 1) break;\n\n        where = when;\n        phase = boundary;\n        if (tri !== 0) {\n          if (boundary === 0.25) this.bend(-8 * tri * step, where);\n          else if (boundary === 0.75) this.bend(8 * tri * step, where);\n        }\n        if (saw !== 0 && boundary === 0.5) this.jump(-2 * saw, where);\n        if (pulse !== 0 && boundary === width) this.jump(-2 * pulse, where);\n        if (boundary === 1) {\n          if (pulse !== 0) this.jump(2 * pulse, where);\n          phase = 0;\n          if (!driven) this.turn(mask, where);\n        }\n      }\n      this.phase = phase + (1 - where) * step;\n\n      const raw = value + this.owed;\n      this.centred = raw - this.lastRaw + this.pole * this.centred;\n      this.lastRaw = raw;\n      channel[index] = this.centred;\n      below[index] = sub + this.subOwed;\n    }\n    return true;\n  }\n}\n"
      }
    },
    {
      "id": "osc2",
      "kind": "dsp",
      "options": {
        "code": "// The oscillator of an analog monosynth, as one module: a wave that morphs\n// from a triangle through a sawtooth and a square to a narrow pulse, a sub\n// oscillator locked to it, a phase that does not start where the last note's\n// did, and a pitch that never quite sits still. The vocabulary's own\n// `oscillator` reaches none of the four. It has no phase anything can read,\n// so nothing can count its cycles to divide them into a sub; nothing can tell\n// it where to start, and every voice built for a note starts it at nothing;\n// nothing can start it over, so it cannot be synced; and its waves are four\n// fixed shapes, so a knob between them is a crossfade of four oscillators\n// that only sound like one while they stay in step.\n//\n// **Wave** travels triangle, sawtooth, square at nought to two, each pair\n// mixed sample for sample between, and from two to three the square narrows\n// from a half of the cycle to a tenth of it rather than fading into anything.\n// A tenth because the pulse loses its fundamental fast below it — its level\n// falls with the sine of the width times pi, a third of the square's at a\n// tenth and a sixth at a twentieth — and because its two edges must stay\n// further apart than the two samples each one's correction spans, which at a\n// tenth they do up to C7 and at a twentieth only up to C6. A pulse spends more\n// of its cycle low than high, so it sits off centre by that much; the offset\n// is taken off as the width moves, rather than by a filter after it, so a\n// narrow pulse starts a note centred instead of thumping into place.\n//\n// Every wave starts where the platform's other oscillators start theirs: the\n// triangle and the sawtooth at nothing on their way up, the square at the\n// start of its high half. So **Phase** at reset starts every note exactly as\n// an `oscillator` would, and free starts each one somewhere else in its\n// cycle, drawn from the module's generator — which is what an analog\n// oscillator does, since it never stopped running between notes. Two notes in\n// a row, or two of these detuned against each other, then never start their\n// attack the same way twice.\n//\n// **The sub** is a square one octave or two below, and is the main phase\n// divided rather than an oscillator of its own: it changes sides every time\n// the main phase comes round, or every second time, so it cannot drift\n// against it. It has an output of its own, at full level whatever the mix is,\n// and the module mixes it into Out through a gain outside this code.\n//\n// **Drift** is a slow wander of the pitch, in cents: a new target from the\n// dice every three tenths of a second, approached through a one-pole with the\n// same time constant, worked out every 32 samples rather than every one,\n// since nothing that slow needs more. It is the instability that makes two\n// analog oscillators beat against each other, and at nothing it is gone.\n//\n// **Sync** takes the phase back to its start on the rising zero crossings of\n// whatever is patched there, as the sync oscillator's Sync input does, a\n// sample late and never a fraction of one jittery. While it is driving, the\n// pitch heard is the thing driving it, so that is what the sub divides; when\n// it lets go, the sub divides the main phase's own turns again.\n//\n// Every discontinuity is corrected where it falls between two samples: a\n// polyBLEP scaled by however far the wave jumped for the sawtooth's fall, the\n// pulse's two edges, the sub's edges and a reset, and that residual\n// integrated once — a polyBLAMP — for the triangle's corners. The output\n// leaves through a one-pole at 5 Hz, as the sync oscillator's does and for\n// its reason: a wave cut off mid-cycle no longer sits either side of nothing.\nimport { AtmoProcessor, Rng } from \"atmosynth:dsp\";\n\n/** The narrowest the pulse gets, as a fraction of the cycle spent high. */\nconst NARROWEST = 0.1;\n/** Samples between two steps of the drift. */\nconst DRIFT_TICK = 32;\n/** Seconds between two of its targets, and its time constant. */\nconst DRIFT_SECONDS = 0.3;\n\n/** No more than a wave a sample, and never backwards; nothing at all where it is not finite. */\nfunction limit(step) {\n  return !(step - step === 0) ? 0 : step > 0.49 ? 0.49 : step < 0 ? 0 : step;\n}\n\nexport default class AtmosynthAnalog extends AtmoProcessor {\n  static spec = 1;\n  static inputs = [];\n  // Out, then the sub on its own.\n  static outputs = [1, 1];\n  // Not smoothed here: a knob's move reaches these already eased, and the\n  // note and the inputs wired in are followed exactly.\n  static params = {\n    // The note, in hertz, off the module's MIDI input.\n    frequency: { min: 0, max: 24000, default: 0, rate: \"a\", smooth: 0 },\n    // The knob and whatever is patched into Detune, together.\n    detune: { min: -9600, max: 9600, default: 0, rate: \"a\", smooth: 0 },\n    // 0 triangle, 1 sawtooth, 2 square, 3 narrow pulse, and every place between.\n    wave: { min: 0, max: 3, default: 1, rate: \"a\", smooth: 0 },\n    // Whatever is patched into Sync. Silence never crosses, so an input with\n    // nothing in it starts nothing over.\n    reset: { min: -1000, max: 1000, default: 0, rate: \"a\", smooth: 0 },\n    // How far the pitch wanders, in cents.\n    drift: { min: 0, max: 15, default: 3, rate: \"a\", smooth: 0 },\n    // 0 one octave down, 1 two.\n    octave: { min: 0, max: 1, default: 0, rate: \"k\", smooth: 0 },\n    // 0 free, 1 reset. Read once, when the note begins.\n    phase: { min: 0, max: 1, default: 0, rate: \"k\", smooth: 0 },\n  };\n\n  constructor() {\n    super();\n    // Where a free note starts and the drift's targets. Nothing is drawn\n    // until the first call, which is when the note begins.\n    this.rng = new Rng(this.seed);\n    this.phase = 0;\n    /** The main phase's turns, counted round four: the sub is read off it. */\n    this.count = 0;\n    /** Whether the first block has drawn where this note starts. */\n    this.begun = false;\n    /** The Detune the ratio was last worked out for. */\n    this.cents = 0;\n    this.ratio = 1;\n    /** What the Wave knob was last worked out for (not a number until it has\n     *  been, so the first sample works it out), and what it came to. */\n    this.wave = 0 / 0;\n    this.tri = 0;\n    this.saw = 1;\n    this.pulse = 0;\n    this.width = 0.5;\n    this.offset = 0;\n    this.start = 0;\n    /** The Sync input as it was a sample ago, and samples it still drives for. */\n    this.lastLevel = 0;\n    this.external = 0;\n    /** Band-limiting owed to this sample and the next, for each output. */\n    this.owed = 0;\n    this.carry = 0;\n    this.subOwed = 0;\n    this.subCarry = 0;\n    /** The 5 Hz one-pole on the way out, and the two samples it remembers. */\n    this.pole = 1 - (2 * Math.PI * 5) / sampleRate;\n    this.lastRaw = 0;\n    this.centred = 0;\n    /** The drift: samples to its next step and to its next target, where it is\n     *  heading, where it has got to, and the ratio that comes to. */\n    this.tick = 0;\n    this.every = DRIFT_SECONDS * sampleRate;\n    this.wait = this.every;\n    this.glide = 1 - Math.exp(-DRIFT_TICK / this.every);\n    this.target = 0;\n    this.wander = 0;\n    this.drifted = 1;\n  }\n\n  /** The Wave knob's travel, as weights on three waves and a pulse's width. */\n  shape(position) {\n    const place = position < 0 ? 0 : position > 3 ? 3 : position;\n    this.tri = place < 1 ? 1 - place : 0;\n    this.saw = place < 1 ? place : place < 2 ? 2 - place : 0;\n    this.pulse = place < 1 ? 0 : place < 2 ? place - 1 : 1;\n    this.width = place < 2 ? 0.5 : 0.5 - (place - 2) * (0.5 - NARROWEST);\n    // A pulse high for a fraction w of its cycle sits 2w − 1 off centre.\n    this.offset = this.pulse * (2 * this.width - 1);\n    this.start = this.level(0);\n  }\n\n  /** The wave at a phase, before any band-limiting. */\n  level(phase) {\n    let value = 0;\n    if (this.tri !== 0) {\n      const turned = phase < 0.75 ? phase + 0.25 : phase - 0.75;\n      value = this.tri * (1 - 4 * Math.abs(turned - 0.5));\n    }\n    if (this.saw !== 0) value += this.saw * (phase < 0.5 ? 2 * phase : 2 * phase - 2);\n    if (this.pulse !== 0) value += this.pulse * (phase < this.width ? 1 : -1) - this.offset;\n    return value;\n  }\n\n  /** A band-limited step of `height`, `when` samples after this instant. */\n  jump(height, when) {\n    const half = height / 2;\n    this.owed += half * (1 - when) * (1 - when);\n    this.carry -= half * when * when;\n  }\n\n  /** The same for the sub's own output. */\n  subJump(height, when) {\n    const half = height / 2;\n    this.subOwed += half * (1 - when) * (1 - when);\n    this.subCarry -= half * when * when;\n  }\n\n  /** A band-limited corner: the slope changes by `change` a sample. */\n  bend(change, when) {\n    const sixth = change / 6;\n    this.owed += sixth * (1 - when) * (1 - when) * (1 - when);\n    this.carry += sixth * when * when * when;\n  }\n\n  /** One more turn for the sub to divide, `when` samples after this instant. */\n  turn(mask, when) {\n    const before = (this.count & mask) !== 0 ? -1 : 1;\n    this.count = (this.count + 1) & 3;\n    const after = (this.count & mask) !== 0 ? -1 : 1;\n    if (after !== before) this.subJump(after - before, when);\n  }\n\n  process(inputs, outputs, params) {\n    const channel = outputs[0][0];\n    const below = outputs[1][0];\n    const frequency = params.frequency;\n    const detune = params.detune;\n    const wave = params.wave;\n    const reset = params.reset;\n    const drift = params.drift;\n    const mask = params.octave[0] < 0.5 ? 1 : 2;\n    const rate = sampleRate;\n\n    if (!this.begun) {\n      this.begun = true;\n      if (params.phase[0] < 0.5) {\n        this.phase = this.rng.uniform();\n        this.count = Math.floor(this.rng.uniform() * 4);\n        this.wander = this.rng.bipolar();\n      }\n      this.target = this.rng.bipolar();\n    }\n\n    for (let index = 0; index < channel.length; index += 1) {\n      const position = wave[index];\n      if (!(position === this.wave)) {\n        this.shape(position);\n        this.wave = position;\n      }\n      const cents = detune[index];\n      if (cents !== this.cents) {\n        this.cents = cents;\n        this.ratio = Math.pow(2, cents / 1200);\n      }\n      if (this.tick === 0) {\n        this.tick = DRIFT_TICK;\n        this.wait -= DRIFT_TICK;\n        if (this.wait <= 0) {\n          this.wait += this.every;\n          this.target = this.rng.bipolar();\n        }\n        this.wander += (this.target - this.wander) * this.glide;\n        this.drifted = Math.pow(2, (drift[index] * this.wander) / 1200);\n      }\n      this.tick -= 1;\n      const step = limit((frequency[index] * this.ratio * this.drifted) / rate);\n\n      // The Sync input's rising zero crossings, placed the same fraction into\n      // this sample as they fell into the last.\n      let syncAt = -1;\n      const level = reset[index];\n      if (this.lastLevel < 0 && level >= 0) {\n        syncAt = -this.lastLevel / (level - this.lastLevel);\n        if (syncAt >= 1) syncAt = 0.999999;\n        this.external = rate | 0;\n      }\n      this.lastLevel = level;\n      const driven = this.external > 0;\n      if (driven) this.external -= 1;\n\n      // What the last sample's discontinuities left for this one.\n      this.owed = this.carry;\n      this.carry = 0;\n      this.subOwed = this.subCarry;\n      this.subCarry = 0;\n\n      // Both outputs at this instant, before the interval to the next one is\n      // walked for everything that happens in it.\n      const value = this.level(this.phase);\n      const sub = (this.count & mask) !== 0 ? -1 : 1;\n\n      const tri = this.tri;\n      const saw = this.saw;\n      const pulse = this.pulse;\n      const width = this.width;\n      let phase = this.phase;\n      let where = 0;\n      for (let guard = 0; guard < 8; guard += 1) {\n        let boundary = 1;\n        if (tri !== 0) {\n          if (phase < 0.25) boundary = 0.25;\n          else if (phase < 0.75) boundary = 0.75;\n        }\n        if (saw !== 0 && phase < 0.5 && 0.5 < boundary) boundary = 0.5;\n        if (pulse !== 0 && phase < width && width < boundary) boundary = width;\n        let when = step > 0 ? where + (boundary - phase) / step : 2;\n        if (when < where) when = where;\n\n        if (syncAt >= where && syncAt <= when) {\n          // Back to the start, from wherever the wave had got to, and the\n          // triangle's slope with it where it was on its way down.\n          phase += (syncAt - where) * step;\n          where = syncAt;\n          syncAt = -1;\n          this.jump(this.start - this.level(phase), where);\n          if (tri !== 0 && phase >= 0.25 && phase < 0.75) this.bend(8 * tri * step, where);\n          phase = 0;\n          this.turn(mask, where);\n          continue;\n        }\n        if (when > 1) break;\n\n        where = when;\n        phase = boundary;\n        if (tri !== 0) {\n          if (boundary === 0.25) this.bend(-8 * tri * step, where);\n          else if (boundary === 0.75) this.bend(8 * tri * step, where);\n        }\n        if (saw !== 0 && boundary === 0.5) this.jump(-2 * saw, where);\n        if (pulse !== 0 && boundary === width) this.jump(-2 * pulse, where);\n        if (boundary === 1) {\n          if (pulse !== 0) this.jump(2 * pulse, where);\n          phase = 0;\n          if (!driven) this.turn(mask, where);\n        }\n      }\n      this.phase = phase + (1 - where) * step;\n\n      const raw = value + this.owed;\n      this.centred = raw - this.lastRaw + this.pole * this.centred;\n      this.lastRaw = raw;\n      channel[index] = this.centred;\n      below[index] = sub + this.subOwed;\n    }\n    return true;\n  }\n}\n"
      }
    },
    {
      "id": "shaper",
      "kind": "waveShaper",
      "options": {
        "curve": [
          "-2.3498582",
          "-2.3498582",
          "-2.3498581",
          "-2.3498581",
          "-2.3498581",
          "-2.3498581",
          "-2.3498581",
          "-2.349858",
          "-2.349858",
          "-2.349858",
          "-2.349858",
          "-2.3498579",
          "-2.3498579",
          "-2.3498579",
          "-2.3498578",
          "-2.3498578",
          "-2.3498578",
          "-2.3498578",
          "-2.3498577",
          "-2.3498577",
          "-2.3498576",
          "-2.3498576",
          "-2.3498576",
          "-2.3498575",
          "-2.3498575",
          "-2.3498575",
          "-2.3498574",
          "-2.3498574",
          "-2.3498573",
          "-2.3498573",
          "-2.3498572",
          "-2.3498572",
          "-2.3498571",
          "-2.3498571",
          "-2.349857",
          "-2.349857",
          "-2.3498569",
          "-2.3498568",
          "-2.3498568",
          "-2.3498567",
          "-2.3498566",
          "-2.3498566",
          "-2.3498565",
          "-2.3498564",
          "-2.3498563",
          "-2.3498563",
          "-2.3498562",
          "-2.3498561",
          "-2.349856",
          "-2.3498559",
          "-2.3498558",
          "-2.3498557",
          "-2.3498557",
          "-2.3498556",
          "-2.3498554",
          "-2.3498553",
          "-2.3498552",
          "-2.3498551",
          "-2.349855",
          "-2.3498549",
          "-2.3498548",
          "-2.3498546",
          "-2.3498545",
          "-2.3498544",
          "-2.3498542",
          "-2.3498541",
          "-2.3498539",
          "-2.3498538",
          "-2.3498536",
          "-2.3498534",
          "-2.3498533",
          "-2.3498531",
          "-2.3498529",
          "-2.3498527",
          "-2.3498525",
          "-2.3498523",
          "-2.3498521",
          "-2.3498519",
          "-2.3498517",
          "-2.3498515",
          "-2.3498512",
          "-2.349851",
          "-2.3498507",
          "-2.3498505",
          "-2.3498502",
          "-2.34985",
          "-2.3498497",
          "-2.3498494",
          "-2.3498491",
          "-2.3498488",
          "-2.3498485",
          "-2.3498481",
          "-2.3498478",
          "-2.3498474",
          "-2.3498471",
          "-2.3498467",
          "-2.3498463",
          "-2.3498459",
          "-2.3498455",
          "-2.3498451",
          "-2.3498447",
          "-2.3498442",
          "-2.3498438",
          "-2.3498433",
          "-2.3498428",
          "-2.3498423",
          "-2.3498417",
          "-2.3498412",
          "-2.3498406",
          "-2.3498401",
          "-2.3498395",
          "-2.3498389",
          "-2.3498382",
          "-2.3498376",
          "-2.3498369",
          "-2.3498362",
          "-2.3498355",
          "-2.3498347",
          "-2.349834",
          "-2.3498332",
          "-2.3498324",
          "-2.3498315",
          "-2.3498307",
          "-2.3498298",
          "-2.3498289",
          "-2.3498279",
          "-2.3498269",
          "-2.3498259",
          "-2.3498249",
          "-2.3498238",
          "-2.3498227",
          "-2.3498215",
          "-2.3498204",
          "-2.3498191",
          "-2.3498179",
          "-2.3498166",
          "-2.3498152",
          "-2.3498139",
          "-2.3498124",
          "-2.349811",
          "-2.3498094",
          "-2.3498079",
          "-2.3498063",
          "-2.3498046",
          "-2.3498029",
          "-2.3498011",
          "-2.3497993",
          "-2.3497974",
          "-2.3497954",
          "-2.3497934",
          "-2.3497913",
          "-2.3497892",
          "-2.349787",
          "-2.3497847",
          "-2.3497824",
          "-2.3497799",
          "-2.3497774",
          "-2.3497748",
          "-2.3497722",
          "-2.3497694",
          "-2.3497666",
          "-2.3497637",
          "-2.3497606",
          "-2.3497575",
          "-2.3497543",
          "-2.349751",
          "-2.3497476",
          "-2.349744",
          "-2.3497404",
          "-2.3497366",
          "-2.3497328",
          "-2.3497288",
          "-2.3497246",
          "-2.3497204",
          "-2.349716",
          "-2.3497114",
          "-2.3497068",
          "-2.3497019",
          "-2.349697",
          "-2.3496918",
          "-2.3496865",
          "-2.349681",
          "-2.3496754",
          "-2.3496696",
          "-2.3496636",
          "-2.3496574",
          "-2.349651",
          "-2.3496444",
          "-2.3496376",
          "-2.3496306",
          "-2.3496233",
          "-2.3496158",
          "-2.3496081",
          "-2.3496002",
          "-2.349592",
          "-2.3495835",
          "-2.3495748",
          "-2.3495657",
          "-2.3495564",
          "-2.3495468",
          "-2.3495369",
          "-2.3495267",
          "-2.3495162",
          "-2.3495053",
          "-2.3494941",
          "-2.3494825",
          "-2.3494706",
          "-2.3494582",
          "-2.3494455",
          "-2.3494324",
          "-2.3494189",
          "-2.3494049",
          "-2.3493905",
          "-2.3493756",
          "-2.3493603",
          "-2.3493445",
          "-2.3493282",
          "-2.3493113",
          "-2.3492939",
          "-2.349276",
          "-2.3492575",
          "-2.3492384",
          "-2.3492187",
          "-2.3491984",
          "-2.3491775",
          "-2.3491558",
          "-2.3491335",
          "-2.3491105",
          "-2.3490868",
          "-2.3490623",
          "-2.349037",
          "-2.3490109",
          "-2.348984",
          "-2.3489562",
          "-2.3489276",
          "-2.348898",
          "-2.3488675",
          "-2.3488361",
          "-2.3488036",
          "-2.3487701",
          "-2.3487356",
          "-2.3487",
          "-2.3486632",
          "-2.3486252",
          "-2.3485861",
          "-2.3485457",
          "-2.348504",
          "-2.348461",
          "-2.3484167",
          "-2.3483709",
          "-2.3483237",
          "-2.348275",
          "-2.3482248",
          "-2.3481729",
          "-2.3481194",
          "-2.3480642",
          "-2.3480073",
          "-2.3479485",
          "-2.3478879",
          "-2.3478254",
          "-2.3477609",
          "-2.3476943",
          "-2.3476256",
          "-2.3475548",
          "-2.3474817",
          "-2.3474063",
          "-2.3473285",
          "-2.3472482",
          "-2.3471654",
          "-2.34708",
          "-2.3469918",
          "-2.3469009",
          "-2.346807",
          "-2.3467102",
          "-2.3466104",
          "-2.3465073",
          "-2.3464011",
          "-2.3462914",
          "-2.3461782",
          "-2.3460615",
          "-2.3459411",
          "-2.3458169",
          "-2.3456887",
          "-2.3455564",
          "-2.34542",
          "-2.3452793",
          "-2.3451341",
          "-2.3449843",
          "-2.3448297",
          "-2.3446703",
          "-2.3445058",
          "-2.3443361",
          "-2.3441611",
          "-2.3439804",
          "-2.3437941",
          "-2.3436019",
          "-2.3434036",
          "-2.343199",
          "-2.342988",
          "-2.3427703",
          "-2.3425456",
          "-2.3423139",
          "-2.3420749",
          "-2.3418283",
          "-2.3415739",
          "-2.3413114",
          "-2.3410407",
          "-2.3407614",
          "-2.3404733",
          "-2.3401761",
          "-2.3398694",
          "-2.3395531",
          "-2.3392269",
          "-2.3388903",
          "-2.3385431",
          "-2.3381849",
          "-2.3378154",
          "-2.3374343",
          "-2.3370411",
          "-2.3366355",
          "-2.3362172",
          "-2.3357856",
          "-2.3353405",
          "-2.3348813",
          "-2.3344077",
          "-2.3339191",
          "-2.3334152",
          "-2.3328954",
          "-2.3323592",
          "-2.3318062",
          "-2.3312357",
          "-2.3306473",
          "-2.3300404",
          "-2.3294145",
          "-2.3287689",
          "-2.3281029",
          "-2.3274161",
          "-2.3267078",
          "-2.3259772",
          "-2.3252236",
          "-2.3244465",
          "-2.323645",
          "-2.3228184",
          "-2.3219659",
          "-2.3210867",
          "-2.32018",
          "-2.3192449",
          "-2.3182806",
          "-2.3172862",
          "-2.3162607",
          "-2.3152033",
          "-2.3141128",
          "-2.3129883",
          "-2.3118288",
          "-2.3106332",
          "-2.3094003",
          "-2.3081291",
          "-2.3068184",
          "-2.305467",
          "-2.3040736",
          "-2.302637",
          "-2.3011559",
          "-2.2996289",
          "-2.2980546",
          "-2.2964317",
          "-2.2947585",
          "-2.2930338",
          "-2.2912558",
          "-2.289423",
          "-2.2875338",
          "-2.2855865",
          "-2.2835793",
          "-2.2815105",
          "-2.2793783",
          "-2.2771808",
          "-2.274916",
          "-2.272582",
          "-2.2701767",
          "-2.2676982",
          "-2.2651441",
          "-2.2625124",
          "-2.2598008",
          "-2.2570069",
          "-2.2541284",
          "-2.251163",
          "-2.2481079",
          "-2.2449608",
          "-2.2417191",
          "-2.2383799",
          "-2.2349406",
          "-2.2313983",
          "-2.2277502",
          "-2.2239933",
          "-2.2201247",
          "-2.2161411",
          "-2.2120394",
          "-2.2078165",
          "-2.2034689",
          "-2.1989934",
          "-2.1943864",
          "-2.1896445",
          "-2.184764",
          "-2.1797413",
          "-2.1745725",
          "-2.169254",
          "-2.1637818",
          "-2.1581519",
          "-2.1523603",
          "-2.1464028",
          "-2.1402753",
          "-2.1339735",
          "-2.1274931",
          "-2.1208297",
          "-2.1139787",
          "-2.1069357",
          "-2.0996961",
          "-2.0922551",
          "-2.0846082",
          "-2.0767503",
          "-2.0686769",
          "-2.0603828",
          "-2.0518633",
          "-2.0431132",
          "-2.0341276",
          "-2.0249014",
          "-2.0154294",
          "-2.0057066",
          "-1.9957278",
          "-1.9854878",
          "-1.9749814",
          "-1.9642034",
          "-1.9531486",
          "-1.9418118",
          "-1.9301878",
          "-1.9182716",
          "-1.9060578",
          "-1.8935416",
          "-1.8807177",
          "-1.8675813",
          "-1.8541275",
          "-1.8403512",
          "-1.826248",
          "-1.811813",
          "-1.7970417",
          "-1.7819297",
          "-1.7664727",
          "-1.7506666",
          "-1.7345074",
          "-1.7179913",
          "-1.7011146",
          "-1.683874",
          "-1.6662662",
          "-1.6482882",
          "-1.6299373",
          "-1.611211",
          "-1.5921072",
          "-1.5726238",
          "-1.5527592",
          "-1.5325122",
          "-1.5118818",
          "-1.4908672",
          "-1.4694684",
          "-1.4476852",
          "-1.4255183",
          "-1.4029685",
          "-1.380037",
          "-1.3567256",
          "-1.3330365",
          "-1.3089722",
          "-1.2845357",
          "-1.2597307",
          "-1.234561",
          "-1.2090311",
          "-1.1831459",
          "-1.156911",
          "-1.1303322",
          "-1.1034159",
          "-1.0761691",
          "-1.0485992",
          "-1.020714",
          "-0.9925221",
          "-0.9640324",
          "-0.9352541",
          "-0.9061971",
          "-0.8768719",
          "-0.847289",
          "-0.8174599",
          "-0.7873961",
          "-0.7571097",
          "-0.7266131",
          "-0.6959193",
          "-0.6650413",
          "-0.6339928",
          "-0.6027877",
          "-0.57144",
          "-0.5399643",
          "-0.5083751",
          "-0.4766874",
          "-0.4449162",
          "-0.4130768",
          "-0.3811846",
          "-0.3492549",
          "-0.3173035",
          "-0.2853458",
          "-0.2533975",
          "-0.2214741",
          "-0.1895912",
          "-0.1577642",
          "-0.1260085",
          "-0.0943393",
          "-0.0627716",
          "-0.0313203",
          0,
          "0.0311749",
          "0.0621904",
          "0.0930326",
          "0.123688",
          "0.1541436",
          "0.1843865",
          "0.2144043",
          "0.2441851",
          "0.2737173",
          "0.3029897",
          "0.3319918",
          "0.3607131",
          "0.3891441",
          "0.4172753",
          "0.445098",
          "0.472604",
          "0.4997852",
          "0.5266346",
          "0.5531451",
          "0.5793105",
          "0.605125",
          "0.6305833",
          "0.6556804",
          "0.6804121",
          "0.7047743",
          "0.7287638",
          "0.7523776",
          "0.7756132",
          "0.7984684",
          "0.8209418",
          "0.843032",
          "0.8647383",
          "0.8860603",
          "0.906998",
          "0.9275517",
          "0.9477221",
          "0.9675103",
          "0.9869177",
          "1.0059458",
          "1.0245968",
          "1.0428729",
          "1.0607767",
          "1.0783108",
          "1.0954784",
          "1.1122827",
          "1.1287271",
          "1.1448154",
          "1.1605513",
          "1.175939",
          "1.1909825",
          "1.2056861",
          "1.2200544",
          "1.2340919",
          "1.2478033",
          "1.2611933",
          "1.2742668",
          "1.2870287",
          "1.299484",
          "1.3116379",
          "1.3234952",
          "1.3350614",
          "1.3463413",
          "1.3573403",
          "1.3680636",
          "1.3785163",
          "1.3887037",
          "1.3986309",
          "1.4083031",
          "1.4177255",
          "1.4269032",
          "1.4358413",
          "1.4445449",
          "1.4530189",
          "1.4612685",
          "1.4692984",
          "1.4771137",
          "1.4847191",
          "1.4921194",
          "1.4993193",
          "1.5063235",
          "1.5131366",
          "1.5197631",
          "1.5262074",
          "1.532474",
          "1.5385672",
          "1.5444911",
          "1.5502501",
          "1.5558481",
          "1.5612893",
          "1.5665776",
          "1.5717168",
          "1.5767108",
          "1.5815633",
          "1.5862779",
          "1.5908583",
          "1.595308",
          "1.5996303",
          "1.6038288",
          "1.6079065",
          "1.6118669",
          "1.615713",
          "1.6194479",
          "1.6230745",
          "1.626596",
          "1.630015",
          "1.6333345",
          "1.6365572",
          "1.6396856",
          "1.6427225",
          "1.6456704",
          "1.6485318",
          "1.651309",
          "1.6540045",
          "1.6566205",
          "1.6591593",
          "1.661623",
          "1.6640138",
          "1.6663338",
          "1.668585",
          "1.6707693",
          "1.6728887",
          "1.674945",
          "1.6769401",
          "1.6788757",
          "1.6807534",
          "1.6825751",
          "1.6843423",
          "1.6860567",
          "1.6877196",
          "1.6893327",
          "1.6908975",
          "1.6924152",
          "1.6938873",
          "1.6953151",
          "1.6967",
          "1.6980432",
          "1.6993459",
          "1.7006093",
          "1.7018347",
          "1.703023",
          "1.7041754",
          "1.705293",
          "1.7063768",
          "1.7074278",
          "1.708447",
          "1.7094353",
          "1.7103937",
          "1.711323",
          "1.7122241",
          "1.7130979",
          "1.7139451",
          "1.7147667",
          "1.7155633",
          "1.7163356",
          "1.7170845",
          "1.7178106",
          "1.7185146",
          "1.7191972",
          "1.719859",
          "1.7205006",
          "1.7211227",
          "1.7217259",
          "1.7223106",
          "1.7228775",
          "1.7234272",
          "1.72396",
          "1.7244766",
          "1.7249775",
          "1.725463",
          "1.7259337",
          "1.7263901",
          "1.7268324",
          "1.7272613",
          "1.7276771",
          "1.7280801",
          "1.7284709",
          "1.7288496",
          "1.7292168",
          "1.7295728",
          "1.7299178",
          "1.7302523",
          "1.7305766",
          "1.7308909",
          "1.7311957",
          "1.731491",
          "1.7317774",
          "1.7320549",
          "1.732324",
          "1.7325848",
          "1.7328376",
          "1.7330827",
          "1.7333203",
          "1.7335505",
          "1.7337738",
          "1.7339901",
          "1.7341999",
          "1.7344032",
          "1.7346002",
          "1.7347913",
          "1.7349764",
          "1.7351559",
          "1.7353299",
          "1.7354985",
          "1.735662",
          "1.7358204",
          "1.735974",
          "1.7361229",
          "1.7362672",
          "1.7364071",
          "1.7365426",
          "1.7366741",
          "1.7368014",
          "1.7369249",
          "1.7370446",
          "1.7371606",
          "1.737273",
          "1.737382",
          "1.7374876",
          "1.73759",
          "1.7376893",
          "1.7377855",
          "1.7378787",
          "1.7379691",
          "1.7380567",
          "1.7381416",
          "1.7382239",
          "1.7383037",
          "1.738381",
          "1.7384559",
          "1.7385286",
          "1.738599",
          "1.7386672",
          "1.7387334",
          "1.7387975",
          "1.7388596",
          "1.7389198",
          "1.7389782",
          "1.7390348",
          "1.7390897",
          "1.7391428",
          "1.7391943",
          "1.7392443",
          "1.7392927",
          "1.7393396",
          "1.7393851",
          "1.7394292",
          "1.7394719",
          "1.7395133",
          "1.7395534",
          "1.7395923",
          "1.73963",
          "1.7396666",
          "1.739702",
          "1.7397363",
          "1.7397696",
          "1.7398019",
          "1.7398331",
          "1.7398634",
          "1.7398928",
          "1.7399213",
          "1.7399489",
          "1.7399756",
          "1.7400015",
          "1.7400266",
          "1.740051",
          "1.7400746",
          "1.7400975",
          "1.7401196",
          "1.7401411",
          "1.740162",
          "1.7401821",
          "1.7402017",
          "1.7402207",
          "1.7402391",
          "1.7402569",
          "1.7402741",
          "1.7402909",
          "1.7403071",
          "1.7403228",
          "1.7403381",
          "1.7403528",
          "1.7403672",
          "1.740381",
          "1.7403945",
          "1.7404075",
          "1.7404202",
          "1.7404324",
          "1.7404443",
          "1.7404558",
          "1.7404669",
          "1.7404777",
          "1.7404882",
          "1.7404984",
          "1.7405082",
          "1.7405177",
          "1.740527",
          "1.7405359",
          "1.7405446",
          "1.740553",
          "1.7405612",
          "1.7405691",
          "1.7405768",
          "1.7405842",
          "1.7405914",
          "1.7405984",
          "1.7406051",
          "1.7406117",
          "1.740618",
          "1.7406242",
          "1.7406302",
          "1.740636",
          "1.7406416",
          "1.740647",
          "1.7406523",
          "1.7406574",
          "1.7406623",
          "1.7406671",
          "1.7406718",
          "1.7406763",
          "1.7406806",
          "1.7406849",
          "1.740689",
          "1.740693",
          "1.7406968",
          "1.7407005",
          "1.7407042",
          "1.7407077",
          "1.7407111",
          "1.7407144",
          "1.7407176",
          "1.7407207",
          "1.7407237",
          "1.7407266",
          "1.7407294",
          "1.7407321",
          "1.7407348",
          "1.7407373",
          "1.7407398",
          "1.7407422",
          "1.7407446",
          "1.7407468",
          "1.740749",
          "1.7407512",
          "1.7407532",
          "1.7407552",
          "1.7407572",
          "1.740759",
          "1.7407609",
          "1.7407626",
          "1.7407643",
          "1.740766",
          "1.7407676",
          "1.7407692",
          "1.7407707",
          "1.7407721",
          "1.7407736",
          "1.7407749",
          "1.7407763",
          "1.7407776",
          "1.7407788",
          "1.74078",
          "1.7407812",
          "1.7407823",
          "1.7407834",
          "1.7407845",
          "1.7407855",
          "1.7407865",
          "1.7407875",
          "1.7407885",
          "1.7407894",
          "1.7407903",
          "1.7407911",
          "1.740792",
          "1.7407928",
          "1.7407936",
          "1.7407943",
          "1.740795",
          "1.7407958",
          "1.7407965",
          "1.7407971",
          "1.7407978",
          "1.7407984",
          "1.740799",
          "1.7407996",
          "1.7408002",
          "1.7408007",
          "1.7408013",
          "1.7408018",
          "1.7408023",
          "1.7408028",
          "1.7408033",
          "1.7408037",
          "1.7408042",
          "1.7408046",
          "1.740805",
          "1.7408054",
          "1.7408058",
          "1.7408062",
          "1.7408066",
          "1.7408069",
          "1.7408073",
          "1.7408076",
          "1.7408079",
          "1.7408083",
          "1.7408086",
          "1.7408089",
          "1.7408091",
          "1.7408094",
          "1.7408097",
          "1.74081",
          "1.7408102",
          "1.7408105",
          "1.7408107",
          "1.7408109",
          "1.7408112",
          "1.7408114",
          "1.7408116",
          "1.7408118",
          "1.740812",
          "1.7408122",
          "1.7408124",
          "1.7408125",
          "1.7408127",
          "1.7408129",
          "1.7408131",
          "1.7408132",
          "1.7408134",
          "1.7408135",
          "1.7408137",
          "1.7408138",
          "1.7408139",
          "1.7408141",
          "1.7408142",
          "1.7408143",
          "1.7408144",
          "1.7408146",
          "1.7408147",
          "1.7408148",
          "1.7408149",
          "1.740815",
          "1.7408151",
          "1.7408152",
          "1.7408153",
          "1.7408154",
          "1.7408155",
          "1.7408155",
          "1.7408156",
          "1.7408157",
          "1.7408158",
          "1.7408159",
          "1.7408159",
          "1.740816",
          "1.7408161",
          "1.7408161",
          "1.7408162",
          "1.7408163",
          "1.7408163",
          "1.7408164",
          "1.7408164",
          "1.7408165",
          "1.7408165",
          "1.7408166",
          "1.7408166",
          "1.7408167",
          "1.7408167",
          "1.7408168",
          "1.7408168",
          "1.7408169",
          "1.7408169",
          "1.740817",
          "1.740817",
          "1.740817",
          "1.7408171",
          "1.7408171",
          "1.7408171",
          "1.7408172",
          "1.7408172",
          "1.7408172",
          "1.7408173",
          "1.7408173",
          "1.7408173",
          "1.7408173",
          "1.7408174",
          "1.7408174",
          "1.7408174",
          "1.7408175",
          "1.7408175",
          "1.7408175",
          "1.7408175",
          "1.7408175",
          "1.7408176",
          "1.7408176",
          "1.7408176",
          "1.7408176",
          "1.7408176",
          "1.7408177",
          "1.7408177",
          "1.7408177",
          "1.7408177",
          "1.7408177",
          "1.7408177",
          "1.7408178",
          "1.7408178",
          "1.7408178",
          "1.7408178",
          "1.7408178",
          "1.7408178",
          "1.7408178",
          "1.7408178",
          "1.7408179",
          "1.7408179",
          "1.7408179"
        ],
        "oversample": "4x"
      }
    },
    {
      "id": "dcblock",
      "kind": "iirFilter",
      "options": {
        "feedback": [
          1,
          "-0.99935"
        ],
        "feedforward": [
          "0.999675",
          "-0.999675"
        ]
      }
    },
    {
      "id": "vcf",
      "kind": "dsp",
      "options": {
        "code": "// A state-variable filter, built as the Oberheim SEM's is: two integrators in\n// a loop, the second's output fed back to the first's input and the first's\n// fed back through a damping, so one circuit holds a low-pass, a band-pass and\n// a high-pass at once, and the notch is the low-pass and the high-pass added.\n// Mode is which of them is listened to, and it is a knob rather than a switch:\n// low-pass at nothing, band-pass at one, high-pass at two and the notch at\n// three, each two neighbours mixed sample for sample between, so turning it\n// moves the sound through the shapes rather than jumping from one to the\n// next. The SEM's own knob ran from low-pass through the notch to high-pass,\n// with the band-pass on a switch beside it; here all four are on one travel,\n// and it is an input as well, so an LFO, an envelope or a lane can sweep it.\n//\n// Two poles, twelve decibels an octave: gentler than a ladder's four, and a\n// different instrument rather than a lesser one. Nothing takes the bass away\n// as it resonates, because a state-variable low-pass passes what is below its\n// cutoff at its own level whatever the damping — which is why the SEM stays\n// full where a ladder turned up goes thin. And the high-pass sings as the\n// low-pass does, where a biquad's high-pass rings at its Q and then stops.\n//\n// Resonance is the damping taken away: at nothing the filter is as damped as\n// two poles get without ringing, at one there is none left and the loop rings\n// on at the cutoff for ever, and past one the damping has turned round and\n// feeds the ring. What holds it there is a saturating stage in the damping\n// path: for a quiet signal it is a straight line and the damping is what the\n// knob says, and as the band-pass grows the stage gives back less than it is\n// handed, which is more damping. So past one the filter sings at the level\n// where the two meet — a round tone, close to a sine, rather than a ring that\n// grows until something clips it. The SEM itself stops short of singing; this\n// goes the step further, as the ladder does, and does it softly.\n//\n// Both integrators saturate, as a transistor integrator does: what it is\n// handed reaches its capacitor through a curve, so a loud signal finds the\n// filter able to move only so fast, and a driven one thickens and a resonance\n// pushed into it is held down. Their curve is twice as wide as the damping's,\n// which is gently: singing as loud as it goes, the filter has slowed its own\n// integrators by a few per cent and is two thirds of a semitone flat, where\n// with the two curves alike it would be nearly two semitones. Drive is how\n// hard the sound is pushed in, through the input stage's own curve, so pushing\n// it bends and compresses rather than only getting louder; it is kept out of\n// the damping, so how hard the filter is driven does not move the point at\n// which it starts to sing.\n//\n// Solved with no sample's delay round the loop, as Zavalishin's\n// topology-preserving transform does it: the integrators are trapezoidal and\n// the loop is worked out for this sample's own values, so the cutoff lands\n// where the knob says at any height without running at twice the rate as the\n// ladder has to. A curve inside a loop solved that way would need the loop\n// worked out again until it settled; instead each curve is taken as the\n// straight line from nothing to where it stands when the loop is first worked\n// out with no curves at all. That is near enough, costs one more division, and\n// always comes out with an answer: however the lines lean, what the loop is\n// divided by stays well clear of nothing.\n//\n// Every curve here is the same either side of nothing, and still the filter\n// leaves a sawtooth off centre. A curve like that keeps a wave centred only\n// while the wave spends as long at each height as at the same depth below,\n// which a sawtooth does going in and no longer does once the poles have moved\n// its harmonics against each other, and which a narrow pulse never does. The\n// lean grows with the square of the level, and every voice of a chord leans\n// the same way, so a chord adds it up. So the output leaves through a one-pole\n// at 5 Hz, as the analog oscillator's does, which takes the lean off below\n// any note and leaves what is played as it was.\nimport { AtmoProcessor, Rng } from \"atmosynth:dsp\";\n\nfunction clamp(value, low, high) {\n  return value < low ? low : value > high ? high : value;\n}\n\n// A tanh, near enough, as the ladder has it: x(27 + x²) / (27 + 9x²), which\n// leaves the origin at the slope a tanh does and arrives at one at three with\n// no slope left, where it stays. It is arithmetic and nothing else, so the\n// plugin works it out to the same double, which two libraries' tanh need not.\nfunction saturate(value) {\n  return value < -3 ? -1 : value > 3 ? 1 : (value * (27 + value * value)) / (27 + 9 * value * value);\n}\n\n// The same curve over what it is handed: the slope of the straight line from\n// nothing to where the curve is at `value`. One at nothing and less further\n// out, and written so that it divides only by what is past three, so nothing\n// has a slope as well.\nfunction slope(value) {\n  const size = value < 0 ? -value : value;\n  return size > 3 ? 1 / size : (27 + size * size) / (27 + 9 * size * size);\n}\n\n// How hard the damping's stage holds a loud band-pass down: the damping it\n// adds is this times how far its curve has bent. Four lets the loudest it\n// sings, at a resonance of 1.2, reach about seven tenths of full scale.\nconst HOLD = 4;\n// How much wider the integrators' curve is than the damping's.\nconst ROOM = 2;\n\nexport default class AtmosynthSem extends AtmoProcessor {\n  static spec = 1;\n  // Channel 0 of what arrives: a mono source arrives on both sides, and a\n  // stereo one is heard by its left.\n  static inputs = [2];\n  static outputs = [1];\n  // Not smoothed here: a knob's move reaches these already eased, and what is\n  // wired in is followed exactly.\n  static params = {\n    frequency: { min: 20, max: 20000, default: 1200, rate: \"a\", smooth: 0 },\n    // Eight octaves either way, as on the ladder, so an envelope into the\n    // cutoff from a low setting can open the filter the whole way.\n    detune: { min: -9600, max: 9600, default: 0, rate: \"a\", smooth: 0 },\n    resonance: { min: 0, max: 1.2, default: 0.4, rate: \"a\", smooth: 0 },\n    // Into the input stage's curve, and only there.\n    drive: { min: 0.1, max: 10, default: 1, rate: \"a\", smooth: 0 },\n    // 0 low-pass, 1 band-pass, 2 high-pass, 3 notch, and the mixes between.\n    mode: { min: 0, max: 3, default: 0, rate: \"a\", smooth: 0 },\n  };\n\n  constructor() {\n    super();\n    // The two integrators: the band-pass's and the low-pass's.\n    this.s1 = 0;\n    this.s2 = 0;\n    // The cutoff and detune the coefficient below was last worked out for:\n    // not yet any, which no value equals.\n    this.frequency = 0 / 0;\n    this.detune = 0 / 0;\n    this.coefficient = 0;\n    /** The 5 Hz one-pole on the way out, and the two samples it remembers. */\n    this.pole = 1 - (2 * Math.PI * 5) / sampleRate;\n    this.lastRaw = 0;\n    this.centred = 0;\n    // The dither below, drawn from the node's own generator.\n    this.rng = new Rng(this.seed);\n  }\n\n  process(inputs, outputs, parameters) {\n    const channel = outputs[0][0];\n    const source = inputs[0][0];\n    // In a browser's audio thread `sampleRate` is an accessor on the global\n    // scope rather than a variable, so it is read once a call.\n    const contextRate = sampleRate;\n    const ceiling = contextRate * 0.45;\n    const pole = this.pole;\n    let lastRaw = this.lastRaw;\n    let centred = this.centred;\n    let s1 = this.s1;\n    let s2 = this.s2;\n\n    for (let index = 0; index < channel.length; index += 1) {\n      const frequency = parameters.frequency[index];\n      const detune = parameters.detune[index];\n      // A Math.pow and a Math.tan, worked out again only when they would come\n      // out different.\n      if (frequency !== this.frequency || detune !== this.detune) {\n        this.frequency = frequency;\n        this.detune = detune;\n        const hz = clamp(frequency * Math.pow(2, detune / 1200), 20, ceiling);\n        // The integrators' gain, prewarped so the cutoff lands where the knob\n        // says rather than flat of it.\n        this.coefficient = Math.tan((Math.PI * hz) / contextRate);\n      }\n      const g = this.coefficient;\n      // The damping: two at a resonance of nothing, none at one, and past one\n      // a little less than none.\n      const k = 2 - 2 * parameters.resonance[index];\n\n      // What starts it, as on the ladder: an analogue filter is pushed into\n      // singing by its own noise, and this one, handed digital silence, would\n      // sit at exactly nothing for ever. A millionth of full scale is a\n      // hundred and twenty decibels down, and enough to grow into the tone\n      // within a note.\n      const x = saturate(\n        parameters.drive[index] * source[index] + 1e-6 * this.rng.bipolar(),\n      );\n\n      // Where the loop would stand with every curve a straight line.\n      let high = (x - (k + g) * s1 - s2) / (1 + g * (k + g));\n      let band = g * high + s1;\n      // Each curve as the line to where it stands there: the first\n      // integrator's through what reaches it, the second's and the damping's\n      // through the band-pass.\n      const g1 = g * slope(high / ROOM);\n      const g2 = g * slope(band / ROOM);\n      const damping = k + HOLD * (1 - slope(band));\n      // And the loop worked out again through them.\n      high = (x - (damping + g2) * s1 - s2) / (1 + g1 * (damping + g2));\n      band = g1 * high + s1;\n      s1 = band + g1 * high;\n      const low = g2 * band + s2;\n      s2 = low + g2 * band;\n\n      // However far the Mode input pushes it, it stays between the low-pass\n      // and the notch: past either end the mix would run on beyond a shape\n      // into a sound none of the four is.\n      const mode = clamp(parameters.mode[index], 0, 3);\n      // What its curves leave off centre, taken off under 5 Hz.\n      const raw =\n        mode < 1\n          ? low + mode * (band - low)\n          : mode < 2\n            ? band + (mode - 1) * (high - band)\n            : high + (mode - 2) * low;\n      centred = raw - lastRaw + pole * centred;\n      lastRaw = raw;\n      channel[index] = centred;\n    }\n\n    this.s1 = s1;\n    this.s2 = s2;\n    this.lastRaw = lastRaw;\n    this.centred = centred;\n    return true;\n  }\n}\n"
      }
    },
    {
      "id": "track",
      "kind": "gain",
      "options": {}
    },
    {
      "id": "trackGainset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          "0.5",
          "-0.5"
        ]
      }
    },
    {
      "id": "gate",
      "kind": "constantSource",
      "options": {}
    },
    {
      "id": "fenv",
      "kind": "dsp",
      "options": {
        "code": "// The contour of an analog synthesizer: delay, attack, hold, decay, sustain\n// and release, each stage a capacitor charging or discharging rather than a\n// straight line, and a loop that goes back round the first four for as long\n// as the key is held. The vocabulary's own envelope is breakpoints laid down\n// in advance, at the moment a key goes down, by the clock: it can draw a\n// straight line or a ratio and nothing else, and it cannot decide anything\n// by where the shape has got to. An attack that charges from wherever it is\n// until it reaches one, and a loop that comes round again for as long as a\n// hand stays on a key nobody can see the end of, are both decisions of that\n// kind, made a sample at a time.\n//\n// **The attack** charges towards 1.3 and is stopped at one: an RC charge cut\n// off before it flattens, fast off the mark and still moving when it arrives,\n// which is the snap of a hardware envelope that a straight line lacks. Its\n// knob is the time from nothing to one, so from wherever a retrigger caught\n// it, it arrives sooner.\n//\n// **The decay and the release** fall towards their target and a thousandth\n// past it — sixty decibels down — and are stopped on it, so each arrives in\n// a time the knob says rather than approaching for ever. That time is the\n// whole of a fall from one to nothing: the knob sets how fast the capacitor\n// discharges, as an analog envelope's does, so a decay to a sustain of a half,\n// or a release from below full, takes less. A release starts from wherever the\n// key let go of the shape, mid-attack included.\n//\n// **Delay** waits before the attack and **Hold** stays at one after it, both\n// counted in samples. **Loop**, while the key is down, takes the decay back\n// round to the delay and the attack rather than resting at the sustain, so a\n// held key is a slow wave of the contour's own shape; let go, it releases from\n// wherever it was.\n//\n// **The gate** is a level that is one while the key is held, which the module\n// makes from an automation on a constant: the one way a module is told a key\n// went down and came back up. Its last point is the release's time, so the\n// voice is held open for as long as the release lasts and no longer. **What\n// comes out** is the contour times `1 − amount + amount × velocity`, where\n// `velocity` is how hard the key was struck, from nothing to one, and `amount`\n// the Velocity knob; and beside it the same less one, for a gain whose own\n// gain is one to be opened by exactly the contour, from nothing.\n//\n// Every coefficient is worked out again only when the knob it depends on\n// moves, and `sampleRate` is read once a block.\n//\n// Written again in DSP JS, it computes every sample the number it did: a knob\n// not yet seen is held as `0 / 0`, which no reading of it equals, and each\n// output is the one channel the browser gave it.\nimport { AtmoProcessor } from \"atmosynth:dsp\";\n\n/** How far past one the attack aims, as a share of its swing. */\nconst OVERSHOOT = 0.3;\n/** How far past its target a fall aims, and so how close it comes before it is there. */\nconst SETTLE = 0.001;\n/** How many time constants a whole swing takes to arrive, rising and falling. */\nconst RISE = Math.log((1 + OVERSHOOT) / OVERSHOOT);\nconst FALL = Math.log((1 + SETTLE) / SETTLE);\n\nconst IDLE = 0;\nconst DELAY = 1;\nconst ATTACK = 2;\nconst HOLD = 3;\nconst DECAY = 4;\nconst SUSTAIN = 5;\nconst RELEASE = 6;\n\n/** What a knob not yet seen is held as, which no reading of it equals. */\nconst UNSEEN = 0 / 0;\n\nexport default class AtmosynthContour extends AtmoProcessor {\n  static spec = 1;\n  static inputs = [];\n  static outputs = [1, 1];\n  // Not smoothed here: a knob's move reaches these already eased, and the\n  // gate and the velocity are followed exactly.\n  static params = {\n    // One while the key is held, from the module's gate.\n    gate: { min: 0, max: 1, default: 0, rate: \"a\", smooth: 0 },\n    // How hard the key was struck, from the module's note input.\n    velocity: { min: 0, max: 1, default: 0, rate: \"a\", smooth: 0 },\n    // The four times, in milliseconds.\n    delay: { min: 0, max: 10000, default: 0, rate: \"k\", smooth: 0 },\n    attack: { min: 0, max: 10000, default: 5, rate: \"k\", smooth: 0 },\n    hold: { min: 0, max: 10000, default: 0, rate: \"k\", smooth: 0 },\n    decay: { min: 0, max: 10000, default: 600, rate: \"k\", smooth: 0 },\n    sustain: { min: 0, max: 1, default: 0.5, rate: \"k\", smooth: 0 },\n    release: { min: 0, max: 10000, default: 400, rate: \"k\", smooth: 0 },\n    // 0 off, 1 on.\n    loop: { min: 0, max: 1, default: 0, rate: \"k\", smooth: 0 },\n    // How much velocity counts, from nothing to everything.\n    amount: { min: 0, max: 1, default: 0, rate: \"k\", smooth: 0 },\n  };\n\n  constructor() {\n    super();\n    this.stage = IDLE;\n    this.level = 0;\n    /** Samples still to wait in a delay or a hold. */\n    this.left = 0;\n    /** Whether the gate was high a sample ago. */\n    this.open = false;\n    /** The knobs each coefficient was last worked out for, and what it came to. */\n    this.delayMs = UNSEEN;\n    this.delaySamples = 0;\n    this.attackMs = UNSEEN;\n    this.attackCoef = 0;\n    this.attackBase = 0;\n    this.holdMs = UNSEEN;\n    this.holdSamples = 0;\n    this.decayMs = UNSEEN;\n    this.sustain = UNSEEN;\n    this.decayCoef = 0;\n    this.decayBase = 0;\n    this.releaseMs = UNSEEN;\n    this.releaseCoef = 0;\n    this.releaseBase = 0;\n  }\n\n  process(inputs, outputs, parameters) {\n    const shape = outputs[0][0];\n    const opening = outputs[1][0];\n    const gate = parameters.gate;\n    const velocity = parameters.velocity;\n    const rate = sampleRate;\n\n    const delay = parameters.delay[0];\n    if (delay !== this.delayMs) {\n      this.delayMs = delay;\n      this.delaySamples = Math.round((delay * rate) / 1000);\n    }\n    const attack = parameters.attack[0];\n    if (attack !== this.attackMs) {\n      this.attackMs = attack;\n      this.attackCoef = Math.exp(-RISE / ((attack * rate) / 1000));\n      this.attackBase = (1 + OVERSHOOT) * (1 - this.attackCoef);\n    }\n    const hold = parameters.hold[0];\n    if (hold !== this.holdMs) {\n      this.holdMs = hold;\n      this.holdSamples = Math.round((hold * rate) / 1000);\n    }\n    const decay = parameters.decay[0];\n    const sustain = parameters.sustain[0];\n    if (decay !== this.decayMs || sustain !== this.sustain) {\n      this.decayMs = decay;\n      this.sustain = sustain;\n      this.decayCoef = Math.exp(-FALL / ((decay * rate) / 1000));\n      this.decayBase = (sustain - SETTLE) * (1 - this.decayCoef);\n    }\n    const release = parameters.release[0];\n    if (release !== this.releaseMs) {\n      this.releaseMs = release;\n      this.releaseCoef = Math.exp(-FALL / ((release * rate) / 1000));\n      this.releaseBase = -SETTLE * (1 - this.releaseCoef);\n    }\n    const looping = parameters.loop[0] >= 0.5;\n    const amount = parameters.amount[0];\n    const kept = 1 - amount;\n\n    let stage = this.stage;\n    let level = this.level;\n    let left = this.left;\n    for (let index = 0; index < shape.length; index += 1) {\n      // A key down starts the delay from wherever the shape is; a key up\n      // releases it from there.\n      const high = gate[index] >= 0.5;\n      if (high !== this.open) {\n        this.open = high;\n        if (high) {\n          stage = DELAY;\n          left = this.delaySamples;\n        } else if (stage !== IDLE) {\n          stage = RELEASE;\n        }\n      }\n\n      // A stage that ends hands this same sample to the one after it, so a\n      // delay or a hold of nothing costs nothing.\n      if (stage === DELAY) {\n        if (left > 0) left -= 1;\n        else stage = ATTACK;\n      }\n      if (stage === ATTACK) {\n        level = this.attackBase + level * this.attackCoef;\n        if (level >= 1) {\n          level = 1;\n          stage = HOLD;\n          left = this.holdSamples;\n        }\n      } else if (stage === HOLD) {\n        if (left > 0) left -= 1;\n        else stage = DECAY;\n      }\n      if (stage === DECAY) {\n        level = this.decayBase + level * this.decayCoef;\n        if (level <= sustain) {\n          level = sustain;\n          stage = looping ? DELAY : SUSTAIN;\n          left = this.delaySamples;\n        }\n      } else if (stage === SUSTAIN) {\n        level = sustain;\n        if (looping) {\n          stage = DELAY;\n          left = this.delaySamples;\n        }\n      } else if (stage === RELEASE) {\n        level = this.releaseBase + level * this.releaseCoef;\n        if (level <= 0) {\n          level = 0;\n          stage = IDLE;\n        }\n      }\n\n      const value = level * (kept + amount * velocity[index]);\n      shape[index] = value;\n      opening[index] = value - 1;\n    }\n    this.stage = stage;\n    this.level = level;\n    this.left = left;\n    return true;\n  }\n}\n"
      }
    },
    {
      "id": "fdepth",
      "kind": "gain",
      "options": {}
    },
    {
      "id": "fenvAmountset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          "-0.4",
          "0.4"
        ]
      }
    },
    {
      "id": "fenvReleaseset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          100,
          -100
        ]
      }
    },
    {
      "id": "vca",
      "kind": "gain",
      "options": {}
    },
    {
      "id": "level",
      "kind": "gain",
      "options": {}
    },
    {
      "id": "out",
      "kind": "moduleOutput",
      "options": {
        "output": "out"
      }
    }
  ],
  "connections": [
    {
      "from": {
        "node": "one",
        "output": 0
      },
      "to": {
        "node": "sumset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "sumset",
        "output": 0
      },
      "to": {
        "node": "sum",
        "param": "gain"
      }
    },
    {
      "from": {
        "node": "note",
        "output": 0
      },
      "to": {
        "node": "osc1",
        "param": "frequency"
      }
    },
    {
      "from": {
        "node": "osc1",
        "output": 0
      },
      "to": {
        "node": "sum",
        "input": 0
      }
    },
    {
      "from": {
        "node": "note",
        "output": 0
      },
      "to": {
        "node": "osc2",
        "param": "frequency"
      }
    },
    {
      "from": {
        "node": "osc2",
        "output": 0
      },
      "to": {
        "node": "sum",
        "input": 0
      }
    },
    {
      "from": {
        "node": "in",
        "output": 0
      },
      "to": {
        "node": "sum",
        "input": 0
      }
    },
    {
      "from": {
        "node": "sum",
        "output": 0
      },
      "to": {
        "node": "shaper",
        "input": 0
      }
    },
    {
      "from": {
        "node": "shaper",
        "output": 0
      },
      "to": {
        "node": "dcblock",
        "input": 0
      }
    },
    {
      "from": {
        "node": "note",
        "output": 0
      },
      "to": {
        "node": "track",
        "input": 0
      }
    },
    {
      "from": {
        "node": "track",
        "output": 0
      },
      "to": {
        "node": "vcf",
        "param": "frequency"
      }
    },
    {
      "from": {
        "node": "one",
        "output": 0
      },
      "to": {
        "node": "trackGainset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "trackGainset",
        "output": 0
      },
      "to": {
        "node": "track",
        "param": "gain"
      }
    },
    {
      "from": {
        "node": "gate",
        "output": 0
      },
      "to": {
        "node": "fenv",
        "param": "gate"
      }
    },
    {
      "from": {
        "node": "vel",
        "output": 0
      },
      "to": {
        "node": "fenv",
        "param": "velocity"
      }
    },
    {
      "from": {
        "node": "fenv",
        "output": 0
      },
      "to": {
        "node": "fdepth",
        "input": 0
      }
    },
    {
      "from": {
        "node": "fdepth",
        "output": 0
      },
      "to": {
        "node": "vcf",
        "param": "detune"
      }
    },
    {
      "from": {
        "node": "one",
        "output": 0
      },
      "to": {
        "node": "fenvAmountset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "fenvAmountset",
        "output": 0
      },
      "to": {
        "node": "fenv",
        "param": "amount"
      }
    },
    {
      "from": {
        "node": "one",
        "output": 0
      },
      "to": {
        "node": "fenvReleaseset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "fenvReleaseset",
        "output": 0
      },
      "to": {
        "node": "fenv",
        "param": "release"
      }
    },
    {
      "from": {
        "node": "dcblock",
        "output": 0
      },
      "to": {
        "node": "vcf",
        "input": 0
      }
    },
    {
      "from": {
        "node": "vcf",
        "output": 0
      },
      "to": {
        "node": "vca",
        "input": 0
      }
    },
    {
      "from": {
        "node": "vca",
        "output": 0
      },
      "to": {
        "node": "level",
        "input": 0
      }
    },
    {
      "from": {
        "node": "level",
        "output": 0
      },
      "to": {
        "node": "out",
        "input": 0
      }
    }
  ],
  "automation": [
    {
      "id": "amp",
      "label": "Amplitude",
      "target": {
        "node": "vca",
        "param": "gain"
      },
      "breakpoints": [
        {
          "time": 0,
          "value": "0",
          "curve": "step"
        },
        {
          "time": 60,
          "value": "1",
          "curve": "linear"
        },
        {
          "time": 240,
          "value": "0.8",
          "curve": "linear"
        },
        {
          "time": 500,
          "value": "0",
          "curve": "linear"
        }
      ],
      "sustainAt": 2
    },
    {
      "id": "gate",
      "label": "Gate",
      "target": {
        "node": "gate",
        "param": "offset"
      },
      "breakpoints": [
        {
          "time": 0,
          "value": "1",
          "curve": "step"
        },
        {
          "time": 0,
          "value": "0",
          "curve": "step"
        }
      ],
      "sustainAt": 0
    }
  ],
  "parameters": [
    {
      "id": "attack",
      "label": "Attack",
      "range": {
        "min": "0",
        "max": "4000"
      },
      "default": "60",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 1,
          "field": "time"
        },
        {
          "node": "fenv",
          "param": "attack"
        }
      ]
    },
    {
      "id": "decay",
      "label": "Decay reaches sustain at",
      "range": {
        "min": "0",
        "max": "8000"
      },
      "default": "240",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 2,
          "field": "time"
        }
      ]
    },
    {
      "id": "sustain",
      "label": "Sustain level",
      "range": {
        "min": "0",
        "max": "1"
      },
      "default": "0.8",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 2,
          "field": "value"
        }
      ]
    },
    {
      "id": "release",
      "label": "Release ends at",
      "range": {
        "min": "0",
        "max": "12000"
      },
      "default": "500",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 3,
          "field": "time"
        }
      ]
    },
    {
      "id": "cutoff",
      "label": "Brightness (Hz)",
      "range": {
        "min": "20",
        "max": "20000"
      },
      "default": "2000",
      "targets": [
        {
          "node": "vcf",
          "param": "frequency"
        }
      ],
      "scale": "log"
    },
    {
      "id": "emphasis",
      "label": "Emphasis (sings above one)",
      "range": {
        "min": "0",
        "max": "1.2"
      },
      "default": "0.25",
      "targets": [
        {
          "node": "vcf",
          "param": "resonance"
        }
      ]
    },
    {
      "id": "contour",
      "label": "Filter contour (cents)",
      "range": {
        "min": "-9600",
        "max": "9600"
      },
      "default": "2400",
      "targets": [
        {
          "node": "fdepth",
          "param": "gain"
        }
      ]
    },
    {
      "id": "contourDecay",
      "label": "Filter decay (ms for a full fall)",
      "range": {
        "min": "1",
        "max": "10000"
      },
      "default": "700",
      "targets": [
        {
          "node": "fenv",
          "param": "decay"
        }
      ],
      "scale": "log"
    },
    {
      "id": "contourSustain",
      "label": "Filter sustain",
      "range": {
        "min": "0",
        "max": "1"
      },
      "default": "0.6",
      "targets": [
        {
          "node": "fenv",
          "param": "sustain"
        }
      ]
    },
    {
      "id": "drive",
      "label": "Drive",
      "range": {
        "min": "0.1",
        "max": "10"
      },
      "default": "1.5",
      "targets": [
        {
          "node": "vcf",
          "param": "drive"
        }
      ]
    },
    {
      "id": "level",
      "label": "Level",
      "range": {
        "min": "0",
        "max": "2"
      },
      "default": "0.28",
      "targets": [
        {
          "node": "level",
          "param": "gain"
        }
      ]
    },
    {
      "id": "wave",
      "label": "Wave (0 triangle, 1 saw, 2 square, 3 narrow pulse)",
      "range": {
        "min": "0",
        "max": "3"
      },
      "default": "1",
      "targets": [
        {
          "node": "osc1",
          "param": "wave"
        },
        {
          "node": "osc2",
          "param": "wave"
        }
      ]
    },
    {
      "id": "detune1",
      "label": "Detune 1 (cents)",
      "range": {
        "min": "-1200",
        "max": "1200"
      },
      "default": "0",
      "targets": [
        {
          "node": "osc1",
          "param": "detune"
        }
      ]
    },
    {
      "id": "detune2",
      "label": "Detune 2 (cents)",
      "range": {
        "min": "-1200",
        "max": "1200"
      },
      "default": "5",
      "targets": [
        {
          "node": "osc2",
          "param": "detune"
        }
      ]
    }
  ],
  "sampleSlots": [],
  "createdAt": "2026-10-14T00:00:00.000Z"
}