Was the SPC700's noise channel based on the 2a03's noise channel?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Was the SPC700's noise channel based on the 2a03's noise channel?

Post by psycopathicteen »

I wrote a song in famitracker and I've been busy converting it to SNES, and I've been trying to figure out if the noise channel in the spc700 works the same as the noise channel in the NES and I found this:

http://www.gamepilgrimage.com/sites/def ... apudsp.txt
The noise generator seems to function something like this: On reset, N=0x4000. Each update (see FLG), N=(N>>1)|(((N<<14)^(N<<13))&0x4000). And the output noise sample at any point is N (after which is volume adjustment then the left-shift to 'restore' the low bit).
https://www.nesdev.org/wiki/APU_Noise#: ... %20counter.
When the timer clocks the shift register, the following actions occur in order:

1) Feedback is calculated as the exclusive-OR of bit 0 and one other bit: bit 6 if Mode flag is set, otherwise bit 1.
2) The shift register is shifted right by one bit.
3) Bit 14, the leftmost bit, is set to the feedback calculated earlier.
If both of these are accurate, then that means that the noise channel works the same in both systems. The only differences are that NES only outputs bit 14 whereas, the SNES outputs the whole shift register, and they have a different set of sample rates.
Last edited by psycopathicteen on Wed Jun 08, 2022 6:03 pm, edited 1 time in total.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by dougeff »

Noise was a common synth sound. Sony had probably made noise sounds in several other chips before this.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by rainwarrior »

Most chip noise was an LFSR with 1-bit output exactly like this.

Having more bits in the LFSR will just make it last longer before repeating. Like at higher frequencies you can easily hear it looping on the NES.

I haven't experimented with SNES noise but I'd be surprised if the actual sound output isn't just 1-bit, because that's the norm I'm used to seeing.

Edit: Apparently it really does output all bits!?
Last edited by rainwarrior on Fri Jun 10, 2022 3:30 pm, edited 1 time in total.
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by Drag »

The C64's SID chip is the only PSG I can think of off the top of my head which uses LFSR noise but outputs more than just 1-bit for the output.

Code: Select all

SID
22 = 0 xor 5.
Bit of output: 7  6  5  4  3  2  1  0
Bit of LFSR:   2  4  8 11 13 17 20 22
Other than that, yes, the most common PSGs at the time (e.g., 2a03, ay-3-8910, sn76489, pokey, and derivatives of each) all have 1-bit output for noise.

I suppose it makes sense the SNES's LFSR is the exact same as the NES's. Does it have the periodic mode too?
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by rainwarrior »

Yeah, since 1-bit noise at high enough frequency is functionally the same as multi-bit random noise, there's really no point in adding any hardware complexity for it? Unless for some reason it has an unusually low frequency limit...?

If anything, I think it adds nice possibilities for low-freqency "pitched" noise that is more satisfying sound-wise than what's possible with a multi-bit version.

SNES does not have periodic noise mode, AFAIK. Maybe you could fake it with echo?
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by Memblers »

There's the conversion lookup table from my old 2A03 emulator. The SPC has more choices for low frequencies, while the NES has more choices for high frequencies. In practice, the high frequencies don't sound much different from each other.

Code: Select all

;======================================================================
;       DSP value            NES reg    NES noise freq  SPC noise freq
;----------------------------------------------------------------------
noise_freq_table:
        .db 00111111b           ; $0                    32mhz
        .db 00111111b           ; $1                    32mhz
        .db 00111111b           ; $2                    32mhz
        .db 00111111b           ; $3                    32mhz
        .db 00111111b           ; $4                    32mhz
        .db 00111111b           ; $5                    32mhz
        .db 00111110b           ; $6                    16mhz
        .db 00111110b           ; $7                    16mhz
        .db 00111110b           ; $8    16744.04mhz     16mhz
        .db 00111110b           ; $9    14080hz         16mhz
        .db 00111100b           ; $A    9397.28hz       8.0mhz
        .db 00111011b           ; $B    7040hz          6.4mhz
        .db 00111001b           ; $C    4698.64hz       4.0mhz
        .db 00111000b           ; $D    35200hz         3.2mhz
        .db 00110101b           ; $E    17600 hz        1.6mhz
        .db 00110010b           ; $F    880 hz          800hz
;======================================================================
Atari's TIA and POKEY chips also use LFSRs, for everything. The Lynx actually lets you select which LFSR bits are tapped, but in existing music for the Lynx, it's simply set to sound like normal square waves.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by creaothceann »

Memblers wrote: Wed Jun 08, 2022 11:32 pm The SPC has more choices for low frequencies, while the NES has more choices for high frequencies. In practice, the high frequencies don't sound much different from each other.
Not sure if relevant, but afaik the SNES also has a low-pass filter in its audio output stage.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by psycopathicteen »

Memblers wrote: Wed Jun 08, 2022 11:32 pm There's the conversion lookup table from my old 2A03 emulator. The SPC has more choices for low frequencies, while the NES has more choices for high frequencies. In practice, the high frequencies don't sound much different from each other.

Code: Select all

;======================================================================
;       DSP value            NES reg    NES noise freq  SPC noise freq
;----------------------------------------------------------------------
noise_freq_table:
        .db 00111111b           ; $0                    32mhz
        .db 00111111b           ; $1                    32mhz
        .db 00111111b           ; $2                    32mhz
        .db 00111111b           ; $3                    32mhz
        .db 00111111b           ; $4                    32mhz
        .db 00111111b           ; $5                    32mhz
        .db 00111110b           ; $6                    16mhz
        .db 00111110b           ; $7                    16mhz
        .db 00111110b           ; $8    16744.04mhz     16mhz
        .db 00111110b           ; $9    14080hz         16mhz
        .db 00111100b           ; $A    9397.28hz       8.0mhz
        .db 00111011b           ; $B    7040hz          6.4mhz
        .db 00111001b           ; $C    4698.64hz       4.0mhz
        .db 00111000b           ; $D    35200hz         3.2mhz
        .db 00110101b           ; $E    17600 hz        1.6mhz
        .db 00110010b           ; $F    880 hz          800hz
;======================================================================
Atari's TIA and POKEY chips also use LFSRs, for everything. The Lynx actually lets you select which LFSR bits are tapped, but in existing music for the Lynx, it's simply set to sound like normal square waves.
Why are those frequencies an octave higher than the ones on nesdev wiki?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by lidnariq »

psycopathicteen wrote: Wed Jun 08, 2022 5:43 pm whereas, the SNES outputs the whole shift register,
Tepples has previous pointed out that this means the SNES LFSR noise is effectively convolved with a [1 1/2 1/4 1/8 1/16 1/32 1/64 1/128 1/256 ... 1/16384] FIR lowpass filter, which is effectively a -10dB/decade (half of a normal lowpass)
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by rainwarrior »

Ah! So it really does output all of its bits? That's interesting.
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by Drag »

Is it actually outputting the entire contents of the LFSR all at once, with each bit at a different amplitude? Or is it just doing something like Out = Out/2 + LFSROut? It's important to know which it's actually doing because it'll sound different at lower frequencies.

Either way, the convolution is a neat trick I never would've thought of. :D
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by rainwarrior »

Drag wrote: Fri Jun 10, 2022 5:57 pmIs it actually outputting the entire contents of the LFSR all at once, with each bit at a different amplitude? Or is it just doing something like Out = Out/2 + LFSROut?
That should already be inherent in the LFSR. "Out = Out/2 + LSFROut" is equivalent.

Each step feeds a new "random" bit in on one end, and then the other bits are shifted.

So, each individual bit counts once at every power of 2 magnitude as it travels through the shift register, and is summed with all the other bits each on a similar journey.


Also, at least according to bsnes, it does not interact with the gaussian interpolation that samples get.


Edit: Apparently the output is signed, and this seems to produce a highpass rather than lowpass effect! See a description on the next page of discussion.
Last edited by rainwarrior on Mon Sep 05, 2022 4:17 am, edited 1 time in total.
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by Drag »

rainwarrior wrote: Fri Jun 10, 2022 6:14 pm That should already be inherent in the LFSR. "Out = Out/2 + LSFROut" is equivalent.

Each step feeds a new "random" bit in on one end, and then the other bits are shifted.

So, each individual bit counts once at every power of 2 magnitude as it travels through the shift register, and is summed with all the other bits each on a similar journey.
This is also what I thought initially, and they're indeed equivalent if the LFSR is clocked for every output sample, but what happens when the period is 2 instead?

Code: Select all

Out = Out/2 + LFSROut
1 A -> A
2 A -> A
3 B -> A/2 + B
4 B -> A/4 + B
5 C -> A/8 + B/2 + C
6 C -> A/16 + B/4 + C

Out = LFSR[0] + LFSR[1]/2 + LFSR[2]/4 + ...
1 A -> A
2 A -> A
3 B -> A/2 + B
4 B -> A/2 + B
5 C -> A/4 + B/2 + C
6 C -> A/4 + B/2 + C
After 6 steps, the results are different between the two methods, and they'll diverge even more as the period is set even higher (i.e., lower pitched noise). That's why I was wondering which method is used. (Sorry, I made one of my ninja edits after I made the post and realized about the higher period issue, if that bit wasn't there originally :P)
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by rainwarrior »

Oh, well yes I don't believe there is any kind of separate convolution, it's just the one inherent in the operation of the LFSR, so it would be at the same period as the noise itself.

At least in bsnes' code, m.noise is the LFSR itself, and it just replaces the sample output directly. No separate shift register, or interaction with the gaussian interpolation, or anything like that.
turboxray
Posts: 348
Joined: Thu Oct 31, 2019 12:56 am

Re: Was the SPC700's noise channel based on the 2a03's noise channel?

Post by turboxray »

Heh. I could have sworn noise mode was also filtered. I remember being impressed by LttP rain noise (louder and quite depending if you're in a house or outside)... and I see that it just has a noise "sample" hahah. Fooled me.
Post Reply