Logika spremembe tracka in clipa
parent
c481574744
commit
2635973247
129
bitwig.js
129
bitwig.js
|
@ -39,8 +39,10 @@ oscBW.on('ready', () => {
|
|||
|
||||
const STANJE = {
|
||||
predvajam: 0,
|
||||
track: 0,
|
||||
clip: 0,
|
||||
track: 1,
|
||||
clip: 1,
|
||||
trackCount: 2,
|
||||
trackAbs: 1,
|
||||
}
|
||||
|
||||
oscWS.on('message', ({ address, args }) => {
|
||||
|
@ -56,41 +58,118 @@ oscWS.on('message', ({ address, args }) => {
|
|||
|
||||
if (STANJE.predvajam && bwUkaz == '/play') {
|
||||
bwUkaz = '/stop'
|
||||
oscBW.send({ address: bwUkaz })
|
||||
} else {
|
||||
oscBW.send({ address: bwUkaz })
|
||||
}
|
||||
|
||||
if (bwUkaz == '/track/next') {
|
||||
bwUkaz = `/track/${STANJE.track}/selected`
|
||||
oscBW.send({ address: bwUkaz, args: [0] })
|
||||
bwUkaz = `/track/${STANJE.track+1}/selected`
|
||||
oscBW.send({ address: bwUkaz, args: [1] })
|
||||
switch (bwUkaz) {
|
||||
case '/play':
|
||||
if (STANJE.predvajam) {
|
||||
bwUkaz = '/stop'
|
||||
oscBW.send({ address: bwUkaz })
|
||||
} else {
|
||||
oscBW.send({ address: bwUkaz })
|
||||
}
|
||||
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
|
||||
}
|
||||
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 })
|
||||
/*
|
||||
oscWS.send({
|
||||
address: '/midi',
|
||||
args: [midiKanal, visina, 127]
|
||||
})
|
||||
*/
|
||||
}
|
||||
})
|
||||
|
||||
oscBW.on('message', ({ address, args }) => {
|
||||
DEBUG.osc && console.log('BITWIG OSC', address, args)
|
||||
if (address == '/play') {
|
||||
console.log('MENJAVA SATANJA PLAY', args)
|
||||
console.log('MENJAVA STANJA PLAY', args)
|
||||
STANJE.predvajam = args[0]
|
||||
}
|
||||
if (address == '/track/selected/position') {
|
||||
STANJE.track = args[0]
|
||||
console.log('MENJAVA SATANJA TRACKA', STANJE.track)
|
||||
let re = /\/track\/(\d+)\/clip\/(\d+)\/isSelected/
|
||||
let m = address.match(re)
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue