index.js
function() {
  var attributes = {
    repeat: {
      left: false,
      right: false
    }
  };
  var notes = [];

  /**
   * Set repeat left for measure
   */
  this.setRepeatLeft = function () {
    attributes.repeat.left = true;
  };

  /**
   * Set repeat right for measure
   */
  this.setRepeatRight = function () {
    attributes.repeat.right = true;
  };

  /**
   * Add note to measure
   * @param {object} note - The note object
   * @param {Number} divisions - The calculated divisions
   * @param {Number} beatType - The beat type
   */
  this.addNote = function(note, divisions, beatType) {
    var _note = {pitch:{}};
    var _octave = 5, _step, _alter = 0;
    if (note.hasOwnProperty('pitches')) {
      _octave--;
      _step = note.pitches[0].pitch;
      while (_step > 6) {
        _octave++;
        _step -= 7;
      }
      while (_step < 0) {
        _octave--;
        _step +=7
      }
      _note.pitch.step = pitches.abc[_step];
      _note.rest = false;
      if (note.pitches[0].hasOwnProperty('accidental')) {
        _alter = accidental.abc[note.pitches[0].accidental];
        _note.pitch.accidental = note.pitches[0].accidental;
      }
    } else {
      _note.pitch.step = "C";
      _note.pitch.octave = 5;
      _note.rest = true;
      _note.pitch.alter = 0;
    }
    _note.pitch.octave = _octave;
    _note.pitch.alter = _alter;

    for (var i = 0; i < durations.length; i++) {
      if (typeof durations[i+1] !== 'undefined') {
        if (durations[i].duration > note.duration && durations[i+1].duration <= note.duration) {
          var diff = note.duration - durations[i+1].duration;
          _note.duration = durations[i+1].duration * divisions * beatType;
          _note.type = durations[i+1].type;
          if (diff > 0) {
            if ((diff / durations[i+1].duration) === 0.5) {
              _note.dot = true;
            } else {
              throw new Error('Unknown duration: ' + note.duration);
            }
          }
          break;
        }
      } else {
        throw new Error('Unknown duration: ' + note.duration);
      }
    }

    notes.push(_note);
  };

  /**
   * Get measure object
   * @returns {{attributes: {repeat: {left: boolean, right: boolean}}, notes: Array}}
   */
  this.get = function() {
    return {
      attributes: attributes,
      notes: notes
    };
  };
}
function() {
  var attributes = {
    repeat: {
      left: false,
      right: false
    }
  };
  var notes = [];

  /**
   * Set repeat left for measure
   */
  this.setRepeatLeft = function () {
    attributes.repeat.left = true;
  };

  /**
   * Set repeat right for measure
   */
  this.setRepeatRight = function () {
    attributes.repeat.right = true;
  };

  /**
   * Add note to measure
   * @param {object} note - The note object
   * @param {Number} divisions - The calculated divisions
   * @param {Number} beatType - The beat type
   */
  this.addNote = function(note, divisions, beatType) {
    var _note = {pitch:{}};
    var _octave = 5, _step, _alter = 0;
    if (note.hasOwnProperty('pitches')) {
      _octave--;
      _step = note.pitches[0].pitch;
      while (_step > 6) {
        _octave++;
        _step -= 7;
      }
      while (_step < 0) {
        _octave--;
        _step +=7
      }
      _note.pitch.step = pitches.abc[_step];
      _note.rest = false;
      if (note.pitches[0].hasOwnProperty('accidental')) {
        _alter = accidental.abc[note.pitches[0].accidental];
        _note.pitch.accidental = note.pitches[0].accidental;
      }
    } else {
      _note.pitch.step = "C";
      _note.pitch.octave = 5;
      _note.rest = true;
      _note.pitch.alter = 0;
    }
    _note.pitch.octave = _octave;
    _note.pitch.alter = _alter;

    for (var i = 0; i < durations.length; i++) {
      if (typeof durations[i+1] !== 'undefined') {
        if (durations[i].duration > note.duration && durations[i+1].duration <= note.duration) {
          var diff = note.duration - durations[i+1].duration;
          _note.duration = durations[i+1].duration * divisions * beatType;
          _note.type = durations[i+1].type;
          if (diff > 0) {
            if ((diff / durations[i+1].duration) === 0.5) {
              _note.dot = true;
            } else {
              throw new Error('Unknown duration: ' + note.duration);
            }
          }
          break;
        }
      } else {
        throw new Error('Unknown duration: ' + note.duration);
      }
    }

    notes.push(_note);
  };

  /**
   * Get measure object
   * @returns {{attributes: {repeat: {left: boolean, right: boolean}}, notes: Array}}
   */
  this.get = function() {
    return {
      attributes: attributes,
      notes: notes
    };
  };
}
function ( ) { var attributes = { repeat : { left : false , right : false } } ; var notes = [ ] ; /**
   * Set repeat left for measure
   */ this . setRepeatLeft = function ( ) { attributes . repeat . left = true ; } ; /**
   * Set repeat right for measure
   */ this . setRepeatRight = function ( ) { attributes . repeat . right = true ; } ; /**
   * Add note to measure
   * @param {object} note - The note object
   * @param {Number} divisions - The calculated divisions
   * @param {Number} beatType - The beat type
   */ this . addNote = function ( note , divisions , beatType ) { var _note = { pitch : { } } ; var _octave = 5 , _step , _alter = 0 ; if ( note . hasOwnProperty ( 'pitches' ) ) { _octave -- ; _step = note . pitches [ 0 ] . pitch ; while ( _step > 6 ) { _octave ++ ; _step -= 7 ; } while ( _step < 0 ) { _octave -- ; _step += 7 } _note . pitch . step = pitches . abc [ _step ] ; _note . rest = false ; if ( note . pitches [ 0 ] . hasOwnProperty ( 'accidental' ) ) { _alter = accidental . abc [ note . pitches [ 0 ] . accidental ] ; _note . pitch . accidental = note . pitches [ 0 ] . accidental ; } } else { _note . pitch . step = "C" ; _note . pitch . octave = 5 ; _note . rest = true ; _note . pitch . alter = 0 ; } _note . pitch . octave = _octave ; _note . pitch . alter = _alter ; for ( var i = 0 ; i < durations . length ; i ++ ) { if ( typeof durations [ i + 1 ] !== 'undefined' ) { if ( durations [ i ] . duration > note . duration && durations [ i + 1 ] . duration <= note . duration ) { var diff = note . duration - durations [ i + 1 ] . duration ; _note . duration = durations [ i + 1 ] . duration * divisions * beatType ; _note . type = durations [ i + 1 ] . type ; if ( diff > 0 ) { if ( ( diff / durations [ i + 1 ] . duration ) === 0.5 ) { _note . dot = true ; } else { throw new Error ( 'Unknown duration: ' + note . duration ) ; } } break ; } } else { throw new Error ( 'Unknown duration: ' + note . duration ) ; } } notes . push ( _note ) ; } ; /**
   * Get measure object
   * @returns {{attributes: {repeat: {left: boolean, right: boolean}}, notes: Array}}
   */ this . get = function ( ) { return { attributes : attributes , notes : notes } ; } ; }
Constructor for measure objects
@constructor
Constructor for measure objects