Created
January 8, 2014 22:07
-
-
Save fand/8325352 to your computer and use it in GitHub Desktop.
Panner node alternative for Web Audio API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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