From 609c67d9759e970770dd384304fb63f36a6dff53 Mon Sep 17 00:00:00 2001 From: Pierre Ranwez <pierre.ranwez.etu@univ-lille.fr> Date: Thu, 24 Feb 2022 18:48:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bug:=20audio=20clip=20for=20onse?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content.js b/content.js index 92e3862..9546f36 100644 --- a/content.js +++ b/content.js @@ -1,5 +1,5 @@ var audioContext = null; -var meter = {volume: 0}; +var meter = { volume: 0 }; var analyser = null; var rafID = null; var buflen = 1024; @@ -259,7 +259,7 @@ async function gotStream(stream) { let _sensibility = 5 if (event.data.volume) _volume = event.data.volume; - meter = {volume: _volume}; + meter = { volume: _volume }; } mediaStreamSource.connect(node); audioContext.resume(); @@ -449,7 +449,7 @@ function audioEvent() { volume = meter.volume * 1.4; value = value.replace('[' + template.templateFull + ']', (meter.volume * 1.4 < 1 ? range(template, volume) : 0)); } - else if (template.eventType == 'onset' && template.eventName == noteStrings[note % 12]) { + else if (template.eventType == 'onset' && template.eventName == noteStrings[note % 12] && meter.volume > 0.08) { eventIn = true; value = value.replace('[' + template.templateFull + ']', range(template, 1)); } @@ -458,6 +458,7 @@ function audioEvent() { eventIn = true; value = value.replace('[' + template.templateFull + ']', ''); } + console.log(meter.volume); } }); if (eventIn) { -- GitLab