Skip to content

Instantly share code, notes, and snippets.

@fand
Created January 8, 2014 15:53
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/8318958 to your computer and use it in GitHub Desktop.
Save fand/8318958 to your computer and use it in GitHub Desktop.
Delay effect in Web Audio API, but it kills Chrome...
class @FX
constructor: (@ctx) ->
@in = @ctx.createGain()
@in.gain.value = 1.0
@out = @ctx.createGain()
@out.gain.value = 1.0
@view = new FXView(this)
connect: (dst) -> @out.connect(dst)
disconnect: () -> @out.disconnect()
setInput: (d) -> @in.gain.value = d
setOutput: (d) -> @out.gain.value = d
class @Delay extends @FX
constructor: (@ctx) ->
super(@ctx)
@delay = @ctx.createDelay()
@delay.delayTime.value = 0.23
@lofi = @ctx.createBiquadFilter()
@lofi.type = "peaking"
@lofi.frequency.value = 12
@lofi.Q.value = 0.0 # range is [0.0, 5.0]
@lofi.gain.value = 1.0
@feedback = @ctx.createGain()
@feedback.gain.value = 0.2
@in.connect(@lofi)
@lofi.connect(@delay)
@delay.connect(@out)
@delay.connect(@feedback)
@feedback.connect(@lofi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment