w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.
https://w3c.github.io/webcodecs/
Other
978 stars 136 forks source link

Offer resampling of decoded audio #178

Open chcunningham opened 3 years ago

chcunningham commented 3 years ago

Request from audio industry pros. Could even be done per-decode() to create ramping effects. Leverage in-decoder resampling where available.

padenot commented 3 years ago

As mentioned during the call, this is rather uncommon, but is apparently possible in some framework. Authors can of course resample themselves (using the Web Audio API or their WASM DSP).

chcunningham commented 3 years ago

Triage note: marking 'extension' as resampling would be offered via some new method or API (e.g. AudioData.resampleTo() or interface AudioResampler{ ...}).

padenot commented 3 years ago

Agreed.

I'll just add in passing that the first API proposal can't work because any resampler except linear resampling (which has unacceptable audio quality) is stateful.

dalecurtis commented 3 years ago

IMHO, we don't want this since it's a high level concept at odds with the low level nature of WebCodecs.

Instead authors should use an OfflineAudioContext to handle resampling or channel mixing. You generally do not want to resample a single frame of audio since the kernel preserves state across frames as it moves over the resampling window.