testiranje dveh visin

main
Jurij Podgoršek 2022-05-22 16:43:15 +02:00
parent 811df247b0
commit f7956313e8
1 changed files with 42 additions and 13 deletions

View File

@ -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])