WIP midi kontroler

main
Jurij Podgoršek 2022-09-14 20:34:39 +02:00
parent d574ad0884
commit af128acd36
1 changed files with 69 additions and 0 deletions

View File

@ -1,4 +1,5 @@
const midi = require('midi')
const readline = require('readline');
let mo = new midi.Output()
let mi = new midi.Input()
@ -14,3 +15,71 @@ mi.on('message', (deltaTime, message) => {
console.log(`midi in: ${message} d: ${deltaTime}`)
mo.send(message)
})
// Formiraj CC midi sporočilo
// 176+ = CC
const cc = (a, b) => ([176, a, b])
const quantize = [
cc(40, 22),
cc(40, 0),
cc(40, 23)
]
const pause = [
cc(20, 0),
cc(20, 23)
]
const play = [
cc(20, 0),
cc(20, 22)
]
const posnemiTakt = [
cc(101, 3),
cc(102, 3),
cc(103, 3),
cc(104, 3),
cc(105, 3),
cc(106, 3),
cc(107, 3),
cc(108, 3),
cc(30, 9),
cc(101, 60),
cc(102, 9),
cc(103, 118),
cc(104, 118),
cc(105, 0),
cc(106, 0),
cc(107, 0),
cc(108, 0),
cc(30, 0),
cc(30, 11)
]
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
const posljiMidi = (ukazi) => {
ukazi.forEach(midi => {
mo.send(midi)
})
}
rl.setPrompt('Vpiši ukaz > ')
rl.prompt()
rl.on('line', line => {
console.log(line)
switch (line) {
case 'q':
posljiMidi(quantize)
break;
}
rl.prompt()
})