WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.05k stars 167 forks source link

Using AudioWorkletNode to control GainNode doesn't sound correct #2111

Closed chaosprint closed 4 years ago

chaosprint commented 4 years ago
    window.actx = new window.AudioContext()
    await window.actx.audioWorklet.addModule('worklet/test-processor.js')

    let oscillatorNode = window.actx.createOscillator()
    oscillatorNode.start()

    let gainNode =  new GainNode(window.actx)

    let lfoNode = new AudioWorkletNode(window.actx, 'test-processor')
    lfoNode.connect(gainNode.gain) // here is the problem

    oscillatorNode.connect(gainNode)
    gainNode.connect(window.actx.destination)
class TestProcessor extends AudioWorkletProcessor {
    process (inputs, outputs, parameters) {
      const output = outputs[0]
      output.forEach(channel => {
        for (let i = 0; i < channel.length; i++) {
          channel[i] = Math.random() * 2 - 1 // if change to 0.01, it doesn't work correctly either
        }
      })
      return true
    }
  }

 registerProcessor('test-processor', TestProcessor)
rtoy commented 4 years ago

This is not a bug in the spec. Please use stackoverflow, slack, or other channel.

This is for tracking issues in the webaudio spec itself.