Closed Bug 1831564 Opened 2 years ago Closed 2 years ago

AnalyserNode.getByteFrequencyData() is affected by the sample rate of the output device

Categories

(Core :: Web Audio, defect, P3)

Firefox 112
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: li-peijian, Unassigned)

Details

Attachments

(2 files, 2 obsolete files)

Attached image Screenshot (210).png (obsolete) —

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68

Steps to reproduce:

Change the default format of Windows sound playback device to a different sample rate.
Play audios with Web Audio API and draw frequency graphics with AnalyserNode.getByteFrequencyData().

Actual results:

In different sample rate of the output device, the amount of effective data that AnalyserNode.getByteFrequencyData() returns is different, that makes the peak's width of frequency graphics looks different.

Expected results:

Is this match the API specifications?
I thought this should be same in any output device's any sample rate.

Attached image Screenshot (213).png (obsolete) —
Attached image 屏幕截图(215).png
Attachment #9331821 - Attachment is obsolete: true
Attached image 屏幕截图(216).png
Attachment #9331822 - Attachment is obsolete: true

Reviewing:
https://webaudio.github.io/web-audio-api/#dom-analysernode-getbytefrequencydata

I see there have been some behaviour corrections since we last updated this method, not sure if we were already in line with the expected behaviour:
https://github.com/WebAudio/web-audio-api/issues/2361

Severity: -- → S3
Flags: needinfo?(padenot)
Priority: -- → P3

This is expected. The file you're playing doesn't have frequency content after 20kHz, and you're drawing up to 192kHz.

Per specification the analyzer returns data up to the AudioContext sample-rate / 2 (the Nyquist frequency), which means most of the values are going to be 0, because the audio contains audio data with a frequency up to about 16kHz (looking at the second graph), and you ask to plot up to 192kHz.

Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Flags: needinfo?(padenot)
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: