Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Web Audio API: outputChannelCount not working when I inherit from AudioWorkletProcessor

I have the following example. I try to pass the options parameter via calling super(...). When I do this, I don't get 2 output channels as I specified, instead I only get 1 output channel.

class Processor extends AudioWorkletProcessor {
    constructor() {
        super({outputChannelCount: [2]});
    }

    process(inputs, outputs, parameters) {
        console.log("output channels: ", outputs[0].length);
        return true;
    }
}

registerProcessor('processor', Processor);

When I try the same passing the options to the AudioWorkletNode instead, like in the following example, it works as expected.

    let audioContext = new AudioContext();
    (async () => {
        await audioContext.audioWorklet.addModule('processor.js');
        audioWorkletNode = new AudioWorkletNode(audioContext, 'processor', {outputChannelCount: [2]});
        audioWorkletNode.connect(audioContext.destination);
    })();

This is not working in any browser I tried.

Am I doing something wrong? Is this a bug? Is there something in the Web Audio API specification that I am missing here?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think what you describe is expected. The constructor of an AudioWorkletProcessor doesn't take any arguments as defined by the IDL definition here:

https://webaudio.github.io/web-audio-api/#AudioWorkletProcessor

The options that you pass to the AudioWorkletNode constructor on the main thread get stored as something called the pending processor construction data. They get applied automatically and there is no way to change them from within the processor.

I guess this is to make sure the AudioWorkletNode and its corresponding AudioWorkletProcessor always have the same configuration. If you could change the configuration within the processor the AudioWorkletNode would be out of sync until the information travelled back again.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!