WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.04k stars 165 forks source link

Unclearness regarding the DC-offset in PeriodicWave #2530

Open dd-pardal opened 1 year ago

dd-pardal commented 1 year ago

Describe the issue

Section 1.28.3.1 states that the element of the [[real]] array at index 0 is the DC-offset but the formula for the waveform in section 1.28.4 doesn't depend on it. Is this value being purposefully ignored? If so, adding a note about it in the spec would be helpful.

Where Is It

Section 1.28.

Additional Information

Firefox and Chromium seem to ignore this value.

padenot commented 1 year ago

If I remember correctly, being able to DC-offset is intended, back when the PeriodicWave object was not really specified. We when wrote the formula, but must have made a mistake there, dropping the DC-offset part.

Chrome and Firefox currently ignore the value (specifically, set the first real and imaginary coefficient to 0 before doing the inverse Fourier transform), but could use it.

It seems somewhat useful for control signal at least (where there's no dynamic range concerns, and can go outside of [-1.0, 1.0]).

padenot commented 11 months ago

This is correctly specified in https://webaudio.github.io/web-audio-api/#PeriodicWave-constructors (step 3.), and we can't change it now. Authors can use the ConstantSourceNode to add a DC-offset, and we'll change the spec text to make it clear that this cannot produce a DC-Offset.