packages/sampler-instrument/lib/midi.js
function midi (instrument, options) {
  options = options || {}
  var midi = {}
  var unused = []
  instrument.names().forEach(function (name) {
    var m = toMidi(name)
    if (m) midi[m] = instrument.get(name)
    else unused.push(name)
  })

  if (options.map) addMap(midi, instrument, options.map)

  return {
    unused: function () { return unused.slice() },
    names: function () { return Object.keys(midi) },
    get: function (name) { return midi[toMidi(name) || name] }
  }
}
function midi (instrument, options) {
  options = options || {}
  var midi = {}
  var unused = []
  instrument.names().forEach(function (name) {
    var m = toMidi(name)
    if (m) midi[m] = instrument.get(name)
    else unused.push(name)
  })

  if (options.map) addMap(midi, instrument, options.map)

  return {
    unused: function () { return unused.slice() },
    names: function () { return Object.keys(midi) },
    get: function (name) { return midi[toMidi(name) || name] }
  }
}
function midi ( instrument , options ) { options = options || { } var midi = { } var unused = [ ] instrument . names ( ) . forEach ( function ( name ) { var m = toMidi ( name ) if ( m ) midi [ m ] = instrument . get ( name ) else unused . push ( name ) } ) if ( options . map ) addMap ( midi , instrument , options . map ) return { unused : function ( ) { return unused . slice ( ) } , names : function ( ) { return Object . keys ( midi ) } , get : function ( name ) { return midi [ toMidi ( name ) || name ] } } }
Create midi mappings for an instrument

@param {Instrument} instrument - the instrument. An instrument is an object
with names() and get() methods
@param {HashMap} options - (Optional) the midi mapping options. A hash may
with:

- map: a hash map of notes or a range of notes mapped to a sample name and
sample playing options. For example:
`map: {'C2': { sample: 'c2 sound' }, 'C3-C4': { sample: 'c3 sound'}}`
Create midi mappings for an instrument