From f7956313e8aee534b84af36026cb422b37570848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurij=20Podgor=C5=A1ek?= Date: Sun, 22 May 2022 16:43:15 +0200 Subject: [PATCH] testiranje dveh visin --- kegel.js | 55 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/kegel.js b/kegel.js index 0754b46..7f27ab9 100644 --- a/kegel.js +++ b/kegel.js @@ -32,11 +32,11 @@ oscWS.on('ready', () => { */ }) -let midiOn = false +const zaznava = 0.8 -const zaznava = 0.5 +let cakajX = false +let cakajZ = false -let cakaj = false const cakajInterval = 1 / 5 const razponTona = [0.1, 0.5] //const razponTona = [0.001, 0.002] @@ -58,19 +58,14 @@ oscWS.on('message', ({ address, args }) => { const acZ = args[2] const vsota = acX + acY + acZ - if (cakaj) { - //console.log("CAKAM!") - return - } + if (acX > zaznava && !cakajX) { - if (acX > zaznava && !cakaj) { - - cakaj = true + cakajX = true // Pavza setTimeout(() => { //console.log("nehaj cakat") - cakaj = false + cakajX = false }, cakajInterval * 1000) @@ -78,7 +73,7 @@ oscWS.on('message', ({ address, args }) => { const accval = Math.sin((acX - zaznava) / 3) console.log(acX, accval) // Acc visina - const visina = 24 + Math.round((accval / 2.5) * 48) + const visina = 24 + Math.round((accval / 2.5) * 72) //const visina = rotVisina //console.log('posiljam midi', [144, visina, 127]) @@ -88,7 +83,41 @@ oscWS.on('message', ({ address, args }) => { }) console.log('vklopi', visina) - midiOn = true + // Ugasni cez en cas + let izklop = razponTona[0] + Math.random() * (razponTona[1] - razponTona[0]) + setTimeout(() => { + oscWS.send({ + address: '/midi', + args: [128, visina, 127] + }) + console.log('izklopi', visina) + }, izklop * 1000) + } + + if (acZ > zaznava && !cakajZ) { + + cakajZ = true + + // Pavza + setTimeout(() => { + //console.log("nehaj cakat") + cakajZ = false + }, cakajInterval * 1000) + + + // Od 24 do 48 + const accval = Math.sin((acZ - zaznava) / 3) + console.log(acZ, accval) + // Acc visina + const visina = 56 + Math.round((accval / 2.5) * 72) + //const visina = rotVisina + + //console.log('posiljam midi', [144, visina, 127]) + oscWS.send({ + address: '/midi', + args: [144, visina, 127] + }) + console.log('vklopi', visina) // Ugasni cez en cas let izklop = razponTona[0] + Math.random() * (razponTona[1] - razponTona[0])