# Lately Tuned pitch table generator # Written for Python version 3.2 # by Brad Smith 4/14/2012 # http://rainwarrior.ca import math # for log # NES frequency NESFREQ = 315000000.0 / 176.0 TUNING_OCTAVE = 3 # G#3 = 16/17 * 440hz tuning reference TUNING_NOTE = 8 TUNING_FREQ = 440.0 * 16.0 / 17.0 # A = 440hz #TUNING_NOTE = 9 #TUNING_FREQ = 440.0 def note_hz(n): n -= TUNING_NOTE + (12 * TUNING_OCTAVE) return TUNING_FREQ * pow(2, n / 12) def table_val(f): return int(round((NESFREQ / (16.0 * f)) - 1.0)) if __name__ == "__main__": periods = "" for i in range(0,8*12): tv = table_val(note_hz(i)) # for debugging #periods += ("\n %02d: %04x" % (i, tv)) # little endian output that can be pasted into a hex editor periods += ("%02x %02x " % ((tv&0xFF), ((tv>>8)&0xFF))) print("Periods: " + periods) # end of file