lib/chord.js
function (obj, octave) {
  var lastNote = obj.chord[0];

  obj.chord = _.map(obj.chord, function (n) {
    // Every time a note is "lower" than the last note, we're in a new octave
    if (n.lowerThan(lastNote)) octave += 1;

    // As a side-effect, update the octaves for root and bass
    if (n.enharmonic(obj.root)) {
      obj.root = obj.root.inOctave(octave);
    }
    if (obj.bass && n.enharmonic(obj.bass)) {
      obj.bass = obj.bass.inOctave(octave);
    }

    lastNote = n;
    return n.inOctave(octave);
  });
}
function (obj, octave) {
  var lastNote = obj.chord[0];

  obj.chord = _.map(obj.chord, function (n) {
    // Every time a note is "lower" than the last note, we're in a new octave
    if (n.lowerThan(lastNote)) octave += 1;

    // As a side-effect, update the octaves for root and bass
    if (n.enharmonic(obj.root)) {
      obj.root = obj.root.inOctave(octave);
    }
    if (obj.bass && n.enharmonic(obj.bass)) {
      obj.bass = obj.bass.inOctave(octave);
    }

    lastNote = n;
    return n.inOctave(octave);
  });
}
function ( obj , octave ) { var lastNote = obj . chord [ 0 ] ; obj . chord = _ . map ( obj . chord , function ( n ) { // Every time a note is "lower" than the last note, we're in a new octave if ( n . lowerThan ( lastNote ) ) octave += 1 ; // As a side-effect, update the octaves for root and bass if ( n . enharmonic ( obj . root ) ) { obj . root = obj . root . inOctave ( octave ) ; } if ( obj . bass && n . enharmonic ( obj . bass ) ) { obj . bass = obj . bass . inOctave ( octave ) ; } lastNote = n ; return n . inOctave ( octave ) ; } ) ; }
Given a chord object and an octave number, assign appropriate octave numbers to notes
Given a chord object and an octave number assign appropriate octave numbers to notes