Skip to content

AudioContext behavior differing across browsersΒ #1019

@giulianopenido

Description

@giulianopenido

I've encountered two cross-browser inconsistencies when using standardized-audio-context that seem to defeat the purpose of the library's cross-browser standardization goal. It also happens using these native features, so I am not sure if it is a bug.

Environment

Library version: 25.3.77
Browsers tested: Chrome (latest), Firefox (latest)

  1. Issue: AudioContext with custom sampleRate fails in Firefox

When creating an AudioContext with a custom sample rate:

import { AudioContext } from 'standardized-audio-context';

const audioContext = new AudioContext({ sampleRate: 16000 });

Expected behavior: The AudioContext should be created successfully and handle sample rate conversion internally when connecting to MediaStreams with different sample rates.
Actual behavior: Firefox throws an error because the AudioContext sample rate differs from the MediaStream sample rate. Chrome and other browsers handle this gracefully.

  1. Issue: channelCount on MediaStreamAudioDestinationNode ignored in Firefox

When creating a MediaStreamAudioDestinationNode and setting channelCount to 1:

const destination = audioContext.createMediaStreamDestination();
destination.channelCount = 1;
// or
destination.channelCountMode = 'explicit';
destination.channelCount = 1;

Expected behavior: The output MediaStream should be mono (1 channel).
Actual behavior:

βœ… Chrome: Works correctly, outputs mono audio
❌ Firefox: Ignores the setting and continues outputting stereo audio

Questions

Is this a known limitation of the library?
Are there any recommended workarounds for achieving consistent behavior across browsers?
Should the library normalize these behaviors, or is this considered out of scope?

Thank you for maintaining this library! πŸ™

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions