N163 trick ~ Odd out of bounds tone behavior

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

Moderator: Moderators

Post Reply
ionustron
Posts: 34
Joined: Wed Apr 14, 2010 12:25 pm

N163 trick ~ Odd out of bounds tone behavior

Post by ionustron »

I was mentioning this round compo time, and forgot to get back to it...

There's a curious trick you can do with the N163 to get it to produce tones much higher than intended with MML. The effect seems to be very aliased or gets screwy with the filtering and makes for vastly different results across emulators. I'm not certain it hardware supports it either.

It's the simplest thing really, I'm sure someone has to have figured it out as well. Since the SA command was added, we have much more control over tuning and sweeps on the channels. Make it go as high as it'll go and it'll eventually settle on an odd tone before cycling back to the lowest hz it can output. Even with note envelopes, it still cycles through the tones. However, something very curious happens when we apply a pitch envelope with a decreasing value. Once it hits the lowest level, it cycles back to an extremely shrill range with harmonics bouncing all over it sometimes. Sometimes it goes silent.

When I messed around with it further, I noticed on a waveform of many buffers, it would remove all but the first buffer when cycling back through the tones. If you let it continue sweeping to the bottom and cycling back to the top again, it would add the next buffer samples back into the waveform, adding another buffer every full sweep until the entire waveform is back and then cutting back to only one buffer upon the next cycle through the tones.. This is why it would go silent sometimes, when the first buffer(s) were just flat waveforms with no difference. It would stay silent until the sweep reached a buffer that had different samples, and the shrill would kick right back in.

The thought was then to make an envelope to hit a sweet spot in the tone and then bounce it between a couple spots, add some volume and noise channel flourish and voila! A tambourine or sleigh bell effect. This was used roughly halfway into the Shining Force II cover that was entered in the compo. Course it sounds like crap in the flash player, and it's all over the place everywhere else...

Digging through a testing mml, here's another fun testing example to compile;

Code: Select all

//////////////////////////////////////////////////////////////

#EX-NAMCO106 8
#PITCH-CORRECTION

PQRSTUVW @t20,20

@EP1 = {|-10}

@N10 = {3 10 10 10 0 10 10 10 0 0 0 10 10 15 15 10 10 0 0 10 10 0 0 0 10 10 0 0 10 10 0 0 0}
/(the buffers past the first 4 samples shouldn't matter on this waveform. It was just from an early test.)

@v1 = {1 1 1 2 2 2 3 3 3 4 4 4 5}
@v2 = {5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0}

PQRSTU o1 EP1 SA1 @@10 l16
Q K1
R K2
S K3
T K4
U K5

PQRSTU v0 c8. @v1 EP0 w1^1^1^2 EPOF w1^1
P @v2w1
Q ^@v2w1
R ^8@v2w1
S ^8^@v2w1
T ^4@v2w1
U ^4@v2w1

//////////////////////////////////////////////////////////////
In the example, a brief time is spent silent because the volume is at zero while it's descending but before the sweep. Setting this to octave 0 will start it much sooner if not instantly.

I'm sorry as always that I probably don't have the right sound terminology, I just wished to share an interesting trick that I'm not sure is legitimately useful or not given what I've learned about having many sound channels active since the compo. Any explanation would be very helpful and interesting.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

I think this is just a bug in ppMCK.

The frequency is controlled by 18 bits in registers $78, $7A, $7C, but only two bits of $7C are used for frequency. The rest are used to control the length of your waveform.

So, when it gets to the bottom, it wraps, and I guess ppMCK is trying to make a frequency number with more than 18 bits in it and they bleed over into the waveform length bits.
ionustron
Posts: 34
Joined: Wed Apr 14, 2010 12:25 pm

Post by ionustron »

aha!

So then I wonder if you could just define a single buffer waveform and access those frequencies normally. My thought is that this could be used on a more common carefully made waveform working on a channel and then wrapping to the 1st buffer occasionally, sharing on some percussion or effect sound duty and saving a little bit of data used for an extra definition.

But do you think this is a safe bug to abuse?
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

Sure, I think it's probably "safe" to abuse... I mean, an NSF player should be able to do it fine, I guess, but there is probably a better way to do it (the ppMCK bug might have other side effects). Are you allowed to write the frequency registers yourself? (I don't know ppMCK very well.)
ionustron
Posts: 34
Joined: Wed Apr 14, 2010 12:25 pm

Post by ionustron »

You might with the y command, but otherwise I think most of the direct frequency write commands are disabled on the N163 channels in PPmck for some silly reason and bring up the engrish error "Unuse command on this track."
jrlepage
Posts: 24
Joined: Wed Apr 04, 2012 2:15 am

Post by jrlepage »

I do apologise for the massive bump, but I tried playing your Famicompo entry (in which you used this exploit) on hardware, and I can confirm this doesn't work on a real N163. :)

Here's the recording (FLAC, 5.73 MB). Skip to 0m37s so hear the part where the exploit happens.
ionustron
Posts: 34
Joined: Wed Apr 14, 2010 12:25 pm

Post by ionustron »

hahah, interesting! It sounds like it's using the whole waveform, making a tire screech. That's hilarious.
Post Reply