MidiUtil { public static int frequencyToMidi(float frequency) { return 69 + (int)Math.round(12 * (Math.log(frequency/F_REF)/Math.log(2.0))); } private  MidiUtil(); static int frequencyToMidi(float frequency); static float midiToFrequency(int m); static void play(Melody melody, int instrument, int channel); static final double F_REF; }
@Test public void testFrequencyToMidi() { for (int i=0; i<PITCHES.length; i++) { assertEquals(i, MidiUtil.frequencyToMidi(PITCHES[i]), "MIDI index does not match the expected MIDI index."); } }