mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 11:01:45 +00:00
change plugin system
This commit is contained in:
25
src/plugins/audio-compressor.ts
Normal file
25
src/plugins/audio-compressor.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { createPlugin } from '@/utils';
|
||||
|
||||
export default createPlugin({
|
||||
name: 'Audio Compressor',
|
||||
description: '',
|
||||
|
||||
renderer() {
|
||||
document.addEventListener(
|
||||
'audioCanPlay',
|
||||
({ detail: { audioSource, audioContext } }) => {
|
||||
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;
|
||||
|
||||
audioSource.connect(compressor);
|
||||
compressor.connect(audioContext.destination);
|
||||
},
|
||||
{ once: true, passive: true },
|
||||
);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user