Popravi za bitwig povezavo, skripta za midi naprave vzpostavit

main
Tjaž 2022-10-25 14:53:17 +02:00
parent cac41f51a3
commit c481574744
2 changed files with 48 additions and 21 deletions

View File

@ -1,36 +1,30 @@
const WebSocket = require('ws')
const osc = require('osc')
const ip = process.argv[2]
const wwIP = process.argv[2]
const bwIP = process.argv[3]
const DEBUG = {
osc: true
}
const oscWS = new osc.WebSocketPort({
url: `ws://${ip}:6676`,
url: `ws://${wwIP}:6676`,
metadata: false
})
const bwPortUkazi = 8000
const bwPortStanje = 9000
const bwIP = '192.168.64.113'
const oscWSstanje = new osc.UDPPort({
const oscBW = new osc.UDPPort({
localAddress: bwIP,
remotePort: bwPortUkazi,
localPort: bwPortStanje,
metadata: false
})
const oscWSukazi = new osc.UDPPort({
localAddress: bwIP,
localPort: bwPortUkazi,
metadata: false
})
oscWS.on('ready', () => {
console.log(`Povezan sem na ${ip}`)
console.log(`Povezan sem na WW ${wwIP}`)
/*
setInterval(() => {
console.log('ping')
@ -39,13 +33,15 @@ oscWS.on('ready', () => {
*/
})
oscWSstanje.on('ready', () => {
console.log(`Prejemam bitwig info`)
oscBW.on('ready', () => {
console.log(`Povezan sem na bitwig ${bwIP}`)
})
oscWSukazi.on('ready', () => {
console.log(`Pripravljen sem na posiljanje v bitwig`)
})
const STANJE = {
predvajam: 0,
track: 0,
clip: 0,
}
oscWS.on('message', ({ address, args }) => {
DEBUG.osc && console.log('MSG OSC', address, args.map(x => x.toFixed(4)))
@ -55,6 +51,26 @@ oscWS.on('message', ({ address, args }) => {
const m = address.match(re)
if (m) {
console.log(address, m)
let bwUkaz = '/' + address.split('/').splice(3).join('/')
if (STANJE.predvajam && bwUkaz == '/play') {
bwUkaz = '/stop'
}
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] })
}
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',
@ -64,10 +80,18 @@ oscWS.on('message', ({ address, args }) => {
}
})
oscWSstanje.on('message', ({ address, args }) => {
DEBUG.osc && console.log('BITWIG OSC', address, args.map(x => x.toFixed(4)))
oscBW.on('message', ({ address, args }) => {
DEBUG.osc && console.log('BITWIG OSC', address, args)
if (address == '/play') {
console.log('MENJAVA SATANJA PLAY', args)
STANJE.predvajam = args[0]
}
if (address == '/track/selected/position') {
STANJE.track = args[0]
console.log('MENJAVA SATANJA TRACKA', STANJE.track)
}
})
oscWS.open()
//oscWSstanje.open()
oscWSukazi.open()
oscBW.open()

3
povezi-midi.sh 100755
View File

@ -0,0 +1,3 @@
#!/bin/bash
sudo modprobe snd-virmidi midi_devs=2