VOGONS


CMS/GameBlaster emulation thread

Topic actions

Reply 60 of 63, by stripwax

User metadata
Rank Newbie
Rank
Newbie

Demystifying a couple of other things: different versions of the datasheet have meaningfully different contents I think. At least one version states this (which I didn't realise until just now):

If the frequency channel controlled is off (NE = FE = 0) the envelope will appear at the output, which provides an alternative "non-square" tone capability. In this event the frequency will be the envelope rate, which provided the rate is from the frequency channel, will be a maximum of 1kHz. Higher frequencies of up to 2kHz can be obtained by the envelope resolution being halved from 16 levels to 8 levels. (Rates quotes are based on an 8MHz clock)

So I guess my note above about whether this is by design or undocumented can now be disregarded 😀

There's also a note in the datasheet that says:

The SAA1099 uses pulse width modulation to achieve amplitude and envelope levels ... The amplitude and envelope signals chop the output at a minimum rate of 62.5kHz.

That puzzled me until just now - I think that refers to the following combination:
Frequency enabled, Noise enabled, Amplitude set to 2 and Envelope set to 1.
Under this scenario, per my table above, the combination of the amplitude + envelope patterns ANDed together yields one pulse every 64 cycles; and by mixing both frequency and noise then the pulse will occur only on even periods (since odd periods contribute noise); assuming the noise is generating a zero level then the combination yields just one pulse every 128 cycles, or 62.5kHz at 8MHz clock.

Last edited by stripwax on 2018-11-20, 00:02. Edited 2 times in total.

Reply 61 of 63, by stripwax

User metadata
Rank Newbie
Rank
Newbie

Just thought about this too:

HLHHHHHHHHHHHHHL LLLLLLLLLLLLLLLH HLHHHHHHHHHHHHHL LLLLLLLLLLLLLLLH ....
^ ^ ^ ^

So.. that makes me think the tables are wrong by 4 cycles actually. If I shift all the tables by 4 cycles, I think this just works, and then we also know the answer to what was discussed much earlier: "what is the actual alignment of these PDM sequences". It's probably easier to believe that the flipping between tone/noise/tone/noise when mixing both tone and noise occurs at clock cycle 0, rather than at clock cycle 60. I'd be willing to bet that we get the real PDM tables:

AMPLITUDE PDM SEQUENCES
0: 0000000000000000000000000000000000000000000000000000000000000000 = 0
1: 0000000011110000000000000000000000000000000000000000000000000000 = 4/64
2: 0000000000001111111100000000000000000000000000000000000000000000 = 8/64
3: 0000000011111111111100000000000000000000000000000000000000000000 = 12/64
4: 0000000000000000000000000000000000001111111111111111000000000000 = 16/64
5: 0000000011110000000000000000000000001111111111111111000000000000 = 20/64
6: 0000000000001111111100000000000000001111111111111111000000000000 = 24/64
7: 0000000011111111111100000000000000001111111111111111000000000000 = 28/64
8: 1111000000000000000011111111111111110000000000000000111111111111 = 32/64
9: 1111000011110000000011111111111111110000000000000000111111111111 = 36/64
10: 1111000000001111111111111111111111110000000000000000111111111111 = 40/64
11: 1111000011111111111111111111111111110000000000000000111111111111 = 44/64
12: 1111000000000000000011111111111111111111111111111111111111111111 = 48/64
13: 1111000011110000000011111111111111111111111111111111111111111111 = 52/64
14: 1111000000001111111111111111111111111111111111111111111111111111 = 56/64
15: 1111000011111111111111111111111111111111111111111111111111111111 = 60/64
ENVELOPE PDM SEQUENCES
0: 0000000000000000000000000000000000000000000000000000000000000000 = 0/64
1: 0000000000001000000000000000100000000000000010000000000000001000 = 4/64
2: 0000010000000100000001000000010000000100000001000000010000000100 = 8/64
3: 0000010000001100000001000000110000000100000011000000010000001100 = 12/64
4: 0011000000110000001100000011000000110000001100000011000000110000 = 16/64
5: 0011000000111000001100000011100000110000001110000011000000111000 = 20/64
6: 0011010000110100001101000011010000110100001101000011010000110100 = 24/64
7: 0011010000111100001101000011110000110100001111000011010000111100 = 28/64
8: 1100001111000011110000111100001111000011110000111100001111000011 = 32/64
9: 1100001111001011110000111100101111000011110010111100001111001011 = 36/64
10: 1100011111000111110001111100011111000111110001111100011111000111 = 40/64
11: 1100011111001111110001111100111111000111110011111100011111001111 = 44/64
12: 1111001111110011111100111111001111110011111100111111001111110011 = 48/64
13: 1111001111111011111100111111101111110011111110111111001111111011 = 52/64
14: 1111011111110111111101111111011111110111111101111111011111110111 = 56/64
15: 1111011111111111111101111111111111110111111111111111011111111111 = 60/64

Reply 62 of 63, by stripwax

User metadata
Rank Newbie
Rank
Newbie

I've been thinking about this again recently 😀

With some more recent experiments, I observed absolutely no synchronisation between the PDM sequences and the frequency(tone/noise) generators.
And actually that makes sense; those can output bitstreams with different periodicity, whereas the PDM is essentially a 'static' density map that you can just AND with any 1/0 signal.
So I've convinced myself that the 'alignment' of PDM tables isn't really a thing; but in silicon it would probably be implemented as easily as possible 😉 - it's really just combinatorial logic on the outputs of a counter. I'm putting some vhdl thoughts here : https://github.com/stripwax/SAASoundVHDL

Reply 63 of 63, by superfury

User metadata
Rank l33t++
Rank
l33t++

So, the 64-bit tables for the 16 outputs are correct, but any change in the output signal (which is reprogrammed during any cycle) restarts output of the entries for the current level(0-15)? Which one should I use? The envelope or the amplitude PDM table?

Also it's running at 64 times the base frequency (8MHz)? My current implementation hasn't changed since my last post, which is currently at 1/4th of 14.31818MHz, which 16 samples for each input sample to play.
So it'd need to run it's samples at 14MHz in that case (to get 64 samples for each positive/negative volume)?
What if including positive/negative samples? Or is everything simply positive only (thus 0 is effectively negative (-5V instead of 0V for example))?

Or am I supposed to simply AND those two outputs together (one bit from both tables to get the PWM output to low-pass filter)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io