MobyGamer wrote on 2022-08-29, 18:48:
The 1/2 mixing rate vs. output rate is a good tradeoff to eliminate the PC Speaker carrier noise, for sure. (Some games in the late 80s did that.)
Yes, this is the Goal, I realized how to do it only some days ago:
When doing the Loop to apply the conversion to the Timer value, write the result twice.
Otherwise, it require to change the Timer IRQ and slow it down...
AND we can take the opportunity to Add Linear interpolation 😀 It is "Just a SUB / SHR / ADD" and may improve the result.
MobyGamer wrote on 2022-08-29, 18:48:
For the PWM conversion table, here's how I do it: Values are 1 to N where N is (1193182 / samplerate) -1. The 1 to N-1 range ensures no timer issues (0 will actually count down as 65536 in some timer modes). However, there is still "beating" between the PIT divisor and the DRAM refresh divisor (18), so for 100% clean results, you must use a divisor that is a multiple of dram refresh. So for no carrier whine and no beating, you can use divisors of 36 (33144 Hz), 54 (22096 Hz), and 72 (16572 Hz). IMO, the only practical choices are 54 and 72, as they are close to "6-bit" results. Going faster (18, 66286 Hz) means you're effectively down to 4-bit audio, and would need a 486 to play back anyway.
I will take a look.
If the Interrupt frequency is too low, there PWN does not work well (We can't really call it PWN with so low frequencies) and the Timer delay can't cover the full period.
Then, it may be always better to output at around 16KHz, even if the mixing rate is lower.
We can also mix at 10KHz and scale the result, it will always be faster than mix at 16KHz. Why not...
But I think that 8KHz Mix, 16KHz output will be the only possibility for a 5150 with 4 Channels.
MobyGamer wrote on 2022-08-29, 18:48:
I was able to achieve divisor 54 (22KHz) on a 4.77MHz 8088, but it required the PIC to be set to auto-EOI, and that had some side effects, so I don't recommend rates that high on 4.77 MHz systems.
Somebody already asked me for Auto EOI, I never tried and as I don't understand its initialization code, I am quite "frightened" to test.
If I have time, maybe implement both, in case of compatibility issue .
If one day, I can motivate some PPls to work on an Amstrad PC1512 Demo, I would like to try having an end screen with an 8 Channel module (Or more) on the PC Speaker... This can be cool 😀