midi: add debug support (print sent/receive if --debug is on)
This commit is contained in:
parent
8ca2e5a87e
commit
6401ee257f
2 changed files with 26 additions and 19 deletions
|
|
@ -3,7 +3,11 @@ var PythonShell = require('python-shell'),
|
|||
settings = require('./settings')
|
||||
|
||||
|
||||
var py = new PythonShell(path.resolve('/main/midi.py'),{mode:'text', args: settings.read('midi')})
|
||||
var py = new PythonShell(path.resolve('/main/midi.py'),{mode:'text', args: [
|
||||
settings.read('debug') ? 'debug' : '',
|
||||
...settings.read('midi')
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
oscToMidi = (data)=>{
|
||||
|
|
@ -17,17 +21,16 @@ oscToMidi = (data)=>{
|
|||
init = (receiveOsc)=>{
|
||||
py.on('message', function (message) {
|
||||
// console.log(message)
|
||||
|
||||
var name, data
|
||||
try {
|
||||
message = JSON.parse(message)
|
||||
// console.log(JSON.parse(message))
|
||||
[name, data] = JSON.parse(message)
|
||||
} catch (err) {
|
||||
// console.log(err)
|
||||
}
|
||||
if (message.log) {
|
||||
console.log(message.log)
|
||||
} else if (message.osc) {
|
||||
receiveOsc(message.osc)
|
||||
if (name == 'log') {
|
||||
console.log(data)
|
||||
} else if (name == 'osc') {
|
||||
receiveOsc(data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,15 @@ import json as JSON
|
|||
|
||||
# python -> node communication
|
||||
|
||||
def ipcSend(data):
|
||||
print(JSON.dumps(data))
|
||||
def ipcSend(name, data):
|
||||
print(JSON.dumps([name, data]))
|
||||
stdout.flush()
|
||||
|
||||
# debug
|
||||
debug = False
|
||||
if 'debug' in argv:
|
||||
debug = True
|
||||
|
||||
# virtual midi port
|
||||
virtuals = []
|
||||
mididingsLoopbackPatch = []
|
||||
|
|
@ -105,9 +110,7 @@ if 'list' in argv:
|
|||
|
||||
message.append('============')
|
||||
|
||||
ipcSend({
|
||||
'log': '\n'.join(message)
|
||||
})
|
||||
ipcSend('log', '\n'.join(message))
|
||||
|
||||
|
||||
|
||||
|
|
@ -185,7 +188,10 @@ class MidiRouter(object):
|
|||
|
||||
if device in self.midiDevicesIn:
|
||||
|
||||
ipcSend({'osc':{
|
||||
if debug:
|
||||
ipcSend('log','MIDI received: %i %i %i \t(from: %s)' % (status, data1, data2, self.midiDevicesIn[device]))
|
||||
|
||||
ipcSend('osc',{
|
||||
'address': '/%s' % event,
|
||||
'args': [
|
||||
{
|
||||
|
|
@ -202,7 +208,7 @@ class MidiRouter(object):
|
|||
}
|
||||
],
|
||||
'target': ['midi:' + self.midiDevicesIn[device]]
|
||||
}})
|
||||
})
|
||||
|
||||
|
||||
def sendMidi(self, device, event, *args):
|
||||
|
|
@ -233,10 +239,8 @@ class MidiRouter(object):
|
|||
|
||||
if device in self.midiDevicesOut:
|
||||
self.dispatcher.send(status, data1, data2, 0, self.midiDevicesOut[device])
|
||||
|
||||
elif device == '*':
|
||||
self.dispatcher.send(status, data1, data2, 0, -1)
|
||||
|
||||
if debug:
|
||||
ipcSend('log','MIDI sent: %i %i %i \t(to: %s)' % (status, data1, data2, device))
|
||||
|
||||
|
||||
patch = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue