Non-Partisan Magicians

    soundbank-dipper

    0.1.2 • Public • Published

    soundbank-dipper

    A global side-chain compressor for the Web Audio API. Modulate the amplitude of AudioNodes based on the amplitude of other AudioNodes.

    A dipper is global to the current audioContext. If you need separate dipper contexts, use var newContext = Object.create(audioContext).

    Intended for use as a processor in soundbank, but it is compatible with any Web Audio API AudioNode set up.

    Install

    $ npm install soundbank-dipper

    API

    var Dipper = require('soundbank-dipper')

    Dipper(audioContext)

    Create an AudioNode instance. In "source" mode, audio flows straight through, but is used to modulate the amplitude of all dipper nodes in "modulate" mode.

    node.mode (get/set)

    Either 'source', or 'modulate'.

    node.ratio (AudioParam)

    Amount of dip effect to apply. Defaults to 1.

    Example

    Side-chain background oscillator against source:

    var Dipper = require('soundbank-dipper')
     
    var audioContext = new webkitAudioContext()
     
    var sourceDipper = Dipper(audioContext)
    sourceDipper.mode = 'source'
     
    var sidechainDipper = Dipper(audioContext)
    sidechainDipper.mode = 'modulator'
     
    sourceDipper.connect(audioContext.destination)
    sidechainDipper.connect(audioContext.destination)
     
    var background = audioContext.createOscillator()
    background.type = 'sawtooth'
    background.connect(sidechainDipper)
    background.start()
     
    setInterval(function(){
      var source = audioContext.createOscillator()
      source.type = 'square'
      source.detune.value = -2400
      source.connect(sourceDipper)
      source.start()
      source.stop(audioContext.currentTime + 0.5)
    }, 2000)

    Install

    npm i soundbank-dipper

    DownloadsWeekly Downloads

    11

    Version

    0.1.2

    License

    ISC

    Last publish

    Collaborators

    • mmckegg