/* * Created on Apr 28, 2004 * */ package jmsltestsuite; import com.softsynth.jmsl.util.TuningET; import com.softsynth.jmsl.util.TuningTable; /** * Compare two definitions of 12tet tuning: TuningTable versus TuningET * * @author Nick Didkovsky, email: didkovn@mail.rockefeller.edu, (c) 2004 Nick Didkovsky, all rights reserved. * */ public class TuningTest { TuningTable tuningTable; TuningET tuningET = new TuningET(); public TuningTest() { double[] table = new double[12]; for (int i = 0; i < 12; i++) { table[i] = tuningET.getFrequency(TuningET.MIDDLE_C_PITCH + i); } tuningTable = new TuningTable(table, TuningET.MIDDLE_C_PITCH); // freq table and refernce pitch } void setStretch(int cents) { tuningTable.setOctaveStretchCents(cents); tuningET.setOctaveStretchCents(cents); } public void compare() { for (int i = 0; i < 48; i++) { double pitch = TuningET.MIDDLE_C_PITCH - 24 + i; double freq1 = tuningET.getFrequency(pitch); double freq2 = tuningTable.getFrequency(pitch); System.out.println(pitch + ", " + freq1 + ", " + freq2); if (freq1 != freq2 && Math.abs(freq1 - freq2) > 0.00001) { System.out.println("DIFFERENCE! " + freq1 + ", " + freq2 + ", diff=" + (freq1 - freq2)); } } } public static void main(String args[]) { TuningTest tuningTest = new TuningTest(); // tuningTest.compare(); tuningTest.setStretch(1); tuningTest.compare(); } }