diff options
Diffstat (limited to 'scripts/volume_processor.js')
| -rw-r--r-- | scripts/volume_processor.js | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/scripts/volume_processor.js b/scripts/volume_processor.js deleted file mode 100644 index 9765e7b..0000000 --- a/scripts/volume_processor.js +++ /dev/null @@ -1,27 +0,0 @@ -class VolumeProcessor extends AudioWorkletProcessor { - constructor() { - super(); - this.volume = 0; - } - - process(inputs) { - const input = inputs[0]; - if (input.length > 0) { - const channelData = input[0]; - let sum = 0; - - for (let i = 0; i < channelData.length; i++) { - sum += channelData[i] * channelData[i]; - } - - this.volume = Math.sqrt(sum / channelData.length); - - // Отправляем громкость в основной поток - this.port.postMessage(this.volume); - } - - return true; - } -} - -registerProcessor('volume_processor', VolumeProcessor); |
