How to use the midi.output function in midi

To help you get started, we’ve selected a few midi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rocketryjs / rocketry / test / manual / devices.js View on Github external
*/


const expect = require("chai").expect;
const inquirer = require("inquirer");
const chalk = require("chalk");
const table = require("markdown-table");
const strip = require("strip-ansi");
const _ = require("lodash");
const midi = require("midi");
const rocketry = require("../../lib/index.js");


// MIDI I/O
const input = new midi.input();
const output = new midi.output();

// Device names, ports, support
// TODO: add API features for these and then use them in here
const getDeviceInfo = function(port, portName) {
	// Get names of ports
	const names = rocketry.core.getAllPortNames(port);

	// For all ports in input/output
	for (let i = 0; i < names.length; i++) {
		// Push into ports
		ports.push({
			"port": portName === "output" ? chalk.yellow("output") : chalk.cyan("input"),
			"number": chalk.gray(i),
			"name": names[i],
			"supported": names[i].match(rocketry.support.regex) ? chalk.green("true") : chalk.red("false")
		});
github petersalomonsen / javascriptmusic / testpattern2.js View on Github external
const Pattern = require('./pattern/pattern.class.js');

const midi = require('midi');
global.startTime = Date.now();
global.bpm = 120;

// Set up a new output.
const output = new midi.output();
let outputIndex;
for(var n=0;n
github amei-music / CreatorsHub / prg / client_modules / mididevices.js View on Github external
updateOutputDevices : function(){
      var existingOutputs = {}; for(var name in this.outputs) existingOutputs[name] = false;

      for(var portNum=0; portNum
github jperler / bezie / app / utils / midi.js View on Github external
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);
  }
github radiodario / woolf-waves / player.js View on Github external
var midi = require('midi'),
  midiOut = new midi.output();

try {
  midiOut.openPort(0);
} catch(error) {
  midiOut.openVirtualPort('');
}

var start = 1208;
var BPM = 40;

var lines = require('./processed').data;
var i = start,
    interval, line;
var noteDuration = 1000;

var notes = {
github jdachtera / node-rtpmidi / examples / expose-local-ports.js View on Github external
const hrtime = process.hrtime();
    return Math.round((diff + (hrtime[0] + hrtime[1] / 1000 / 1000 / 1000)) * rate);
  };
}());

const rtpmidi = require('../');

const inputs = {};

const outputs = {};

const sessions = {};

const i = new midi.input();

const o = new midi.output();

let isRunning = false;

const latency = 0;

let throttled = false;

const messageQueue = [];

let timeout;

const now = hrNow(10000);

let port = 5008;

let portMap = { outputs: [], inputs: [] };
github charlieroberts / interface.server / server / interface.server.js View on Github external
if( clients[i].id === clientNum ) {
              remote = clients[i];
              break;
            }
          }
        
          if(remote !== null) {
            remote.send( JSON.stringify( msg ) );
          }
        }
      }else{
        osc.send( args.address, args.typetags, args.parameters );
      }
    }else if( args.type === 'midi' ) {
      if( !midiInit ) {
        midiOutput = new midi.output();
        midiOutput.openVirtualPort( "Interface Output" );
        midiInit = true;
      }

      if(args.type !== 'programchange') {
        midiOutput.sendMessage([ midiNumbers[ args.midiType ] + args.channel, args.number, Math.round(args.value) ])
      }else{
        midiOutput.sendMessage([ 0xC0 + args.channel, args.number ])
      }
    }
  });
github dinchak / node-easymidi / index.js View on Github external
var Output = function (name, virtual) {
  this._output = new midi.output();
  if (virtual) {
    this._output.openVirtualPort(name);
  } else {
    var numOutputs = this._output.getPortCount();
    var found = false;
    for (var i = 0; i < numOutputs; i++) {
      if (name == this._output.getPortName(i)) {
        found = true;
        this._output.openPort(i);
      }
    }
    if (!found) {
      throw new Error('No MIDI output found with name: ' + name);
    }
  }
};
github matteodelabre / midijs / lib / device / device.js View on Github external
exports.getOutputs = function () {
    var output, count, ids = [], i = 0;

    if (global.navigator) {
        return getWebPorts('output');
    }

    output = new midi.output();
    count = output.getPortCount();

    while (i < count) {
        ids.push(i.toString());
        i += 1;
    }

    return Promise.resolve(ids);
};
github colinbdclark / Flocking / src / nodejs / midi.js View on Github external
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);
};