Skip to content

Instantly share code, notes, and snippets.

@flamendless
Created May 14, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flamendless/c2fb8e518647fed3f1e11e3a32abc0a6 to your computer and use it in GitHub Desktop.
Save flamendless/c2fb8e518647fed3f1e11e3a32abc0a6 to your computer and use it in GitHub Desktop.
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