Same noise reproduced on every executation possible?

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Same noise reproduced on every executation possible?

Post by Banshaku »

From what I understand, the noise channel uses some random seed that would influence what will come out of it and must be defined at power on (I guess). What I would like to know is if there is a way to "reset" that seed so the same sound could be reproduced every time, on request?

I'm curious and just want to know if it is possible or not and why is that so.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Same noise reproduced on every executation possible?

Post by tepples »

I assume you want to reset the noise LFSR without using the "test mode" at $4018-$401A. But even that allows only a triangle phase reset, not noise.

Related question: Is there a sequence of 32767-step and 93-step clocks that ends up in a single defined state? I imagine it'd take deep math in finite field GF(215) to answer that. But if the answer is yes, it implies a yes answer for Banshaku's question.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Same noise reproduced on every executation possible?

Post by rainwarrior »

The noise LFSR is seeded with all zeroes on reset, AFAIK. If you wanted to count cycles from that point, you could guarantee its sound.

If you're asking whether you can reseed it at will in the middle of execution? No.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Same noise reproduced on every executation possible?

Post by Banshaku »

@rainwarrior

Yes, this is what I meant: execute a sound fx, reset the seed, execute it again with the same sound. One effect I had sounds better on the first run in famitracker. Once you execute it many time, it doesn't sound the same anymore. If it was resettable that would been useful in one specific case only. Oh well!
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Same noise reproduced on every executation possible?

Post by lidnariq »

tepples wrote:Related question: Is there a sequence of 32767-step and 93-step clocks that ends up in a single defined state?
Hm. From a probabilistic point of view, exactly 1/4 each of all 32768 states clock in a 0, a 1, the tonal noise mode bit "M", or "not M".
So ... it's not obviously the case that such a path will exist.

edit: but the real question is whether there's any usefully different probabilities between the state at a given time, and some finite number of clocks later. Obviously the only correlations would be after some combination of 8, 13, and 13-8 clocks (e.g. starting from state 256, which becomes either 512 or 513 depending on "M". When 512 or 513 hit 8192 or 8208, the value of the "M" bit will matter again:
256 -nM→ 512 → 1024 → 2048 → 4096 → 8192
256 -M→ 513 → 1026 → 2052 → 4104 → 8208
8192 -nM → 16385 → 3 → 6 → 12 → 24 → 48 → 96 → 192 → 384
8192 -M→ 16384 → 1 → 2 → 4 → 8 → 16 → 32 → 64 → 128 → 256
8208 -nM→ 16417 → 67 → 134 → 268
8208 -M→ 16416 → 65 → 130 → 260

But I don't think I have enough knowledge to handle this.
rainwarrior wrote:The noise LFSR is seeded with all zeroes on reset, AFAIK.
To be clear: the noise LFSR just happens to have all 0s on initial power up. A warm reset (or even an "insufficiently" cold boot) won't reset its contents.

edit:
tepples wrote:I assume you want to reset the noise LFSR without using the "test mode" at $4018-$401A. But even that allows only a triangle phase reset, not noise.
But it does let you read out the current noise LFSR state, and because LFSRs, reading 15 bits from it will let you know what the current contents are, and knowing the current state lets you calculate a path to any desired state.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Same noise reproduced on every executation possible?

Post by lidnariq »

Just to follow up on this, because the problem is small enough to be brute-forceable... (2^30)

There is no sequence of clocking the noise channel with your choice of "M" bit set or not set after each clock such that starting from an unknown state will converge on a known state.

From all possible starting states, for all possible 15-clock sequences, you can count the number of bits set. It you sum these bit counts, grouping by sequence, this sum is always 245760, or exactly 32768×7.5. If it were going to converge on some known state, the average would have to converge on an integral number of bits.
Post Reply