mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
20 lines
555 B
JavaScript
20 lines
555 B
JavaScript
const applyCompressor = () => {
|
|
const audioContext = new AudioContext();
|
|
|
|
let compressor = audioContext.createDynamicsCompressor();
|
|
compressor.threshold.value = -50;
|
|
compressor.ratio.value = 12;
|
|
compressor.knee.value = 40;
|
|
compressor.attack.value = 0;
|
|
compressor.release.value = 0.25;
|
|
|
|
const source = audioContext.createMediaElementSource(document.querySelector("video"));
|
|
|
|
source.connect(compressor);
|
|
compressor.connect(audioContext.destination);
|
|
};
|
|
|
|
module.exports = () => document.addEventListener('apiLoaded', () => {
|
|
applyCompressor();
|
|
})
|