Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getDevices() {
// MIDI I/O
const input = new midi.input();
const output = new midi.output();
// Set array of ports
const results = [];
const portTypes = {input, output};
for (const key in portTypes) {
results.push(this.getPorts(portTypes[key], key));
}
// Open and close ports
// Prevent `RtMidiIn::cancelCallback: no callback function was set!` error
// Sometimes node-midi doesn't exit nicely when closing I/O without a callback but it also doesn't exit when it doesn't have one.
// For testing, use `ctrl + c` or `process.exit();` if this doesn't work for you.
// Related: justinlatimer/node-midi#117
input.openPort(0);
output.openPort(0);
// Close MIDI I/O ports
function connectToLaunchpad() { // Attempt to connect to the Launchpad
const midiIn = new midi.input(); // Create new Midi input
const midiOut = new midi.output(); // Create new Midi output
const midiInCount = midiIn.getPortCount(); // Gets the number of Midi input ports connected
const midiOutCount = midiOut.getPortCount(); // Gets the number of Midi output ports connected
if (midiInCount <= 0 || midiOutCount <= 0) {
console.log('No Midi devices found. Have you plugged in the Launchpad Device yet?');
return;
}
let midiInPort = null;
let midiOutPort = null;
for (let i = 0; i < midiInCount; i++) { // Loop through Midi input ports
if (midiIn.getPortName(i).toLowerCase().includes('launchpad')) {
midiInPort = i; // Save index of Launchpad input port if found
}
}
for (let i = 0; i < midiOutCount; i++) { // Loop through Midi output ports
if (midiOut.getPortName(i).toLowerCase().includes('launchpad')) {
} else if (data.class == 'hyperdeckNext') {
myStreamDeck.fillImageFromFile(sd, path.resolve(__dirname, 'assets/stream-deck/forward-clear.png')).then(() => {
});
} else if (data.class == 'hyperdeckPrevious') {
myStreamDeck.fillImageFromFile(sd, path.resolve(__dirname, 'assets/stream-deck/back-clear.png')).then(() => {
});
};
});
};
};
// MIDI //
// Set up a new input.
var input = new midi.input();
// Configure a callback.
input.on('message', function(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('m:' + message);
// Cut Auto
if (message == '176,95,127') {
atem.cutTransition();
};
if (message == '176,95,0') {
tallyCut.style.backgroundColor = "";
};
createVirtualInput: function(name){
// すでに同名の仮想MIDIINがある場合はnullを返す
if(obj.vinputs[name]) return null;
// 仮想MIDI INデバイスが出力側に出てこないようにする
appendIngnoreList(name);
var vin = new midi.input();
vin.ignoreTypes(false, false, true); // (Sysex, Timing, Active Sensing) のignoreを設定する
vin.openVirtualPort(name);
obj.vinputs[name] = vin;
return vin;
},
constructor() {
this.output = new midi.output();
this.input = new midi.input();
this.controllers = {};
this.controller = null;
this.initControllers();
this._isConnected = false;
// Enable timing events
this.input.ignoreTypes(true, false, true);
}
const midi = require('midi');
const fs = require('fs');
const input = new midi.input();
let inputIndex;
for(let n=0;n= 0) {
console.log("Opening",input.getPortName(inputIndex));
input.openPort(inputIndex);
}
class Recorder {
function getInputs() {
var input = new midi.input();
var inputs = [];
for (var i = 0; i < input.getPortCount(); i++) {
inputs.push(input.getPortName(i));
}
input.closePort();
return inputs;
}
flock.midi.nodejs.MIDIAccess = function (options) {
this.sysex = options.sysex !== undefined ? options.sysex : false;
this.input = new midi.input();
this.output = new midi.output();
this.input.ignoreTypes(this.sysex, false, false);
};
function getPorts() {
const inputCount = i.getPortCount();
const outputCount = o.getPortCount();
let id;
const portMap = { inputs: [], outputs: [] };
for (id = 0; id < inputCount; id++) {
if (!inputs[id]) {
inputs[id] = new midi.input();
inputs[id].openPort(id);
}
portMap.inputs.push(i.getPortName(id));
}
for (id = 0; id < outputCount; id++) {
if (!outputs[id]) {
outputs[id] = new midi.output();
outputs[id].openPort(id);
}
portMap.outputs.push(o.getPortName(id));
}
this.portMap = portMap;
return portMap;
}