Using Eight Bits
Below you can see the possible frequencies when using a POKEY in 8-bit mode, with a master clock of 1.843200 MHz. The approximate data values and resulting frequencies for the notes going from C2 to G6 are shown. Naturally, the higher the frequency, the lower the resolution. The lower resolution, the more out of tune the oscillator is.
There are four columns in the table below (sorry about the bad layout). 'Note' is the MIDI note number, '12-TET' is the in tune, ideal frequency for each note, 'Result' is the frequency that the POKEY will play for a give note and 'Difference' is the the difference between the in-tune note and the resulting POKEY note.
Note 12-TET Result Difference
48 130.8128 130.61 -2.66
49 138.5913 138.3 -3.7
50 146.8324 146.94 1.25
51 155.5635 155.26 -3.42
52 164.8138 164.57 -2.55
53 174.6141 174.15 -4.61
54 184.9972 184.91 -0.8
55 195.9977 195.92 -0.7
56 207.6523 207.01 -5.38
57 220.0000 219.43 -4.5
58 233.0819 233.43 2.62
59 246.9417 247.48 3.74
60 261.6256 261.22 -2.66
61 277.1826 276.59 -3.7
62 293.6648 293.88 1.25
63 311.1270 310.51 -3.42
64 329.6276 329.14 -2.55
65 349.2282 350.15 4.57
66 369.9944 369.82 -0.8
67 391.9954 391.84 -0.7
68 415.3047 416.64 5.54
69 440.0000 438.86 -4.5
70 466.1638 463.58 -9.62
71 493.8833 491.26 -9.23
72 523.2511 522.45 -2.66
73 554.3653 557.87 10.91
74 587.3295 587.76 1.25
75 622.2540 621.02 -3.42
76 659.2551 658.29 -2.55
77 698.4565 700.3 4.57
78 739.9888 731.43 -20.14
79 783.9909 783.67 -0.7
80 830.6094 822.86 -16.23
81 880.0000 889.58 18.74
82 932.3275 940.41 14.94
83 987.7666 997.4 16.81
84 1046.5023 1061.75 25.04
85 1108.7305 1097.14 -18.19
86 1174.6591 1265.93 129.55
87 1244.5079 1316.57 97.45
88 1318.5102 1496.1 218.76
89 1396.9129 1567.35 199.3
90 1479.9777 1645.71 183.77
91 1567.9817 1732.33 172.57
92 1661.2188 1936.13 265.12
93 1760.0000 2057.14 270.08
94 1864.6550 2194.29 281.81
95 1975.5332 2351.02 301.25
96 2093.0045 2531.87 329.55
97 2217.4610 2742.86 368.12
98 2349.3181 2992.21 418.76
99 2489.0159 3291.43 483.77
We can represent this difference as a table that compares the POKEY's frequencies for each note to the in-tune frequency.
We can also represent the amount that the POKEY is out of tune in terms of cents. For this graph, I have chosen a smaller range of values because the tuning becomes ridiculous as the frequency increases too high (this is measured in cents; 100 cents is equal to one semitone).
From note 48 onwards
Using Sixteen BitsWhen sixteen bit mode is active, the tuning range and resolution increases immensely, allowing the chip to have a reasonable range of approx. eight octaves. The frequencies and their tuning in cents in comparison to 12-TET is shown below.
Note 12-TET Result Difference
1 8.6620 14.06 838.75
2 9.1770 14.06 738.75
3 9.7227 14.06 638.75
4 10.3009 14.06 538.75
5 10.9134 14.06 438.75
6 11.5623 14.06 338.75
7 12.2499 14.06 238.75
8 12.9783 14.06 138.75
9 13.7500 14.06 38.75
10 14.5676 14.57 0.02
11 15.4339 15.43 0.03
12 16.3516 16.35 0.01
13 17.3239 17.32 0
14 18.3540 18.35 0.01
15 19.4454 19.45 0.01
16 20.6017 20.6 0
17 21.8268 21.83 0.02
18 23.1247 23.12 0.02
19 24.4997 24.5 0.04
20 25.9565 25.96 0.02
21 27.5000 27.5 0.04
22 29.1352 29.14 0.04
23 30.8677 30.87 0.03
24 32.7032 32.7 0.04
25 34.6478 34.65 0
26 36.7081 36.71 0.01
27 38.8909 38.89 0.01
28 41.2034 41.2 0
29 43.6535 43.65 0.06
30 46.2493 46.25 0.07
31 48.9994 49 0.04
32 51.9131 51.92 0.07
33 55.0000 55 0.04
34 58.2705 58.27 0.1
35 61.7354 61.74 0.03
36 65.4064 65.41 0.04
37 69.2957 69.3 0.07
38 73.4162 73.42 0.01
39 77.7817 77.79 0.08
40 82.4069 82.41 0.08
41 87.3071 87.31 0.14
42 92.4986 92.5 0.07
43 97.9989 98 0.04
44 103.8262 103.83 0.07
45 110.0000 110 0.04
46 116.5409 116.55 0.21
47 123.4708 123.47 0.03
48 130.8128 130.82 0.04
49 138.5913 138.61 0.2
50 146.8324 146.85 0.15
51 155.5635 155.57 0.08
52 164.8138 164.84 0.24
53 174.6141 174.64 0.3
54 184.9972 185.02 0.24
55 195.9977 196 0.04
56 207.6523 207.66 0.07
57 220.0000 220 0.04
58 233.0819 233.14 0.43
59 246.9417 246.95 0.03
60 261.6256 261.67 0.29
61 277.1826 277.26 0.46
62 293.6648 293.69 0.15
63 311.1270 311.14 0.08
64 329.6276 329.73 0.55
65 349.2282 349.36 0.63
66 369.9944 370.12 0.59
67 391.9954 392 0.04
68 415.3047 415.32 0.07
69 440.0000 440.11 0.45
70 466.1638 466.4 0.87
71 493.8833 493.89 0.03
72 523.2511 523.34 0.29
73 554.3653 554.51 0.46
74 587.3295 587.38 0.15
75 622.2540 622.28 0.08
76 659.2551 659.7 1.17
77 698.4565 698.71 0.63
78 739.9888 740.24 0.59
79 783.9909 784.34 0.77
80 830.6094 831.02 0.85
81 880.0000 880.23 0.45
82 932.3275 932.79 0.87
83 987.7666 987.78 0.03
84 1046.5023 1047.27 1.27
85 1108.7305 1109.03 0.46
86 1174.6591 1175.51 1.25
87 1244.5079 1245.41 1.25
88 1318.5102 1320.34 2.41
89 1396.9129 1398.48 1.94
90 1479.9777 1481.67 1.98
91 1567.9817 1570.02 2.25
92 1661.2188 1663.54 2.42
93 1760.0000 1762.14 2.11
94 1864.6550 1865.59 0.87
95 1975.5332 1977.68 1.88
96 2093.0045 2094.55 1.27
97 2217.4610 2220.72 2.54
98 2349.3181 2351.02 1.25
99 2489.0159 2490.81 1.25
100 2637.0205 2640.69 2.41
101 2793.8259 2801.22 4.57
102 2959.9554 2963.34 1.98
103 3135.9635 3145.39 5.2
104 3322.4376 3327.08 2.42
105 3520.0000 3531.03 5.42
106 3729.3101 3731.17 0.87
107 3951.0664 3955.36 1.88
108 4186.0090 4189.09 1.27
109 4434.9221 4452.17 6.72
110 4698.6363 4702.04 1.25
111 4978.0317 4981.62 1.25
112 5274.0409 5296.55 7.37
113 5587.6517 5619.51 9.84
114 5919.9108 5945.81 7.56
115 6271.9270 6312.33 11.12
116 6644.8752 6678.26 8.68
117 7040.0000 7089.23 12.06
118 7458.6202 7492.68 7.89
119 7902.1328 7944.83 9.33
120 8372.0181 8378.18 1.27
121 8869.8442 8947.57 15.11
122 9397.2726 9404.08 1.25
123 9956.0635 10017.39 10.63
124 10548.0818 10593.1 7.37
125 11175.3034 11239.02 9.84
126 11839.8215 11968.83 18.76
127 12543.8540 12624.66 11.12
Once again, we can show the pitch versus the ideal pitch as note against frequency. Notice how the 12-TET line completely obscures the resultant frequency line - this is becasue the Atari POKEY is now much more in tune than if we were using eight bits of data!!
We can also show the tuning of each note in cents. The following graph shows the range from MIDI note 10 to MIDI note 110, a huge pitch range. The POKEY is much more in tune.
11 comments:
What is (are) the formula(e) for Hz->Pokey? I want to test certain calculations...
For 16 bit mode, the calculation is:
F = clock / (2 * (256 * hiB + loB + 7))
where hiB = ((clock / F/ 2) - 7) / 256)
and loB = ((clock/ F / 2) - 7) % 256)
For 8 bit mode:
byte = (clock / F / 2) - 7
Also: clock for 8 bit mode can be 1,843,200 Hz, 65,828.5714285714 Hz or 15,360Hz for a crystal running at 1.8432 MHz.
For 16 bit mode it is usually just 1,843,200 Hz
nyup nyup nyup
hmmm I WONDER WHO THAT WAS?
What is the advantage of using the 8-bit mode as opposed to 16 bits (except for the gain in free CPU time from reading/writing only one byte)?
Hi Boomlinde! Nice to see you in this part of town.
16-bit mode gangs two of the oscillators together, so in effect it takes up two channels instead of just the one.
Aha, thanks, that makes sense! I've heard about some technique involving rapidly changing the frequency register between two values to achieve greater frequency resolution. On an atari it would eat a lot of time of course, but if you're using a fast microcontroller it might not be that big of a deal to implement (I have no idea though) for your project. I think it was implemented in Raster Music Tracker.
Personally I think the off-tune notes add some character to the sound and could be utilized if composers took it into account instead of thinking in terms of 12-tet equal temperament.
Good luck!
Also, I'm a frequent reader, but I guess I should comment more :)
I agree with you that the tuning of a chip gives rise to a unique character that needs to be taken into account with various chips and how they produce a given frequency.
"I've heard about some technique involving rapidly changing the frequency register between two values to achieve greater frequency resolution."
No no, this is nothing of the sort, it's just that the POKEY has a 16 bit mode that treats two 8 bit registers / voices as a single entity, thereby giving you 16 bits worth of frequency.
Have you been doing frequency measurements with the chip itself? Some of your math is a bit off from what I have measured and tested, that's why I ask. The data sheet is misleading in a couple spots and you can end up with worse tuning at high frequencies.
Hit me up sometime, I don't know how to get in contact with you : )
The guy is totally just, and there is no skepticism.
Post a Comment