mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-09 01:31:46 +00:00
20 lines
580 B
JavaScript
20 lines
580 B
JavaScript
const applyCompressor = (e) => {
|
|
const { audioContext } = e.detail;
|
|
|
|
const compressor = audioContext.createDynamicsCompressor();
|
|
compressor.threshold.value = -50;
|
|
compressor.ratio.value = 12;
|
|
compressor.knee.value = 40;
|
|
compressor.attack.value = 0;
|
|
compressor.release.value = 0.25;
|
|
|
|
e.detail.audioSource.connect(compressor);
|
|
compressor.connect(audioContext.destination);
|
|
};
|
|
|
|
module.exports = () =>
|
|
document.addEventListener('audioCanPlay', applyCompressor, {
|
|
once: true, // Only create the audio compressor once, not on each video
|
|
passive: true,
|
|
});
|