-
Notifications
You must be signed in to change notification settings - Fork 8
/
mock_freq_table
34 lines (26 loc) · 881 Bytes
/
mock_freq_table
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/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]))