getWebAudioContextSampleRate function

double getWebAudioContextSampleRate()

Returns the browser's AudioContext sample rate — this is the EXACT sample rate the system audio hardware uses. No guessing.

Standard values: 44100 (most systems) or 48000 (pro audio cards). The browser normalizes all audio streams to this rate.

Implementation

double getWebAudioContextSampleRate() {
  try {
    final ctx = web.AudioContext();
    final rate = ctx.sampleRate;
    ctx.close();
    return rate;
  } catch (_) {
    return 48000.0; // Safe fallback for web
  }
}