'use strict';

var midi = require('./midi')
  , input
  , system = {}

// Get Midi Ports Info -----------------------------------
function getPorts(midiInterface){
  var portCount = midiInterface.getPortCount()
    , ports = []

  for (var i = 0; i < portCount ; i++) {
    var port = {
      name : midiInterface.getPortName(i)
      , num : i
      }
    ports.push(port)
  }
  return ports
}

// Get Ports
system.input = getPorts(new midi.input())
// system.output = getPorts(new midi.output())
console.log(system)

// Open first port -----------------------------------

input = new midi.input()
input.openPort(0);

var counter = 0;
input.on('message', function(deltaTime, message) {
  counter += 1;
  console.log(counter, 'm:' + message + ' d:' + deltaTime);
});

