| TED Sound Generation Internals | Programming/Audio
These are notes from TLC about the TED's internal working regarding sound generation.
(Some introduction.)
The TED is completely digital on the inside (except some things related to the image generation). Therefore all transistors are open or closed. Each one can be a logical 0 or a logical 1.
The TED only has one clock. On a PAL TED, this is 17.73447MHz, on NTSC it's 14.31818MHz. Each working frequency inside the machine is derived from this value (divided with a whole number). This includes the line and frame frequencies as well. The single clock is 17.734470/20 =~ 0.886MHz on PAL.
The sound generator uses this as well. The engine is using a fourth of the single clock. Internally there's a counter, which when reaches the set value, changes an internal bit to the opposite state, and starts counting again. The output of this 1-bit value is the well known square wave, and the length of the counting is the frequency value written into the TED. Therefore the master clock signal divided by some number is what can be used as frequency. The frequencies are calculated as 17.734470/20/4/value/2 (the last division by 2 is there because one note period is generated from two flips of the logical value, since one square wave has an up and a down part).
(Did you ever wonder why the value $03FF - the highest possible - produces a low frequency? Read on!)
We have to mention the relationship of "value" (in the above formula) and the value written into the TED registers. This is a little muddled, because they wanted to minimize the size of the circuit. The internal counter is actually counting UP, and when it reaches $03FF, it gives the command to flip the 1-bit value and start counting again. But actually it's not doing the reset exactly like that. Rather is specifies what the next increased value should be, the counter itself, or the (start) value. Because of this, there are two special cases, and many regular ones. If you write $03ff into the TED's frequency register, then the internal counter wraps around first, and then counts up to $03FF, and only THEN does it flip. Meanwhile it counts exactly $0400/1024. So the generated frequency is 17.734470/20/4/1024/2, or 108,242614746Hz. This is the lowest possible freq that the TED's sound generator can produce. The other special case is $03FE, which you may be familiar with from digi tables. This value, when increased, will ALWAYS be $03FF, therefore reload. Because of the simple design, the signal coming from the counter stays on 1. Since the flipping of the sound bit is caused by the signal "going into 1" (not being 1), the 1-bit value for the sound "stays standing", and eventually loses its value and becomes 1. In every other case: the length of the counter is actually $03FF-(start value). For example, writing 0 into the register is $03FF-0 = $03FF or 1023. So the generated frequency is 17.734470/20/4/1023/2, or 108,348423754Hz. Another interesting value is $03FD. The period length is $03FF-$03FD = 2. 17.734470/20/4/2/2 = 55 420,21875Hz, this is the highest possible frequency that can be generated (sometimes used in digi tables as ultra-sound).
(And the noise generator?)
And finally the noise generator. It uses a feedback(?visszacsatolt?) shift-register. These have a line of bits, the TED has 8, each bit "steps" once in one direction, and the empty space is filled with a XOR-ed value. These are widely used as random number generators, since the period length (unless the configuration is messed up) is usually 2^n-1 in length (for example, an 8 bit one will only generate the same numbers after 255 steps). Well, the TED uses one of these. The register's side place value is the actual "noise" waveform, and the step value is the 1-bit value coming out of the sound generator (mentioned above). What's most important to note here is the fact that the shift-register steps once every sound generation period. That is, taking the best case scenario (we are in a phase where each step of the shift register is causing the bit to flip), the output of the noise generator will only flip half as many times as the sound generator, therefore the produced frequency - even in the best case scenario can only be half of the sound's. However, the noise generator can and will produce repeating bits, which decreases the frequency of the flips and therefore the overall frequency as well. Therefore the generated frequency is in some relationship with the frequency set, it's a half, third, sixth, etc., so there's a harmonic relationship, but it's definitely a lower frequency.
|
| |
Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon |