{
  "$type": "at.atmosynth.module",
  "descriptionVersion": 1,
  "moduleId": "instrument-strings",
  "versionKey": "3",
  "name": "Strings",
  "description": "A bowed section: three sawtooths spread apart and wandering against each other through an Oberheim's kind of filter, slow to arrive and slow to leave. Emphasis is 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": "osc3",
      "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": "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": "note",
        "output": 0
      },
      "to": {
        "node": "osc3",
        "param": "frequency"
      }
    },
    {
      "from": {
        "node": "osc3",
        "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": "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": 260,
          "value": "1",
          "curve": "linear"
        },
        {
          "time": 560,
          "value": "0.78",
          "curve": "linear"
        },
        {
          "time": 1360,
          "value": "0",
          "curve": "linear"
        }
      ],
      "sustainAt": 2
    }
  ],
  "parameters": [
    {
      "id": "attack",
      "label": "Attack",
      "range": {
        "min": "0",
        "max": "4000"
      },
      "default": "260",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 1,
          "field": "time"
        }
      ]
    },
    {
      "id": "decay",
      "label": "Decay reaches sustain at",
      "range": {
        "min": "0",
        "max": "8000"
      },
      "default": "560",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 2,
          "field": "time"
        }
      ]
    },
    {
      "id": "sustain",
      "label": "Sustain level",
      "range": {
        "min": "0",
        "max": "1"
      },
      "default": "0.78",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 2,
          "field": "value"
        }
      ]
    },
    {
      "id": "release",
      "label": "Release ends at",
      "range": {
        "min": "0",
        "max": "12000"
      },
      "default": "1360",
      "targets": [
        {
          "automation": "amp",
          "breakpoint": 3,
          "field": "time"
        }
      ]
    },
    {
      "id": "cutoff",
      "label": "Brightness (Hz)",
      "range": {
        "min": "20",
        "max": "20000"
      },
      "default": "4000",
      "targets": [
        {
          "node": "vcf",
          "param": "frequency"
        }
      ],
      "scale": "log"
    },
    {
      "id": "emphasis",
      "label": "Emphasis (sings above one)",
      "range": {
        "min": "0",
        "max": "1.2"
      },
      "default": "0.1",
      "targets": [
        {
          "node": "vcf",
          "param": "resonance"
        }
      ]
    },
    {
      "id": "drive",
      "label": "Drive",
      "range": {
        "min": "0.1",
        "max": "10"
      },
      "default": "1",
      "targets": [
        {
          "node": "vcf",
          "param": "drive"
        }
      ]
    },
    {
      "id": "level",
      "label": "Level",
      "range": {
        "min": "0",
        "max": "2"
      },
      "default": "0.29",
      "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"
        },
        {
          "node": "osc3",
          "param": "wave"
        }
      ]
    },
    {
      "id": "detune1",
      "label": "Detune 1 (cents)",
      "range": {
        "min": "-1200",
        "max": "1200"
      },
      "default": "-14",
      "targets": [
        {
          "node": "osc1",
          "param": "detune"
        }
      ]
    },
    {
      "id": "detune2",
      "label": "Detune 2 (cents)",
      "range": {
        "min": "-1200",
        "max": "1200"
      },
      "default": "0",
      "targets": [
        {
          "node": "osc2",
          "param": "detune"
        }
      ]
    },
    {
      "id": "detune3",
      "label": "Detune 3 (cents)",
      "range": {
        "min": "-1200",
        "max": "1200"
      },
      "default": "15",
      "targets": [
        {
          "node": "osc3",
          "param": "detune"
        }
      ]
    }
  ],
  "sampleSlots": [],
  "createdAt": "2026-10-14T00:00:00.000Z"
}