v151 · Web Audio API · AudioWorklet

AudioWorklet Quantum Size

When you change renderSizeHint on an AudioContext, every AudioWorkletProcessor.process() call on that context receives a different number of input and output frames. This demo measures that directly — and visualises how larger quanta mean fewer but heavier process calls per second.

Checking AudioWorklet and configurable quantum support…

measure process() call size

renderSizeHint:
frames per process() call
run probe to measure
process() calls / second
at 44100 Hz sample rate
actual renderQuantumSize
from AudioContext.renderQuantumSize
requested hint
renderSizeHint passed to constructor
Click "Run probe" to create an AudioContext and measure the worklet quantum size.

code

// probe-processor.js (registered as AudioWorkletProcessor)
class ProbeProcessor extends AudioWorkletProcessor {
  constructor() {
    super();
    this._count = 0;
  }

  process(inputs, outputs) {
    // outputs[0][0] is a Float32Array.
    // Its length IS the render quantum for this context.
    const framesThisCall = outputs[0]?.[0]?.length ?? 0;

    if (this._count === 0) {
      // Send frame size back to main thread on first call
      this.port.postMessage({ framesPerCall: framesThisCall });
    }
    this._count++;
    return true; // keep alive
  }
}
registerProcessor('probe-processor', ProbeProcessor);

// ── Main thread ──
// Chrome 151+: renderSizeHint controls the quantum
const ctx = new AudioContext({ renderSizeHint: 512 }); // or 'default', 'hardware'

await ctx.audioWorklet.addModule('./probe-processor.js');
const node = new AudioWorkletNode(ctx, 'probe-processor');

node.port.onmessage = ({ data }) => {
  console.log('frames per process():', data.framesPerCall);
  // ctx.renderQuantumSize also exposes this value directly
  console.log('renderQuantumSize:', ctx.renderQuantumSize);
};

node.connect(ctx.destination);
await ctx.resume();

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗