• Jump To … +
    index.js conga.js cowbell.js hihat.js kick.js mini.js monosynth.js pluck.js snare.js tom.js tonewheel.js delay.js feedback-comb-filter.js filter.js gain-envelope.js gain.js lfo.js mono-buffer.js noise.js osc-bank.js osc.js pulse.js sample.js soft-clipper.js source.js vca.js vcf.js vco.js wave-shaper.js synth.js
  • ¶

    Snare

    import { instrument } from "../synth"
    import Osc from "../kit/osc"
    import Noise from "../kit/noise"
    import Filter from "../kit/filter"
    import Gain from "../kit/gain"
    import GainEnvelope from "../kit/gain-envelope"
  • ¶

    A snare modeled after the 808 design

    /**
     * Create the Snare
     */
    export function Snare (ac, state) {
      state = Object.assign({}, Snare.defaults, state)
  • ¶

    Architecture

    808 snare

      const snare = instrument(ac, {
  • ¶

    The snappy oscillators

        osc1: [Osc, "oscEnv"],
        osc2: [Osc, "oscEnv"],
  • ¶

    The AD envelope for the oscillators

        oscEnv: [GainEnvelope, "amp"],
  • ¶

    White noise generator

        noise: [Noise, "noiseFilter"],
  • ¶

    The noise filter

        noiseFilter: [Filter, "noiseEnv"],
  • ¶

    The AD envelope for the noise

        noiseEnv: [GainEnvelope, "amp"],
  • ¶

    Output

        amp: [Gain, "output"],
      }).update(state)
    
      snare.trigger = (time) => {
        snare.oscEnv.trigger(time)
        snare.noiseEnv.trigger(time)
      }
    
      return snare
    }
    
    Snare.defaults = {
      osc1: {
        type: "sine",
        frequency: 238,
      },
      osc2: {
        type: "sine",
        frequency: 476,
      },
      oscEnv: {
        peak: 0.4,
        attack: 0.01,
        decay: 0.1,
      },
      noise: {
        type: "white",
      },
      noiseFilter: {
        type: "highpass",
        frequency: 4000,
      },
      noiseEnv: {
        attack: 0.01,
        decay: 0.08,
      },
      amp: {
        gain: 0.5,
      },
    }
    
    export default Snare