Skip to content

Instantly share code, notes, and snippets.

@fand
Created January 8, 2014 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fand/8325352 to your computer and use it in GitHub Desktop.
Save fand/8325352 to your computer and use it in GitHub Desktop.
Panner node alternative for Web Audio API
class @Panner
constructor: (@ctx) ->
@in = @ctx.createChannelSplitter(2)
@out = @ctx.createChannelMerger(2)
@l = @ctx.createGain()
@r = @ctx.createGain()
@in.connect(@l, 0)
@in.connect(@r, 1)
@l.connect(@out, 0, 0)
@r.connect(@out, 0, 1)
@setPosition(0.5)
connect: (dst) -> @out.connect(dst)
setPosition: (@pos) ->
@l.gain.value = @pos
@r.gain.value = 1.0 - @pos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment