lib/midi.js
function (notes, settings) {
  var restBuffer = 0;

  var events = _.reduce(notes, function (arr, obj) {
    var time = noteLength(obj.duration, settings);

    if (obj.note) {
      arr.push(makeNoteEvent(restBuffer, true, 0, noteValue(obj.note), settings.noteVelocity)); // On
      arr.push(makeNoteEvent(time, false, 0, noteValue(obj.note), settings.noteVelocity)); // Off
      restBuffer = 0;
    }
    else {
      restBuffer += time;
    }

    return arr;
  }, []);

  return Buffer.concat(events);
}
function (notes, settings) {
  var restBuffer = 0;

  var events = _.reduce(notes, function (arr, obj) {
    var time = noteLength(obj.duration, settings);

    if (obj.note) {
      arr.push(makeNoteEvent(restBuffer, true, 0, noteValue(obj.note), settings.noteVelocity)); // On
      arr.push(makeNoteEvent(time, false, 0, noteValue(obj.note), settings.noteVelocity)); // Off
      restBuffer = 0;
    }
    else {
      restBuffer += time;
    }

    return arr;
  }, []);

  return Buffer.concat(events);
}
function ( notes , settings ) { var restBuffer = 0 ; var events = _ . reduce ( notes , function ( arr , obj ) { var time = noteLength ( obj . duration , settings ) ; if ( obj . note ) { arr . push ( makeNoteEvent ( restBuffer , true , 0 , noteValue ( obj . note ) , settings . noteVelocity ) ) ; // On arr . push ( makeNoteEvent ( time , false , 0 , noteValue ( obj . note ) , settings . noteVelocity ) ) ; // Off restBuffer = 0 ; } else { restBuffer += time ; } return arr ; } , [ ] ) ; return Buffer . concat ( events ) ; }
Given note list, return a buffer containing note events
Given note list return a buffer containing note events