It is currently Thu Oct 18, 2018 8:45 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Noise Channel LFSR
PostPosted: Thu Aug 14, 2014 7:32 pm 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
NES Dev Wiki wrote:
This results in a pseudo-random bit sequence, 32767 steps long when Mode flag is clear, otherwise 93 steps long (the particular 93-step sequence depends on where in the 32767-step sequence the shift register was when Mode flag was set).


I did a brute force checking of this fact, using the algorithms supplied on the wiki. It seems there are 31 "seed values" that result in a 31 step sequence instead of 93.

The code can be found here. I'm just making sure this is correct. If so, the wiki should be adjusted to mention it.

There is no such discrepancy for the 32767 step sequence.


Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Thu Aug 14, 2014 10:19 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6887
Location: Canada
Yes, I believe that is correct. Sometimes you get an "off" note from the periodic noise.


Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Fri Aug 15, 2014 3:53 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7658
Location: Seattle
Does that mean that there's precisely one 31-period loop, and all the other possible states of the LFSR are the null state (period 1) and 352 different 93-period loops?

Hm. Yes, that does seem to be the case.
There is one 31-period sequence that contains the 31 states (in decimal) 10519 12211 13190 13602 14442 16078 1700 17234 17910 18622 19994 21039 21643 22979 24423 25001 26381 27205 27873 28884 30320 3052 31544 32156 3400 4477 6105 6801 7221 8955 9311, and the FFT of same implies that the resultant waveform is just an impulse train (since the 3rd, 6th, 9th, &c harmonics are all the same magnitude and all others are 0)

There are 209 total different tone colors the tonal noise can make (including the silent null state) :
$ ./tonal | cut -f 1 -d : | sort -n | uniq | wc -l
209

The 352 different 93-period loops break down into 207 tone colors; of those 62 are unique, and the other 145 exist twice (forwards and backwards bitstreams?) There seems to be no obvious correlation between volume of fundamental or presence/absence of 31st harmonic (whose presence is, notably, boolean)


Attachments:
File comment: compile with " gcc tonal.c -lfftw3 -lm "
tonal.c [974 Bytes]
Downloaded 79 times
Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Sat Aug 16, 2014 9:16 am 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
lidnariq wrote:
Does that mean that there's precisely one 31-period loop


correct, there is only one 31-step loop, with 31 possible entries into it from the 32767-step form (since the 32767-step form will generate all unique values).

could the wiki be updated with this information? right now there is no mention of the 31-step form, only the 32767 and 93-step forms.


Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Sat Aug 16, 2014 11:28 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7658
Location: Seattle
Already got it.


Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Sat Aug 16, 2014 11:58 am 
Offline

Joined: Mon Sep 27, 2004 2:57 pm
Posts: 1256
I'm not sure this is necessary to have on the wiki like that, because it is canonically 93 steps, with the 31 step sequence being more of an artifact of having a weird seed (especially moreso because only one seed generates it, it just feels like more attention is being brought to it than necessary). Maybe put it as a sidenote instead?


Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Sat Aug 16, 2014 2:01 pm 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
Drag wrote:
especially moreso because only one seed generates it


Technically speaking, there are 31 seed values that jump you into the 31-step loop. :)

Drag wrote:
Maybe put it as a sidenote instead?


I agree that it should be mentioned as a quirk, since only ~0.09% of the seed values send you along the 31-step path. I'll be whipping up a little test later to make sure this does indeed happen on hardware in the mean time (It almost certainly does).


Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Sun Aug 17, 2014 6:13 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7658
Location: Seattle
Well, from a musical point of view, the 31-period doesn't matter, but the largely unpredictable ratio of harmonics does. Even just among the 93-period sounds there's a wide variety of different strengths of each of the first three harmonics:
Attachment:
graph-of-tonal-noise-harmonics.png
graph-of-tonal-noise-harmonics.png [ 8.91 KiB | Viewed 2323 times ]
Legend:
Purple: the period 31 defective case, right next to some of
Green: the set of period 93 that only occur once, producing an outline around
Blue: the set of period 93 that occur twice, making a wavy surface.
Red: the set of period 93 that have a loud 31st harmonic

I made this graph using gnuplot, source files attached. In the actual program you can drag around the camera to actually be able to visualize the surface.


Attachments:
tonal-noise-gnuplot.zip [2.11 KiB]
Downloaded 72 times
Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Sun Aug 17, 2014 6:16 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20667
Location: NE Indiana, USA (NTSC)
Try making eight frames of this plot a degree apart from each other and tossing them in an animated GIF. I wonder how that'd look.


Top
 Profile  
 
 Post subject: Re: Noise Channel LFSR
PostPosted: Sun Aug 17, 2014 6:37 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7658
Location: Seattle
Here's something rotating about (45°+10°·sin(t),45°+10°·cos(t)). The purple point for period=31 is off the left side of the viewport.
Attachment:
rotating-tonal-noise-harmonics.gif
rotating-tonal-noise-harmonics.gif [ 39.46 KiB | Viewed 2317 times ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group