Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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