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)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    17
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    17
  • 0.1.1
    0
  • 0.1.0
    1
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i soundbank-dipper

Weekly Downloads

18

Version

0.1.2

License

ISC

Last publish

Collaborators

  • mmckegg