README, dodan midi in za zogico

main
Jurij Podgoršek 2022-06-28 19:16:48 +02:00
parent 19d267da3c
commit 6cb1064250
2 changed files with 91 additions and 50 deletions

View File

@ -1,2 +1,21 @@
# kegel # kegel
Mere:
Najdaljši premer: 82mm
Špica: 15mm
32mm je lahko dolg vstavek
27mm je široka spodnja odprtina (blizu držalu)
Zapečemo ga s strani (izrez + prispajk nazaj)
## TODO
- Li-poly baterije
- konektorji za baterije
- gumbi za vklop
- še en kegel sestaviva
- napajanje za rock pi X (QC3.0)
- mikrofon naredit v kegel
- wifi na tablico ALI drug displej
- pedalko sprintat in povezat
- bluetooth; je stabilen?
- senzorji včasih ne odštejejo gravitacije

122
kegel.js
View File

@ -45,73 +45,95 @@ let rotVisina = 0
oscWS.on('message', ({ address, args }) => { oscWS.on('message', ({ address, args }) => {
DEBUG.osc && console.log('MSG OSC', address, args.map(x => x.toFixed(4))) DEBUG.osc && console.log('MSG OSC', address, args.map(x => x.toFixed(4)))
//const re = /\/ww\/(d+)\/([a-zA-Z]+)/ // Wavey Wind sporočila
const re = /\/ww\/(\d+)\/([a-zA-Z]+)/ const re = /\/ww\/(\d+)\/([a-zA-Z]+)/
const m = address.match(re) const m = address.match(re)
const index = m[1] if (m) {
const addr = m[2] const index = m[1]
const addr = m[2]
if (addr == 'euler') { if (addr == 'euler') {
//const eVisina = Math.sin(args[0] + args[1]) //const eVisina = Math.sin(args[0] + args[1])
const eVisina = Math.sin(args[2]) const eVisina = Math.sin(args[2])
rotVisina = 24 + Math.round(((eVisina / 2) + 0.5) * 24) rotVisina = 24 + Math.round(((eVisina / 2) + 0.5) * 24)
//console.log("rotVisina", rotVisina) //console.log("rotVisina", rotVisina)
} }
if (addr == 'accel') { if (addr == 'accel') {
const acX = args[0] const acX = args[0]
const acY = args[1] const acY = args[1]
const acZ = args[2] const acZ = args[2]
// Y os je kegel po dolgem - ignoriramo // Y os je kegel po dolgem - ignoriramo
const vsota = acX + acZ const vsota = acX + acZ
if (vsota > zaznava && !cakaj) { if (vsota > zaznava && !cakaj) {
cakaj = true cakaj = true
// Pavza // Pavza
setTimeout(() => { setTimeout(() => {
//console.log("nehaj cakat") //console.log("nehaj cakat")
cakaj = false cakaj = false
}, cakajInterval * 1000) }, cakajInterval * 1000)
const midiKanal = 144 + parseInt(index) const midiKanal = 144 + parseInt(index)
// Od 24 do 48 // Od 24 do 48
const accval = Math.sin((vsota - zaznava) / 3) const accval = Math.sin((vsota - zaznava) / 3)
//console.log(acX, accval) //console.log(acX, accval)
// Acc visina // Acc visina
const visina = (midiKanal == 0) const visina = (midiKanal == 0)
? 24 + Math.round((accval / 2.5) * 36) ? 24 + Math.round((accval / 2.5) * 36)
: 48 + Math.round((accval / 2.5) * 72) : 48 + Math.round((accval / 2.5) * 72)
//const visina = rotVisina
//console.log('posiljam midi', [144, visina, 127]) //const visina = rotVisina
/*
oscWS.send({
address: '/midi',
args: [192, 0, 127]
})
*/
oscWS.send({
address: '/midi',
args: [midiKanal, visina, 127]
})
console.log('vklopi', midiKanal, visina)
// Ugasni cez en cas //console.log('posiljam midi', [144, visina, 127])
let izklop = razponTona[0] + Math.random() * (razponTona[1] - razponTona[0]) /*
setTimeout(() => {
oscWS.send({ oscWS.send({
address: '/midi', address: '/midi',
args: [midiKanal, visina, 0] args: [192, 0, 127]
}) })
console.log('izklopi', midiKanal, visina) */
}, izklop * 1000) oscWS.send({
address: '/midi',
args: [midiKanal, visina, 127]
})
console.log('vklopi', midiKanal, visina)
// Ugasni cez en cas
let izklop = razponTona[0] + Math.random() * (razponTona[1] - razponTona[0])
setTimeout(() => {
oscWS.send({
address: '/midi',
args: [midiKanal, visina, 0]
})
console.log('izklopi', midiKanal, visina)
}, izklop * 1000)
}
} }
} else {
console.log(address)
}
if (address === '/midi-in') {
console.log(args)
oscWS.send({
address: '/midi',
args: [150, args[1], args[2]]
})
// Ugasni cez en cas
let izklop = razponTona[0] + Math.random() * (razponTona[1] - razponTona[0])
setTimeout(() => {
oscWS.send({
address: '/midi',
args: [150, args[1], 0]
})
console.log('izklopi', 150, args[1])
}, izklop * 1000)
} }
}) })