Noise Test Program

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Noise Test Program
by on (#208030)
Nothing special and I'm sure similar programs have been made before, but here is a quick noise channel test program made by request to be used to quickly test if the looped noise test mode flag works on real Famicoms via a flashcart or other devcart solution. I'm posting it here so that it becomes hosted, and in case someone would need it. It's stitched together from several general purpose routines from my own personal library, so it may have lots of redundant code that's never executed.

If someone spots any bugs, mistakes or have other suggestions regarding it, just shout here.

Image
Re: Noise Test Program
by on (#208034)
I like it. Pretty simple and easy to use. Maybe didn't expect to have to press A to apply settings but that's an arbitrary choice I guess, was easy to understand anyway.
Re: Noise Test Program
by on (#208056)
Thanks! Yeah I first planned it to change settings as soon as you select them, but this was easier to do.

Not sure if looped noise is the best term though? I've also seen the term periodic noise. If I understand it correctly, looped noise means that the random wave pattern is shorter or loops faster which makes it more tonal in most pitch settings (pitch $0F doesn't seem to sound any different with the flag set or cleared). Neither terms looped or periodic makes sense to me, the period of a wave is always looping right?
Re: Noise Test Program
by on (#208065)
Both "periodic" and "looped" describe what it does. Technically it's always looped, but the loop is just much longer (like 300 times longer). With this mode on, the loop is short enough to play a pitch on most of its frequencies, rather than a just a repeating noise, the threshold for that is somewhere around 10Hz.

So... the lowest frequency $F is too low to be a pitch, maybe ~2Hz when it's in periodic mode, but it's more like 0.006Hz when it's not. A fast loop repeating twice a second vs. one that's minutes long, too long to notice the looping. Around about $C the periodic mode starts turning into a musical pitch where instead of a repeating noise you just hear a tone.

You should be able to hear a difference in all of them, but not all of them become a pitch.

The actual mode is kind of a short circuit of the LFSR that generates the noise, moving the tap to send the feetback into the LFSR more frequently. The shorter sequence that comes out changes depending on what state it was in when you turned on the periodic noise mode, so the pitched sound changes in character if you turn periodic mode on and off.

So as for terminology, I think "periodic" or "looped" are both fine, though if you want to get more precise maybe it's a "short period" or "short loop" mode? The idea is just that the period/loop becomes pretty noticeable in this mode. Sort of funnily, the length of the period of $0F in periodic mode is similar to the length of $01's period in non-periodic mode (but running at a much lower frequency). The range of rates is wide enough that it overlaps in this respect.
Re: Noise Test Program
by on (#208066)
The period-93 mode has the interesting additional property that it randomly contains a very loud 31st harmonic. There's no way for the CPU to detect whether it's in this mode (short of modifying the NES), so it's hard to use intentionally.

Previous things I've said:
3d graph of first 3 harmonics being random
A cold boot can get a very specific waveform from the period-93 mode that's musically useful

That said, the ×31 harmonic does mean that the very low rates actually become useful in tonal noise mode; the slowest rate there does repeat at 5Hz but it also has a conspicuously audible tone at 147Hz.
Re: Noise Test Program
by on (#208069)
Could you add a "semi-periodic" mode that toggles 93-step mode on and off by frames? The hi-hat sound in my NES chiptunes since 2011 alternates $03 and $83.
Re: Noise Test Program
by on (#208110)
Thanks for the explanation. So the mode flag cuts the period short enough to sound musical (in most pitches), although it's still really a random pattern generated by the hardware random generator.

I think "short period" describes it the best, but on the other hand "looped" take the least screen space, so I guess it's fine like it is. :)
Re: Noise Test Program
by on (#208112)
So tepples' hi-hat is one example of use. My two others are
-tiny bell/triangle (the instrument, not the waveform) approximations and
-error signals / "quirky machine sounds".

Sivak used the "error buzz" effect for the logo screen.
What else do you use it for?

I presume it would have some musical relevance if you detuned all other channels to match it, but then again you're confined to it 1)not being chromatic, 2)being a bit random in timbre as described.
Re: Noise Test Program
by on (#208132)
I use looped noise for an error buzz when the user is packing an order to ship out but scans a product that isn't on the order. (Yes, you read that right. I use FamiTracker to build sound effects for my employer's internal web application.)

The Curse of Possum Hollow uses it for a couple bosses (see attachments).

It's more useful on Game Boy where I can coax decently tuned C, D, F, and G# notes out of it.
Re: Noise Test Program
by on (#208139)
Sometimes it's just useful to be able to make a pitched sound effect that interrupts the noise channel rather than one of the squares.

It's very good for a "triangle" type sound (percussion instrument, not waveform), like in Solstice.

Often I like 1 frame of periodic noise at the start of an otherwise non-periodic noise instrument. It's good for a "metallic" chip at the start of the sound; sometimes that's good for suggesting something like a cymbal. Sometimes this is just useful for making a different sound that pokes through the rest of the noise, suggesting an extra voice of percussion that can play in its own independent rhythm.

The opposite, 1 frame of noise followed by periodic can be nice just to put an edge on the attack of the triangle type percussion too; not really trying to simulate its realistic sound, but still a useful way to give its attack some defined character.

Tepples mentioned an instrument that alternates between periodic and non every frame, which creates kind of a "fluttery" noise sound; I find this can be really good for sustained cymbal instruments, like a cymbal roll.

Shiru's LAN Master game uses periodic noise constantly for buzzing/beeping noises in the background music. Mega Man 2's Quick Man stage makes similar prominent use of it.

Sometimes people have tried to use the pitches of the noise unit to make melodies. Sivak's jingle was mentioned. I think B00daW did a few little tunes like this but I can't find them right now. Did tepples use it like this for a NIN cover? (Memory hazy.) This is kind of a problem if you want to support both NTSC and PAL, since they have different pitches. (Similar problem to DPCM.)

Anyhow, it's just another sound that you can use. If you try it out and remember the sound, maybe you'll occasionally think of places it might fit. Also, depending whether or not you care about the early Famicom that didn't have it, you may want to test everything with periodic noise disabled just to make sure it still sounds OK without it.
Re: Noise Test Program
by on (#208140)
rainwarrior wrote:
Sometimes people have tried to use the pitches of the noise unit to make melodies. Sivak's jingle was mentioned. I think B00daW did a few little tunes like this but I can't find them right now. Did tepples use it like this for a NIN cover? (Memory hazy.)

On the Game Boy, not the NES. The pitches of Game Boy looped noise are exactly those of "Wish" from Broken.
Re: Noise Test Program
by on (#208149)
I think this is the thing by b00daw I was thinking of, but it doesn't really use noise as a melody, it's mostly an experiment with using 360Hz update rates, it seems:
https://forums.nesdev.com/viewtopic.php?f=6&t=9126

Sort of related, I once wrote a short piece of music around the NTSC DPCM frequencies and retuned everything else to match it:
https://forums.nesdev.com/viewtopic.php?p=92494#p92494

The equivalent is possible for noise, to some extent, but even with the DPCM scale I thought found it too restricting. It was fun to write that one little tune, but I doubt I'll ever try to write more music with that technique. (Sometimes harsh limitations can stimulate interesting ideas, but I'm tapped out for that one.)
Re: Noise Test Program
by on (#208153)
rainwarrior wrote:
The equivalent is possible for noise, to some extent, but even with the DPCM scale I thought found it too restricting. It was fun to write that one little tune, but I doubt I'll ever try to write more music with that technique. (Sometimes harsh limitations can stimulate interesting ideas, but I'm tapped out for that one.)
It doesn't help that the frequencies on an NTSC deck (in period 93 mode) are ~45cents out of tune with A440, while the 31st harmonic is in tune with A440.

Code:
 div 93freq 12TETA440 3freq    12TETA440
   4 4811.2 D-8+41.0 /149147.7 ultrasonic
   8 2405.6 D-7+41.0 / 74573.9 ultrasonic
  16 1202.8 D-6+41.0 / 37286.9 ultrasonic
  32  601.4 D-5+41.0 / 18643.5 ultrasonic
  64  300.7 D-4+41.0 /  9321.7 D-9-14.0
  96  200.5 G-3+39.0 /  6214.5 G-8-15.9
 128  150.4 D-3+41.0 /  4660.9 D-8-14.0
 160  120.3 B-2-45.3 /  3728.7 A#7-0.3
 202   95.3 G-2-48.9 /  2953.4 F#7-3.8
 254   75.8 D#2-45.4 /  2348.8 D-7-0.4
 380   50.6 G#1-42.8 /  1570.0 G-6+2.2
 508   37.9 D#1-45.4 /  1174.4 D-6-0.4
 762   25.3 G#0-47.4 /   782.9 G-5-2.3
1016   18.9 subsonic /   587.2 D-5-0.4
2034    9.5 subsonic /   293.3 D-4-2.1
4068    4.7 subsonic /   146.7 D-3-2.1


PAL is even more of a mess; the lower tones are pedantically still ~45cents out of tune, but the higher ones range all over place:
Code:
 div 93freq 12TETA440 3freq    12TETA440
   4 4469.4 C#8+13.4 /138550.6 ultrasonic
   8 2234.7 C#7+13.4 / 69275.3 ultrasonic
  14 1277.0 D#6+44.6 / 39585.9 ultrasonic
  30  595.9 D-5+25.1 / 18473.4 ultrasonic
  60  298.0 D-4+25.1 /  9236.7 D-9-29.8
  88  203.2 G#3-37.9 /  6297.8 G-8+7.1
 118  151.5 D#3-45.8 /  4696.6 D-8-0.7
 148  120.8 B-2-37.9 /  3744.6 A#7+7.1
 188   95.1 F#2+47.9 /  2947.9 F#7-7.1
 236   75.8 D#2-45.8 /  2348.3 D-7-0.7
 354   50.5 G#1-47.7 /  1565.5 G-6-2.7
 472   37.9 D#1-45.8 /  1174.2 D-6-0.7
 708   25.3 G#0-47.7 /   782.8 G-5-2.7
 944   18.9 subsonic /   587.1 D-5-0.7
1890    9.5 subsonic /   293.2 D-4-2.6
3778    4.7 subsonic /   146.7 D-3-1.7


By "93freq" I mean the lowest frequency represented by the LFSR when it's in "short" mode. By "3freq" I mean the frequency that's the Very Loud 31st harmonic. (93÷31=3)
Re: Noise Test Program
by on (#208154)
lidnariq wrote:
It doesn't help that the frequencies on an NTSC deck (in period 93 mode) are ~45cents out of tune with A440

Wait, to me that sounds helpful?

Like the DPCM frequencies are all consistently out of tune by a factor of 17/16 because of that off-by-one error in its loop implementation. I shifted the tuning tables in that NSF to compensate.

If the noise frequencies are a fairly consistent deviation from A440 then that in itself is helpful, because it can be compensated by tuning to A440 + 45 cents instead of A440.
Re: Noise Test Program
by on (#208155)
It was the contrast I was attempting to call out. The "fundamental" is a quartertone off relative to the louder 31st harmonic; only one or the other is in-tune with 12TET regardless of your tuning reference.
Re: Noise Test Program
by on (#208156)
Hrm, I didn't really see that as a problem, directly.

I mean that's a general problem with any emphasized harmonic that's not a power of two (or three is close), a lot of acoustic instruments have resonance that does that kind of thing... but I don't think it's unacceptable in most cases. E.g. I've played a marimba with very strong 5th harmonics, where if you wanted to focus on it you can listen to that tone instead of the fundamental, and it's completely out of tune with anything else playing with it. In context though, the other sounds guide you to the "correct" hearing of it and the out of tune harmonics are sort of de-emphasized psychologically, just one of the "non-tonal" components to the sound.

The noise channel does have the problem that you can't really control which loop you're going to get, but you could probably mitigate that issue just by letting it run in non-periodic mode to continually "randomize" between periodic tones. The majority of tones will establish the 93 step pitch.
Re: Noise Test Program
by on (#208160)
rainwarrior wrote:
The majority of tones will establish the 93 step pitch.
About 91% of the time... Out of the 32767 valid states for the LFSR, 2976 of them have the three-times-as-loud 31st harmonic. I guess that does seem pretty safe.

(By which I mean, when the 31st harmonic is present, it's 2.8x or ~9dB louder than any other harmonic component.)
Re: Noise Test Program
by on (#208163)
BTW anyone knows some licensed Famicom or NES games that use looped noise? All I could think of was Megaman 1 (Fireman music), Megaman 2 (Quickman music) and Balloon Fight (Game Over music, probably unintentionally). The guy that wanted to test this on his square button Famicom had a lot of games but not any of these.
Re: Noise Test Program
by on (#208167)
B00daws' tune sounds pretty amazing, although it would be rather impractical to run the audio engine at x6 speed. Sounds much like printer and floppy drive music, and it should, because what B00daw seems to do is start-stop alternate the channel just like the servo of a any such devise would (at least that's my understanding how they work).

Yeah, solstice is a great one. Very nice use of (orchestral) triangle. Part of it comes from it being a bit varied in different parts, and part because it is allowed to play solo here and there, i think.

That megaman tune (quick man) is a little above my threshold; wouldn't want to listen to that track outside its context. The off-pitch tuning is just too apparent. :S

The higher end pitches definitely have a bit of the character the cymbals' bell part. It might sound even better if you have a separate noise channel (Pretty obscure case: Sunsoft 5b) on an external synth chip and use the 93 noise for the bell decay, simultaneously. Harder hits = the drum stick hit closer to the center of the cymbal.


pokun wrote:
BTW anyone knows some licensed Famicom or NES games that use looped noise?

Aforementioned Solstice, main gameplay theme. I think it sounds off in this NTSC playback, though. It must've been composed for PAL. (warning: subjective random thought. i don't know what tim follin actually thought, of course. but i'd assume they used a PAL unit for testing.) Edit: Ninja'd.
Re: Noise Test Program
by on (#208173)
FrankenGraphics wrote:
pokun wrote:
BTW anyone knows some licensed Famicom or NES games that use looped noise?

Aforementioned Solstice, main gameplay theme. I think it sounds off in this NTSC playback, though. It must've been composed for PAL.

Sounds like bad filtering in audio emulation, actually. Here's a gameplay capture from the original machine: https://youtu.be/fXQDpxTkCAA?t=66 (although this one in turn suffers from audio compression).
Re: Noise Test Program
by on (#208174)
Yeah, your link sounds more au naturel. Thanks! Why would anyone EQ a song, especially by so much, before uploading? :cry:

Added this in an edit, but then you posted. Pasting the relevant piece here instead:

found a quote. "[...] if i typed in '42, 100', '42' would be the note and '100' would be the duration in cycles per second (in the uk, 25 would be one second). So I never knew what key or tempo I was writing in [...]". If it's about the same period, PAL seems to be the target platform, but tempo not an active decision.
Re: Noise Test Program
by on (#208177)
FrankenGraphics wrote:
Yeah, your link sounds more au naturel. Thanks! Why would anyone EQ a song, especially by so much, before uploading? :cry:

It's not really "EQed", I think that's just pretty typical results of using the RF modulator output, plus maybe degradation from being recorded to whatever intermediary forms before becoming a 240p-quality YouTube video.

As an aside, you can also see those 6-pixel wide diagonal stripes a lot (esp. title screen, pause map/menu) since they used checkerboard dithering extensively. (Also, several screens of the game have garbage in the top row of tiles, which is likely to be covered on NTSC but more often visible on PAL, AFAIK.)

I'm not sure whether it can be said to primarily target NTSC or PAL. It was developed in England, but released in North America many months before it was in Europe. I think they were pretty savvy about testing on both by that point. (Though on the issue of tempo, I think they just did a "don't care", and it's slower in the PAL version.)

There was also a short making-of promotional video made, where it looks/sounds like Tim's music demo is NTSC: https://www.youtube.com/watch?v=894_PNqBkx4