diff --git a/server.js b/server.js index d3054a6..c4feb17 100644 --- a/server.js +++ b/server.js @@ -78,14 +78,6 @@ if (MIDI) { //mo.openPort(0) mo.openVirtualPort("kegel") mi.openVirtualPort("ww-midi-in") - - mi.on('message', (deltaTime, message) => { - // The message is an array of numbers corresponding to the MIDI bytes: - // [status, data1, data2] - // https://www.cs.cf.ac.uk/Dave/Multimedia/node158.html has some helpful - // information interpreting the messages. - console.log(`midi in: ${message} d: ${deltaTime}`); - }); } function openSerial(ttyAddr) { @@ -214,6 +206,20 @@ scudp.on('error', (e) => { }) scudp.open() +if (MIDI) { + mi.on('message', (deltaTime, message) => { + // The message is an array of numbers corresponding to the MIDI bytes: + // [status, data1, data2] + // https://www.cs.cf.ac.uk/Dave/Multimedia/node158.html has some helpful + // information interpreting the messages. + console.log(`midi in: ${message} d: ${deltaTime}`); + sendAll({ + address: '/midi', + args: message + }, info, oscWS, osclients) + }); +} + function eulerFromQuaternion(quaternion) { // Quaternion to matrix. const w = quaternion[0], x = quaternion[1], y = quaternion[2], z = quaternion[3];