How does the NES Sound processor (2A03) produce the noise waveforms? - Page 1
Forum section: electronics / beginners

author: Deactivated-1
author_rank: Frequent Contributor
timestamp: July 01, 2022, 03:59:15 am
content: the built-in Audio Processing Unit in the 2A03 in the NES has a noise channel, which has 2 modes, one sounds like static and other more metallic and gritty.but how does it make these waveforms? also how does it make it sound like a specific pitch?

author: radiolistener
author_rank: Super Contributor
timestamp: July 01, 2022, 04:15:25 am
content: probably the same as it implemented in AY8910/YM2149F PSG chip - random noise generator on linear feedback shift register which output is feed into programable divider to allow select noise frequency.I don't know about 2A03, but AY8910/YM2149F also allows to change volume and it includes several predefined envelopes, so the noise can be modulated with AM.

author: taste_tester
author_rank: Regular Contributor
timestamp: July 03, 2022, 01:34:19 am
content: The noise generator is a linear-feedback shift register in an 8 bit chip, so it's almost certainly using some kind of pseudorandom number or noise generator, which explains why the output seems consistent.

author: BrianHG
author_rank: Super Contributor
timestamp: July 03, 2022, 02:39:32 am
content: Just about the same as the C64 SID:https://en.wikipedia.org/wiki/Linear-feedback_shift_register

author: BrianHG
author_rank: Super Contributor
timestamp: July 03, 2022, 11:46:16 pm
content: 93 bits is the width of the LFSR. Take a look at the SID random noise. It is only an 8 bit output dac, but they use a 23bit LFSR so that the generated noise will achieve all possible numbers over time. Read the linked WIKI. Take a look at their example and follow the logic in your head. That 16bit example will not achieve the 65536 states they claim if you just run the thing indefinitely. Unfortunately, they will hit a smaller repetitive loop of numbers well below 65536. But if you only use the bottom 8 bit out as an 8 bit random number generator, then you will possibly achieve a pattern with 256 steps, but only a few thousand possibilities before it repeats. This is why the 8bit SID uses 23 bits for it's random number generator as the pattern it generates is large enough to not create an audible repetitive sub-tone. An 8 bit LFSR just wouldn't be enough. Even using 8 bits out of a 16bit LFSR might have generated an acoustic sub-tone as that counter would repeat every few k clock cycles, and if your sample playback is 10 or 20 Khz, buried repetitious pattern may generate something you may be able to hear.

author: BrianHG
author_rank: Super Contributor
timestamp: July 04, 2022, 12:07:05 am
content: Quote from: ELS122 on July 03, 2022, 11:54:45 pmNo, I never said that.I said that a 16 bit LFSR would achieve less than 65536 patterns before it looped. Something like 10k cycles at it's maximum before a repeat number comes and the cycle restarts. So, an approximate 24 bit LFSR (utilizing it's bottom 16 bits as your random number) should do an adequate job. Not a 32767 bit LFSR. For a 32bit number, I use a 43bit LFSR XORED with a 37 bit CASR random number generator running in parallel, see here:https://github.com/BrianHGinc/BrianHG-DDR3-Controller/blob/c901baa0c41ae46389940ae729cc772c8d40a8f1/BrianHG_DDR3_GFX_source_v16/BrianHG_draw_test_patterns.sv#L527That is not a 4 billion bit LFSR to generate a random 32bit number.