Midi on/off

main
Jurij Podgoršek 2022-04-23 16:34:38 +02:00
parent 36d86e323d
commit 4a805e782c
1 changed files with 14 additions and 1 deletions

View File

@ -24,6 +24,9 @@ const fs = require('fs')
const midi = require('midi') const midi = require('midi')
let midiOn = false
let midiNotes = {}
// Vzemi iz argumenta // Vzemi iz argumenta
const tty = process.argv[2] const tty = process.argv[2]
@ -241,7 +244,17 @@ const sendAll = (msg, info, oscWS, osclients) => {
if (msg.address == '/accel') { if (msg.address == '/accel') {
if (msg.args[1] > 5000) { if (msg.args[1] > 5000) {
console.log("SEND MIDI!") console.log("SEND MIDI!")
mo.sendMessage([176, 22, 1]) const visina = Math.round((msg.args[1] - 5000) / 100)
midiNotes[visina] = true
mo.send([144, visina, 127])
midiOn = true
}
if (msg.args[1] < 5000 && midiOn) {
Object.keys(midiNotes).forEach(visina => {
mo.send([128, visina, 127])
})
midiOn = false
} }
} }