{
  "$type": "at.atmosynth.module",
  "descriptionVersion": 1,
  "moduleId": "instrument-bass",
  "versionKey": "3",
  "name": "Bass",
  "description": "Low and solid, as a Moog plays it: a square against a triangle an octave below, both starting every note in step, through a mixer that leans on them and a ladder filter that its own contour opens on each note, further the harder a key is struck. Closed down and short. 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": "osc1Phaseset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          -1,
          1
        ]
      }
    },
    {
      "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": "osc2level",
      "kind": "gain",
      "options": {}
    },
    {
      "id": "osc2Waveset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          1,
          -1
        ]
      }
    },
    {
      "id": "osc2Phaseset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          -1,
          1
        ]
      }
    },
    {
      "id": "osc2levelGainset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          "0.2",
          "-0.2"
        ]
      }
    },
    {
      "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 ladder filter: four poles, and a feedback around them deep enough that the\n// filter sings on its own. The node vocabulary cannot reach it — a\n// BiquadFilter is linear and unconditionally stable, so however far its Q is\n// pushed it rings after something excites it and then stops. The filters this\n// one is modelled on do not stop: past the point where the feedback makes up\n// for what the four poles take off, they hold a tone of their own at the\n// cutoff, and on those instruments that tone is played rather than avoided.\n//\n// Four one-pole lowpasses in series, the last one's output subtracted from what\n// goes in. A one-pole turns the signal an eighth of a cycle at its own cutoff,\n// so at the cutoff the four together are half a cycle round and the\n// subtraction has become an addition; each one also takes the level down to\n// about seven tenths there, so a feedback of four exactly makes up for the four\n// of them. That is what Resonance is scaled against: below one the filter\n// rings, at one it is on the edge, above it it sings.\n//\n// Every stage saturates, as every stage of a transistor ladder does. A stage\n// there is a pair of transistors charging a capacitor, and the current they can\n// push into it is the difference of two tanh curves, one of what arrives and\n// one of what the capacitor already holds. So each pole here moves by the tanh\n// of its input less the tanh of where it stands. For a quiet signal a tanh is\n// the straight line it starts as, so a quiet signal meets four plain poles. A\n// loud one finds every stage able to move only so fast, so a driven filter\n// thickens and compresses through all four rather than clipping at the door,\n// and a resonance pushed into it is held down by every stage it goes round.\n// What holds a tone that sings on its own at a level, rather than doubling\n// every cycle until it is a square, is all four of them.\n//\n// The output is taken after the fourth pole, or the third, second or first —\n// 24, 18, 12 or 6 decibels an octave — and the feedback after the fourth\n// whichever it is. That is how the Sub 37 does it: the loop stays four poles\n// round, so Resonance means the same at every slope and only what is listened\n// to moves. Nothing makes up the bass the feedback takes away, so the more it\n// resonates the thinner the low end, which is the sound and not a fault.\n//\n// Version 5 is this filter with the feedback a sample behind, and each pole's\n// tanh of where it stands read from before the sample too, run twice a sample\n// to halve what that costs. Up high a sample is still a large part of a\n// cycle, and both delays turn the loop half a cycle round below the cutoff,\n// which is where it sang: 44 cents flat at 440 Hz just past one, 160 at 2 kHz,\n// 400 at 6 kHz, and singing from under 0.9 at 2 kHz rather than from one.\n// Version 6 is solved with no sample's delay anywhere round the loop, as\n// filter-sem's is: the poles are trapezoidal and the chain, the feedback and\n// every curve in it, is worked out for this sample's own values, once a\n// sample. So it sings at the cutoff the knob names, from one, at the same\n// level at any height. What its curves do to the tone it sings is the\n// ladder's own, and the same at every height: dragged a little flat as it\n// swells, as version 5's is low down.\n//\n// Each curve is taken as the straight line from nothing to where it stands,\n// which makes the chain one that can be worked out in a line: each pole a\n// share of what arrives plus what it holds, so the last a share of what goes\n// into the first plus what the four hold, and the feedback folded into that.\n// The lines are the last sample's to begin with. Through them the chain says\n// where the sound goes in; the four poles are followed from there, each handed\n// the curve of what arrives as it is, and each line moved to where its curve\n// now stands; and the two are done once more. Every divisor is one plus things\n// that cannot be negative, so there is always an answer.\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: x(27 + x²) / (27 + 9x²), which leaves the origin at the\n// slope a tanh does and arrives at one at three with no slope left, where it\n// stays — taken as the slope of the straight line from nothing to where it is\n// at `value`: one at nothing and less further out, written so it divides only\n// by what is past three. It is a few multiplications and one division where\n// Math.tanh is a call, and it is arithmetic and nothing else, so the plugin\n// works it out to the same double, which two libraries' tanh need not do.\nfunction slope(value) {\n  const size = Math.abs(value);\n  return size > 3 ? 1 / size : (27 + size * size) / (27 + 9 * size * size);\n}\n\nexport default class AtmosynthLadder 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, so an envelope into the cutoff from a low\n    // 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 first tanh, and only there: the feedback is left alone, so how\n    // hard the filter is driven does not move the point at which it starts to\n    // sing.\n    drive: { min: 0.1, max: 10, default: 1, rate: \"a\", smooth: 0 },\n    // Which pole the output is taken after, by the Slope choice's position:\n    // 24, 18, 12 and 6 decibels an octave are the fourth, third, second and\n    // first. Rounded, since a choice turned by a controller glides between\n    // positions on its way to one.\n    slope: { min: 0, max: 3, default: 0, rate: \"k\", smooth: 0 },\n  };\n\n  constructor() {\n    super();\n    // The four poles' integrators, first to last.\n    this.s1 = 0;\n    this.s2 = 0;\n    this.s3 = 0;\n    this.s4 = 0;\n    // Each curve's line, as the last sample left it: c0 the curve of what\n    // goes into the first pole, and c1 to c4 the curve of each pole, which it\n    // moves less by and the next is handed. Straight before anything arrives.\n    this.c0 = 1;\n    this.c1 = 1;\n    this.c2 = 1;\n    this.c3 = 1;\n    this.c4 = 1;\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 tap = clamp(Math.round(parameters.slope[0]), 0, 3);\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    let s3 = this.s3;\n    let s4 = this.s4;\n    let c0 = this.c0;\n    let c1 = this.c1;\n    let c2 = this.c2;\n    let c3 = this.c3;\n    let c4 = this.c4;\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      const k = 4 * parameters.resonance[index];\n\n      // What starts it. An analogue filter is pushed into oscillation by its own\n      // noise; this one, handed digital silence, would sit at exactly zero for\n      // ever — and a filter that sings only once something else has sounded is\n      // not the thing being modelled. A millionth of full scale is a hundred and\n      // twenty decibels down, inaudible on its own and enough to grow into the\n      // tone within a note.\n      const x = parameters.drive[index] * source[index] + 1e-6 * this.rng.bipolar();\n\n      let y1 = 0;\n      let y2 = 0;\n      let y3 = 0;\n      let y4 = 0;\n      // Twice, both at this sample's moment: through the last sample's lines,\n      // then through the lines that puts each curve at.\n      for (let pass = 0; pass < 2; pass += 1) {\n        // A pole stands at what it holds, plus g of the curve of what\n        // arrives, less g of its own curve: through the lines, what it holds\n        // plus g of what arrives along its line, over one plus g of its own.\n        const r1 = 1 / (1 + g * c1);\n        const r2 = 1 / (1 + g * c2);\n        const r3 = 1 / (1 + g * c3);\n        const r4 = 1 / (1 + g * c4);\n        const a1 = g * c0 * r1;\n        const a2 = g * c1 * r2;\n        const a3 = g * c2 * r3;\n        const a4 = g * c3 * r4;\n        // So the last pole is a share of what goes into the first plus what\n        // the chain holds, and the feedback from it folds into what goes in.\n        const share = a1 * a2 * a3 * a4;\n        const held = ((s1 * r1 * a2 + s2 * r2) * a3 + s3 * r3) * a4 + s4 * r4;\n        const u = (x - k * held) / (1 + k * share);\n        // The four followed from there, each handed the curve of what\n        // arrives as it is, and each line moved to where its curve stands.\n        c0 = slope(u);\n        y1 = (s1 + g * c0 * u) * r1;\n        c1 = slope(y1);\n        y2 = (s2 + g * c1 * y1) * r2;\n        c2 = slope(y2);\n        y3 = (s3 + g * c2 * y2) * r3;\n        c3 = slope(y3);\n        y4 = (s4 + g * c3 * y3) * r4;\n        c4 = slope(y4);\n      }\n      s1 = 2 * y1 - s1;\n      s2 = 2 * y2 - s2;\n      s3 = 2 * y3 - s3;\n      s4 = 2 * y4 - s4;\n\n      // What its curves leave off centre, taken off under 5 Hz.\n      const raw = tap === 0 ? y4 : tap === 1 ? y3 : tap === 2 ? y2 : y1;\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.s3 = s3;\n    this.s4 = s4;\n    this.c0 = c0;\n    this.c1 = c1;\n    this.c2 = c2;\n    this.c3 = c3;\n    this.c4 = c4;\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.5",
          "0.5"
        ]
      }
    },
    {
      "id": "fenvReleaseset",
      "kind": "waveShaper",
      "options": {
        "curve": [
          250,
          -250
        ]
      }
    },
    {
      "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": "one",
        "output": 0
      },
      "to": {
        "node": "osc1Phaseset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "osc1Phaseset",
        "output": 0
      },
      "to": {
        "node": "osc1",
        "param": "phase"
      }
    },
    {
      "from": {
        "node": "note",
        "output": 0
      },
      "to": {
        "node": "osc2",
        "param": "frequency"
      }
    },
    {
      "from": {
        "node": "osc2",
        "output": 0
      },
      "to": {
        "node": "osc2level",
        "input": 0
      }
    },
    {
      "from": {
        "node": "osc2level",
        "output": 0
      },
      "to": {
        "node": "sum",
        "input": 0
      }
    },
    {
      "from": {
        "node": "one",
        "output": 0
      },
      "to": {
        "node": "osc2Waveset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "osc2Waveset",
        "output": 0
      },
      "to": {
        "node": "osc2",
        "param": "wave"
      }
    },
    {
      "from": {
        "node": "one",
        "output": 0
      },
      "to": {
        "node": "osc2Phaseset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "osc2Phaseset",
        "output": 0
      },
      "to": {
        "node": "osc2",
        "param": "phase"
      }
    },
    {
      "from": {
        "node": "one",
        "output": 0
      },
      "to": {
        "node": "osc2levelGainset",
        "input": 0
      }
    },
    {
      "from": {
        "node": "osc2levelGainset",
        "output": 0
      },
      "to": {
        "node": "osc2level",
        "param": "gain"
      }
    },
    {
      "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": 4,
          "value": "1",
          "curve": "linear"
        },
        {
          "time": 144,
          "value": "0.5",
          "curve": "linear"
        },
        {
          "time": 284,
          "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": "4",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 1,
          "field": "time"
        },
        {
          "node": "fenv",
          "param": "attack"
        }
      ]
    },
    {
      "id": "decay",
      "label": "Decay reaches sustain at",
      "range": {
        "min": "0",
        "max": "8000"
      },
      "default": "144",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 2,
          "field": "time"
        }
      ]
    },
    {
      "id": "sustain",
      "label": "Sustain level",
      "range": {
        "min": "0",
        "max": "1"
      },
      "default": "0.5",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 2,
          "field": "value"
        }
      ]
    },
    {
      "id": "release",
      "label": "Release ends at",
      "range": {
        "min": "0",
        "max": "12000"
      },
      "default": "284",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 3,
          "field": "time"
        }
      ]
    },
    {
      "id": "cutoff",
      "label": "Brightness (Hz)",
      "range": {
        "min": "20",
        "max": "20000"
      },
      "default": "900",
      "targets": [
        {
          "node": "vcf",
          "param": "frequency"
        }
      ],
      "scale": "log"
    },
    {
      "id": "emphasis",
      "label": "Emphasis (sings above one)",
      "range": {
        "min": "0",
        "max": "1.2"
      },
      "default": "0.3",
      "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": "300",
      "targets": [
        {
          "node": "fenv",
          "param": "decay"
        }
      ],
      "scale": "log"
    },
    {
      "id": "contourSustain",
      "label": "Filter sustain",
      "range": {
        "min": "0",
        "max": "1"
      },
      "default": "0.2",
      "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.71",
      "targets": [
        {
          "node": "level",
          "param": "gain"
        }
      ]
    },
    {
      "id": "wave",
      "label": "Wave (0 triangle, 1 saw, 2 square, 3 narrow pulse)",
      "range": {
        "min": "0",
        "max": "3"
      },
      "default": "2",
      "targets": [
        {
          "node": "osc1",
          "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": "-1200",
      "targets": [
        {
          "node": "osc2",
          "param": "detune"
        }
      ]
    }
  ],
  "sampleSlots": [],
  "createdAt": "2026-10-14T00:00:00.000Z"
}