mirror of
https://github.com/bobbimanners/Applecorn.git
synced 2024-12-27 23:31:04 +00:00
35 lines
881 B
Python
35 lines
881 B
Python
#!/usr/bin/python3
|
|
|
|
#
|
|
# Make a table of Mockingboard wavelength values (high and low bytes)
|
|
# Corresponding to the frequency values used in BBC Micro
|
|
# SOUND statements.
|
|
#
|
|
|
|
d7 = 2349.32 # D7 is pitch value 253
|
|
clk = 63780.27 # AY-3 clock (1.023MHz / 16)
|
|
freqs = [0] * 256
|
|
divider = [0] * 256
|
|
|
|
freqs[253] = d7
|
|
|
|
for i in range(254,256):
|
|
freqs[i] = freqs[i-1] * (2 ** (1 / 48))
|
|
|
|
for i in range(252,-1,-1):
|
|
freqs[i] = freqs[i+1] / (2 ** (1 / 48))
|
|
|
|
for i in range(0,256):
|
|
divider[i] = int(round(clk / freqs[i]))
|
|
coarse = int(divider[i] / 256)
|
|
fine = int(divider[i] % 256)
|
|
# print("{:3d}: {:9.3f} {:5d} ({:2d} {:3d})".format(i, freqs[i], divider[i], coarse, fine))
|
|
|
|
print("\nMFREQHIGH");
|
|
for i in range(0,256):
|
|
print(" DB >{:.0f}".format(divider[i]))
|
|
|
|
print("\nMFREQLOW");
|
|
for i in range(0,256):
|
|
print(" DB <{:.0f}".format(divider[i]))
|