midi: move python assets in src, add launcher context menu action for midi device listing
This commit is contained in:
parent
1d298b574e
commit
3eb73eca74
10 changed files with 125 additions and 77 deletions
|
|
@ -98,6 +98,7 @@ if (settings.cli) {
|
|||
|
||||
app.on('ready',function(){
|
||||
global.settings = settings
|
||||
global.midilist = require('./midi').list
|
||||
launcher = require('./electron-window')({address:address, shortcuts:dev, width:680, height:(100 + 8*3 + 29 * Object.keys(settings.options).filter(x=>settings.options[x].launcher !== false).length), node:true, color:'#253040'})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
var {PythonShell} = require('python-shell'),
|
||||
settings = require('./settings')
|
||||
|
||||
class Midi {
|
||||
var pythonOptions = {
|
||||
scriptPath:__dirname,
|
||||
mode:'text',
|
||||
}
|
||||
|
||||
class MidiConverter {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.py = new PythonShell('midi.py', {
|
||||
scriptPath:__dirname,
|
||||
mode:'text',
|
||||
this.py = new PythonShell('python/midi.py', Object.assign({
|
||||
args: [
|
||||
settings.read('debug') ? 'debug' : '',
|
||||
...settings.read('midi')
|
||||
]
|
||||
})
|
||||
}, pythonOptions))
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -34,31 +37,46 @@ class Midi {
|
|||
}
|
||||
|
||||
init(receiveOsc) {
|
||||
this.py.on('message', function(message) {
|
||||
// console.log(message)
|
||||
var name, data
|
||||
try {
|
||||
[name, data] = JSON.parse(message)
|
||||
} catch (err) {
|
||||
// console.log(err)
|
||||
}
|
||||
if (name == 'log') {
|
||||
if (data.indexOf('ERROR') === 0) {
|
||||
console.error(data)
|
||||
} else {
|
||||
console.log(data)
|
||||
}
|
||||
} else if (name == 'osc') {
|
||||
receiveOsc(data)
|
||||
} else if (name == 'error') {
|
||||
console.error('ERROR: MIDI: ' + data)
|
||||
this.stop()
|
||||
}
|
||||
|
||||
this.py.on('message', (message)=>{
|
||||
MidiConverter.parseIpc(message, this)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
static parseIpc(message, instance) {
|
||||
|
||||
// console.log(message)
|
||||
var name, data
|
||||
try {
|
||||
[name, data] = JSON.parse(message)
|
||||
} catch (err) {
|
||||
// console.log(err)
|
||||
}
|
||||
if (name == 'log') {
|
||||
if (data.indexOf('ERROR') === 0) {
|
||||
console.error(data)
|
||||
} else {
|
||||
console.log(data)
|
||||
}
|
||||
} else if (name == 'osc') {
|
||||
receiveOsc(data)
|
||||
} else if (name == 'error') {
|
||||
console.error('ERROR: MIDI: ' + data)
|
||||
if (instance) instance.stop()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static list() {
|
||||
|
||||
PythonShell.run('python/list.py', pythonOptions, function (err, results) {
|
||||
if (err) console.error(err)
|
||||
MidiConverter.parseIpc(results)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var midi = new Midi()
|
||||
|
||||
module.exports = midi
|
||||
module.exports = MidiConverter
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ var ipc = require('../server').ipc,
|
|||
EventEmitter = require('events').EventEmitter
|
||||
|
||||
|
||||
if (midi) midi = new midi()
|
||||
|
||||
class OscServer {
|
||||
|
||||
constructor(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue