Logika spremembe tracka in clipa

main
Tjaž 2022-10-25 21:08:43 +02:00
parent c481574744
commit 2635973247
1 changed files with 104 additions and 25 deletions

127
bitwig.js
View File

@ -39,8 +39,10 @@ oscBW.on('ready', () => {
const STANJE = { const STANJE = {
predvajam: 0, predvajam: 0,
track: 0, track: 1,
clip: 0, clip: 1,
trackCount: 2,
trackAbs: 1,
} }
oscWS.on('message', ({ address, args }) => { oscWS.on('message', ({ address, args }) => {
@ -56,41 +58,118 @@ oscWS.on('message', ({ address, args }) => {
if (STANJE.predvajam && bwUkaz == '/play') { if (STANJE.predvajam && bwUkaz == '/play') {
bwUkaz = '/stop' bwUkaz = '/stop'
oscBW.send({ address: bwUkaz })
} else {
oscBW.send({ address: bwUkaz })
} }
if (bwUkaz == '/track/next') { switch (bwUkaz) {
bwUkaz = `/track/${STANJE.track}/selected` case '/play':
oscBW.send({ address: bwUkaz, args: [0] }) if (STANJE.predvajam) {
bwUkaz = `/track/${STANJE.track+1}/selected` bwUkaz = '/stop'
oscBW.send({ address: bwUkaz, args: [1] })
}
if (bwUkaz == '/track/previous') {
bwUkaz = `/track/${STANJE.track}/selected`
oscBW.send({ address: bwUkaz, args: [0] })
bwUkaz = `/track/${STANJE.track-1}/selected`
oscBW.send({ address: bwUkaz, args: [1] })
}
oscBW.send({ address: bwUkaz }) oscBW.send({ address: bwUkaz })
/* } else {
oscWS.send({ oscBW.send({ address: bwUkaz })
address: '/midi', }
args: [midiKanal, visina, 127] break
}) case '/track/next':
*/ console.log("NASLEDNJI TRACK", STANJE.track+1)
var novTrack = STANJE.track + 1
if (novTrack > 8) {
bwUkaz = `/track/bank/+`
oscBW.send({ address: bwUkaz })
setTimeout(() => {
bwUkaz = `/track/${STANJE.track}/select`
oscBW.send({ address: bwUkaz })
bwUkaz = `/track/${STANJE.track}/clip/${STANJE.clip}/select`
oscBW.send({ address: bwUkaz })
}, 50)
} else {
bwUkaz = `/track/${novTrack}/select`
oscBW.send({ address: bwUkaz })
bwUkaz = `/track/${novTrack}/clip/${STANJE.clip}/select`
oscBW.send({ address: bwUkaz })
}
break
case '/track/previous':
console.log("PREJSNJI TRACK", STANJE.track-1)
var novTrack = STANJE.track - 1
if (novTrack >= 1) {
bwUkaz = `/track/${novTrack}/select`
console.log(bwUkaz)
oscBW.send({ address: bwUkaz })
bwUkaz = `/track/${novTrack}/clip/${STANJE.clip}/select`
oscBW.send({ address: bwUkaz })
console.log(bwUkaz)
} else {
bwUkaz = `/track/bank/-`
oscBW.send({ address: bwUkaz })
setTimeout(() => {
bwUkaz = `/track/${STANJE.track}/select`
oscBW.send({ address: bwUkaz })
bwUkaz = `/track/${STANJE.track}/clip/${STANJE.clip}/select`
oscBW.send({ address: bwUkaz })
}, 50)
}
break
case '/clip/next':
var novClip = STANJE.clip + 1
console.log("NASLEDNJI CLIP", novClip)
if (novClip > 8) {
} else {
bwUkaz = `/track/${STANJE.track}/clip/${novClip}/select`
console.log("POSILJAM", bwUkaz)
oscBW.send({ address: bwUkaz })
}
break
case '/clip/previous':
var novClip = STANJE.clip - 1
console.log("PREJSNJI CLIP", novClip)
if (STANJE.clip - 1 >= 1) {
bwUkaz = `/track/${STANJE.track}/clip/${novClip}/select`
oscBW.send({ address: bwUkaz })
} else {
}
break
}
} }
}) })
oscBW.on('message', ({ address, args }) => { oscBW.on('message', ({ address, args }) => {
DEBUG.osc && console.log('BITWIG OSC', address, args) DEBUG.osc && console.log('BITWIG OSC', address, args)
if (address == '/play') { if (address == '/play') {
console.log('MENJAVA SATANJA PLAY', args) console.log('MENJAVA STANJA PLAY', args)
STANJE.predvajam = args[0] STANJE.predvajam = args[0]
} }
if (address == '/track/selected/position') { let re = /\/track\/(\d+)\/clip\/(\d+)\/isSelected/
STANJE.track = args[0] let m = address.match(re)
console.log('MENJAVA SATANJA TRACKA', STANJE.track) if (m) {
if (args[0]) {
STANJE.track = parseInt(m[1])
STANJE.clip = parseInt(m[2])
console.log('MENJAVA STANJA TRACKA', STANJE.track, STANJE.clip)
console.log(address, args)
}
} }
re = /\/master\/position/
m = address.match(re)
if (m) {
STANJE.trackCount = args[0] - 1
console.log("STEVILO TRACKOV", STANJE.trackCount)
}
/*
re = /\/track\/selected\/clip\/(\d+)\/isSelected/
m = address.match(re)
if (m) {
if (args[0]) {
STANJE.clip = parseInt(m[1])
console.log('MENJAVA STANJA CLIPA', STANJE.clip, m)
}
console.log(address, args)
}
*/
}) })
oscWS.open() oscWS.open()