Only unison, fourth and fifth (+ <I>n</I>*octaves) can be perfect
541113
private boolean allowPerfectQuality() {
		int i = m_label % OCTAVE;
		return (i == UNISON) || (i == FOURTH) || (i == FIFTH);
	}
494374
def substitute_diminished_for_diminished(progression, substitute_index,
        ignore_suffix=False):
    
    (roman, acc, suff) = parse_string(progression[substitute_index])
    res = []

    # Diminished progressions
    if suff == 'dim7' or suff == 'dim' or suff == '' and roman in ['VII']\
         or ignore_suffix:
        if suff == '':
            suff = 'dim'

        # Add diminished chord
        last = roman
        for x in range(3):
            next = skip(last, 2)
            acc += interval_diff(last, next, 3)
            res.append(tuple_to_string((next, acc, suff)))
            last = next
    return res
588491
static boolean isSymmetricOperation(Node n) {
    switch (n.getToken()) {
      case EQ: // equal
      case NE: // not equal
      case SHEQ: // exactly equal
      case SHNE: // exactly not equal
      case MUL: // multiply, unlike add it only works on numbers
        // or results NaN if any of the operators is not a number
        return true;
      default:
        break;
    }
    return false;
  }
991662
private final boolean doublec(int j) {
        if (j < 1) {
            return false;
        }
        if (b[j] != b[j - 1]) {
            return false;
        }
        return isConsonant(j);
    }
101607
function(tune) {
  var ret = {
    attributes: {
      divisions: 1 /tune.getBeatLength(),
      clef: {
        line: 2
      },
      key: {},
      time: {}
    }
  };
  var measures = [];
  var measureCounter = 0;
  var barlineCounter = 0;

  // parse lines
  for (var l = 0; l < tune.lines.length; l++) {
    for (var s = 0; s < tune.lines[l].staff.length; s++) {
      var staff = tune.lines[l].staff[s];

      // parse default clef, key, meter
      if (l === 0 && s === 0) {
        ret.attributes.clef.sign = getKeyByValue(clefs, staff.clef.type);
        ret.attributes.clef.line = staff.clef.clefPos / 2;
        ret.attributes.key.fifths = parseInt(getKeyByValue(circleOfFifths, staff.key.root));
        ret.attributes.time.beats = staff.meter.value[0].num;
        ret.attributes.time['beat-type'] = staff.meter.value[0].den;
      }

      for (var v = 0; v < staff.voices.length; v++) {
        for (var t = 0; t < staff.voices[v].length; t++) {
          var token = staff.voices[v][t];

          // init measure if none exists
          if (measures[measureCounter] === undefined) {
            measures[measureCounter] = new Measure();
          }

          switch (token.el_type) {
            case "note":
              measures[measureCounter].addNote(token, ret.attributes.divisions, ret.attributes.time['beat-type']);
              break;
            case "bar":
              if (token.type === 'bar_right_repeat') {
                measures[measureCounter].setRepeatRight();
              }
              measureCounter++;
              if (measures[measureCounter] === undefined) {
                measures[measureCounter] = new Measure();
              }
              if (token.type === 'bar_left_repeat') {
                measures[measureCounter].setRepeatLeft();
              }
              break;
            default:
              console.log(token);
              break;
          }
        }
      }
    }
  }

  // put measures together
  ret.measures = [];
  for (var i = 0; i < measures.length; i++) {
    var measure = measures[i].get();
    if (measure.notes.length > 0) {
      ret.measures.push(measure);
    }
  }
  return ret;
}
701697
private /*@ helper @*/ void multAddMe(int iv, int addend) {
        long v = iv & LONG_MASK;
        // unroll 0th iteration, doing addition.
        long p = v * (data[0] & LONG_MASK) + (addend & LONG_MASK);
        data[0] = (int) p;
        p >>>= 32;
        for (int i = 1; i < nWords; i++) {
            p += v * (data[i] & LONG_MASK);
            data[i] = (int) p;
            p >>>= 32;
        }
        if (p != 0L) {
            data[nWords++] = (int) p; // will fail noisily if illegal!
        }
    }
141440
private void parseLastConsonant() {
		if (!validViSyll)
			return;
		if (iCurPos > strSyllable.length())
			strLastConsonant = ZERO;
		String strCon = strSyllable.substring(iCurPos, strSyllable.length());

		if (strCon.length() > 3) {
			validViSyll = false;
			return;
		}

		Iterator iter = alLastConsonants.iterator();
		while (iter.hasNext()) {
			String tempLastCon = (String) iter.next();
			if (strCon.equals(tempLastCon)) {
				strLastConsonant = tempLastCon;
				iCurPos += strLastConsonant.length();
				return;
			}
		}
		strLastConsonant = ZERO;
		if (iCurPos >= strSyllable.length())
			validViSyll = true;
		else validViSyll = false;
		
		return;
	}
186540
def total_rated_level(octave_frequencies):
    
    sums = 0.0
    for band in OCTAVE_BANDS.keys():
        if band not in octave_frequencies:
            continue
        if octave_frequencies[band] is None:
            continue
        if octave_frequencies[band] == 0:
            continue
        sums += pow(10.0, ((float(octave_frequencies[band]) + OCTAVE_BANDS[band][1]) / 10.0))
    level = 10.0 * math.log10(sums)
    return level
204056
def independent(repertoire):
    """"""
    marginals = [marginal(repertoire, i) for i in range(repertoire.ndim)]

    # TODO: is there a way to do without an explicit iteration?
    joint = marginals[0]
    for m in marginals[1:]:
        joint = joint * m

    # TODO: should we round here?
    # repertoire = repertoire.round(config.PRECISION)
    # joint = joint.round(config.PRECISION)

    return np.array_equal(repertoire, joint)
920547
Rule ClefMiddle() {
		return Sequence(
				FirstOfS(IgnoreCase("m="), IgnoreCase("middle=")),
				BaseNote(), OptionalS(Octave())
			).label(ClefMiddle);
	}
617293
function Note(pitch_class) {
		var accidental = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Accidental.None;
		var octave = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 4;

		this._pitch_class = pitch_class;
		this._accidental = accidental;
		this._octave = octave;
	}
802975
function (numeral) {
  var matches = numeral.match(/([b#]?)([iIvV]+)/);
  var halfSteps = interval.parse(_.indexOf(romanNumeral, matches[2]).toString()).halfSteps();

  if (matches[1] === 'b') halfSteps -= 1;
  if (matches[1] === '#') halfSteps += 1;

  return halfSteps;
}
457255
function (deltaTime, on, firstChannel, chord, velocity) {
  var arr = [];

  // Make note event for first note after appropriate time
  arr.push(makeNoteEvent(deltaTime, on, firstChannel, noteValue(_.first(chord)), velocity));

  // Make note event for rest of the notes
  _.each(_.rest(chord), function (note, i) {
    arr.push(makeNoteEvent(0, on, i + firstChannel, noteValue(note), velocity));
  });

  return Buffer.concat(arr);
}
797996
def sinusoid(freq, phase=0.):
  
  # When at 44100 samples / sec, 5 seconds of this leads to an error of 8e-14
  # peak to peak. That's fairly enough.
  for n in modulo_counter(start=phase, modulo=2 * pi, step=freq):
    yield sin(n)
968402
private /*@ helper @*/ void trimLeadingZeros() {
        int i = nWords;
        if (i > 0 && (data[--i] == 0)) {
            //for (; i > 0 && data[i - 1] == 0; i--) ;
            while(i > 0 && data[i - 1] == 0) {
                i--;
            }
            this.nWords = i;
            if (i == 0) { // all words are zero
                this.offset = 0;
            }
        }
    }
888543
static private NoteAbstract transpose_Note(NoteAbstract original,
			Note noneTranspKeyNote, KeySignature noneTranspKey,
			Note lastKeyNote, KeySignature lastKey) {
		NoteAbstract transp = null;
		if (original instanceof Note) {
			float microtonalOffset = ((Note)original).getAccidental().getMicrotonalOffset();
			Interval interval = new Interval(noneTranspKeyNote, (Note) original,
					noneTranspKey);
			// Note transp = Note.transpose(original, semitones, lastKey);
			Note transpHeight = interval.calculateSecondNote(lastKeyNote, lastKey);
			try {
				transp = (Note) original.clone();
			} catch (CloneNotSupportedException never) {
				never.printStackTrace();
                return null;
			}
			((Note) transp).setHeight(transpHeight.getHeight());
			((Note) transp).setOctaveTransposition(transpHeight.getOctaveTransposition());
			if (microtonalOffset == 0)
				((Note) transp).setAccidental(transpHeight.getAccidental());
			else
				((Note) transp).setAccidental(transpHeight.getAccidental().getValue()+microtonalOffset);
		} else if (original instanceof MultiNote) {
			try {
				transp = (MultiNote) original.clone();
			} catch (CloneNotSupportedException never) {
				never.printStackTrace();
                return null;
			}
			Note[] notes = ((MultiNote) transp).toArray();
			for (int k = 0; k < notes.length; k++) {
				notes[k] = (Note) transpose_Note(notes[k], noneTranspKeyNote,
						noneTranspKey, lastKeyNote, lastKey);
			}
			((MultiNote) transp).setNotes(notes);
		}
//		TieDefinition tie = original.getTieDefinition();
//		if (tie != null) {
//			if (tie.getStart() == original)
//				tie.setStart(transp);
//			else if (tie.getEnd() == original)
//				tie.setEnd(transp);
//		}
//		Vector slurs = original.getSlurDefinitions();
//		for (Iterator it = slurs.iterator(); it.hasNext();) {
//			SlurDefinition slur = (SlurDefinition) it.next();
//			if (slur.getStart() == original)
//				slur.setStart(transp);
//			else if (slur.getEnd() == original)
//				slur.setEnd(transp);
//		}
		transpose_Chord(transp, noneTranspKeyNote, noneTranspKey,
				lastKeyNote, lastKey);
        assert transp != null;
        if (transp.hasGracingNotes()) {
			NoteAbstract[] graces = transp.getGracingNotes();
			for (int k = 0; k < graces.length; k++) {
				graces[k] = transpose_Note(graces[k], noneTranspKeyNote,
						noneTranspKey, lastKeyNote, lastKey);
			}
		}
		return transp;
	}
550712
function augmented_major_seventh(note) {
	var arr = augmented_triad(note);
	arr.push(intervals.major_seventh(note));
	return arr;
}