@Test public void testBounds(){ Assert.assertEquals(0, evaluator.distance(FRQ_A4_flat, FRQ_A4_flat), PRECISION); Assert.assertEquals(+1, evaluator.distance(FRQ_A4_flat, FRQ_A4_bemol), PRECISION); Assert.assertEquals(-1, evaluator.distance(FRQ_A4_flat, FRQ_A4_sharp), PRECISION); Assert.assertEquals(+1, evaluator.distance(FRQ_A2_flat, FRQ_A2_bemol), PRECISION); Assert.assertEquals(-1, evaluator.distance(FRQ_A2_flat, FRQ_A2_sharp), PRECISION); Assert.assertEquals(-12, evaluator.distance(FRQ_A4_flat, FRQ_A5_flat), PRECISION); Assert.assertEquals(-24, evaluator.distance(FRQ_A4_flat, FRQ_A6_flat), PRECISION); Assert.assertEquals(+12, evaluator.distance(FRQ_A4_flat, FRQ_A3_flat), PRECISION); Assert.assertEquals(+24, evaluator.distance(FRQ_A4_flat, FRQ_A2_flat), PRECISION); Assert.assertEquals(0, evaluator.distance(FRQ_A6_flat, FRQ_A6_flat), PRECISION); Assert.assertEquals(+1, evaluator.distance(FRQ_A6_flat, FRQ_A6_bemol), PRECISION); Assert.assertEquals(-1, evaluator.distance(FRQ_A6_flat, FRQ_A6_sharp), PRECISION); Assert.assertEquals(-24, evaluator.distance(FRQ_A4_bemol, FRQ_A6_bemol), PRECISION); Assert.assertEquals(-24, evaluator.distance(FRQ_A4_sharp, FRQ_A6_sharp), PRECISION); }
@Override public double distance(float expectedFrequency, float estimatedFrequency) { return noteSemitoneValue(expectedFrequency) - noteSemitoneValue(estimatedFrequency); }
PitchPrecisionDistanceInSemitone implements PitchPrecisionDistance { @Override public double distance(float expectedFrequency, float estimatedFrequency) { return noteSemitoneValue(expectedFrequency) - noteSemitoneValue(estimatedFrequency); } }
PitchPrecisionDistanceInSemitone implements PitchPrecisionDistance { @Override public double distance(float expectedFrequency, float estimatedFrequency) { return noteSemitoneValue(expectedFrequency) - noteSemitoneValue(estimatedFrequency); }  }
PitchPrecisionDistanceInSemitone implements PitchPrecisionDistance { @Override public double distance(float expectedFrequency, float estimatedFrequency) { return noteSemitoneValue(expectedFrequency) - noteSemitoneValue(estimatedFrequency); }  @Override double distance(float expectedFrequency, float estimatedFrequency); double noteSemitoneValue(float frequency); double log2(float x); double log2Inverse(float y); int noteLowerBound(float frequency); int noteUpperBound(float frequency); }
PitchPrecisionDistanceInSemitone implements PitchPrecisionDistance { @Override public double distance(float expectedFrequency, float estimatedFrequency) { return noteSemitoneValue(expectedFrequency) - noteSemitoneValue(estimatedFrequency); }  @Override double distance(float expectedFrequency, float estimatedFrequency); double noteSemitoneValue(float frequency); double log2(float x); double log2Inverse(float y); int noteLowerBound(float frequency); int noteUpperBound(float frequency); static final float NOTE_A4_FREQ; static final int SEMITONES; }