Created
May 14, 2019 09:54
-
-
Save flamendless/c2fb8e518647fed3f1e11e3a32abc0a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package frequencytable; | |
public class FrequencyTable { | |
public static void main(String[] args) { | |
test(); | |
} | |
private static void test() { | |
for (int noteNumber = 0; noteNumber < 128; noteNumber++) { | |
double frequency = 440 * Math.pow(2, (noteNumber - 69) / 12.0); | |
int frequencyInt = (int) (1193180 / frequency); | |
String frequencyHex = "0000" + Integer.toHexString(frequencyInt); | |
frequencyHex = frequencyHex.substring(frequencyHex.length() - 4, frequencyHex.length()); | |
if (noteNumber % 8 == 0) { | |
System.out.print("\r\n\tdb "); | |
} | |
System.out.print("0" + frequencyHex.subSequence(2, 4) + "h, 0" + frequencyHex.substring(0, 2) + "h" + ((noteNumber % 8 != 7) ? ", " : "")); | |
} | |
System.out.println(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment