OK the triangle wave trick is as follows:
we use channel 1 and 3 at 1.79mhz, but without filtering.
now poking relatively high values to audf1 and audf3 results in inaudible high notes (above 20 khz), but when they differ slightly, they interfere, giving a sub-harmonic tone
the frequency FR of the resulting tone is:
FR = (F1 - F3) /2
knowing that (with known pitch P1 and P3 values) F1 and F3 are given by this:
F1 = Phi/(2*(P1+4)) ; F3 = Phi/(2*(P3+4)) where Phi is the main computer clock (PAL: Phi = 1773447, NTSC: Phi = 1789790)
Now, if we set a pitch P1 = P and P3 = P+1 we get minimal unwanted overtones
Turning on the real hardware you may do this:
* first make sure all voices are enabled:
sound 0,100,10,10 : end
Pokey=53760: poke Pokey+8,96: poke Pokey+1,175:poke Pokey+5,175
Here: distortion A and volume F is used on both channels 1 and 3, and 1.79mhz clocking is turned on
poke Pokey,27: poke Pokey+4,28
Then, on PAL machines, you might hear a 440Hz note (A)
Now, how to compute the pitch values from the needed frequency:
If P3 = P1 + 1, then:
FR = Phi/(2*(P1+4)*(P1+5))
inverting this relation to get P1 from FR we apply the abc-formula:
P1 = -4.5 + 0.5*SQR(1+Phi/FR)
poke Pokey,P1: poke Pokey+4,P1+1
gives the wanted frequency.
Similar formulas can be constructed for filtered instruments e.a.
Edited by analmux, Tue Jul 12, 2005 2:31 PM.