NSF player "cheats"?

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

Moderator: Moderators

Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

NSF player "cheats"?

Post by Rahsennor »

I'm quite happy with the accuracy of my NSF player by now, so I've started looking for ways to (optionally) fudge things to improve sound quality beyond actual hardware. So far I've tried four different hacks, with varying degrees of success:

N163 overclocking
The obvious brute-force solution to the ringing and aliasing this chip produces. Examples: any N163 game. Downsides: none.

Halt APU triangle on periods 0 and 1
Gets rid of the popping sound when the triangle is "muted" by setting it to an ultrasonic frequency. Examples: Mega Man 2. Downsides: none.

APU pulse DC removal
Reduces the crackle that occurs whenever a pulse channel's level changes. Examples: Kid Icarus, The Legend of Zelda, Dr. Mario.
Downsides: causes a low-frequency buzz on some tunes (Mega Man 2 NSF track 13, Dr. Mario NSF track 12). Probably a bug in my implementation, though I can't seem to figure out where.

APU pulse linear mixing
Fixes the crossmodulation artifacts on some games - mostly FDS titles, for some reason. Examples: Kid Icarus, Doki Doki Panic.
Downsides: alters balance slightly, and some games seem to do it on purpose, like the metallic pings in Solstice.

Does anyone have anything else to add to the list?
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NSF player "cheats"?

Post by tepples »

Rahsennor wrote:APU pulse DC removal
Reduces the crackle that occurs whenever a pulse channel's level changes. Examples: Kid Icarus, The Legend of Zelda, Dr. Mario.
Downsides: causes a low-frequency buzz on some tunes (Mega Man 2 NSF track 13, Dr. Mario NSF track 12). Probably a bug in my implementation, though I can't seem to figure out where.
That'll cause my early "Hello" demo to fail to produce any audio. It writes to the volume register as if it were a primitive form of $4011.
User avatar
Dwedit
Posts: 4921
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: NSF player "cheats"?

Post by Dwedit »

Can't you constantly reset the phase to make the raw square waves sound better?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: NSF player "cheats"?

Post by Rahsennor »

tepples wrote:That'll cause my early "Hello" demo to fail to produce any audio. It writes to the volume register as if it were a primitive form of $4011.
I just tested it, and it still works. The third amplitude modulation sample sounds rather thin though.

I suppose that just proves my implementation is indeed buggy and explains that suspicously 60hz-sounding buzz on some tracks. It does reduce the crackle, though, so it's not a total failure.
User avatar
za909
Posts: 248
Joined: Fri Jan 24, 2014 9:05 am
Location: Mijn hart woont al in Nederland

Re: NSF player "cheats"?

Post by za909 »

My suggestion would be an option to also silence the triangle at period $7FF because the sound engine used in games like Recca, Kickmaster, and Zombie Nation "silences" the triangle by writing $7FF to the period, which produces a noticable sustained "breathing" sound from the quantization steps of the wave. I don't know how common it is to silence the triangle with period $000 (the Follin engine does it as well, not only the first two Mega Man games), but $7FF is definitely less common.
User avatar
B00daW
Posts: 586
Joined: Thu Jan 03, 2008 1:48 pm

Re: NSF player "cheats"?

Post by B00daW »

NSF2 format support.

2a0x audio TEST register support.

Jaleco ADPCM expansion audio support.

Bandai Mitsubishi LPC decoder expansion audio support.

Arcade Dual-2a0x support (Donkey Kong 3).

DAC out mode of PPU signals for PPU generated audio.

Not really "cheats" but those are currently not supported...

Cheats:

User allocation of expansion audio channels to stereo mixer.

5B dynamic over/underclocking for envelope generator to simulate AY/YM.

VRC6 sawtooth waveform flip limiter glitch fix.

DMC memory wraparound glitch fix.
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: NSF player "cheats"?

Post by Rahsennor »

B00daW wrote:NSF2 format support.
I thought that wasn't finished yet?
B00daW wrote:Jaleco ADPCM expansion audio support.

Bandai Mitsubishi LPC decoder expansion audio support.
Not available in the NSF format, and I can't implement what I can't test anyway.
B00daW wrote:2a0x audio TEST register support.

Arcade Dual-2a0x support (Donkey Kong 3).

DAC out mode of PPU signals for PPU generated audio.
Sorry, but I don't even know what you're talking about.
B00daW wrote:User allocation of expansion audio channels to stereo mixer.
My player is monophonic, just like the hardware. It's on the to-do list, but I really don't feel like rewriting all my DSP just to add stereo output right now.
B00daW wrote:5B dynamic over/underclocking for envelope generator to simulate AY/YM.
...how is that useful? A 5B is a 5B, and should do what a 5B does. Unless there's something that requires this behaviour?

(Besides, I haven't even implemented the envelope generator yet. :oops: Can't find test files.)
B00daW wrote:VRC6 sawtooth waveform flip limiter glitch fix.

DMC memory wraparound glitch fix.
These sound like the sort of thing I had in mind, but I've never heard of them before. What exactly are they? Where can I find more info?
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NSF player "cheats"?

Post by rainwarrior »

Rahsennor wrote:
B00daW wrote:VRC6 sawtooth waveform flip limiter glitch fix.
DMC memory wraparound glitch fix.
These sound like the sort of thing I had in mind, but I've never heard of them before. What exactly are they? Where can I find more info?
1. The VRC6's sawtooth accumulator wraps around if you set the volume too loud.
2. A DPCM sample length that goes past $FFFF wraps back around to $8000. ( edit: Sorry, slip of the memory. Corrected by TheFox below. )

I'm not sure what value there is in "cheating" these.

What exactly would a cheating DPCM address to? There's nowhere for the address to go past the end of memory, so I don't see any reason to do anything but the wrapping that the hardware actually does.

Similarly, all you'd get from "fixing" the VRC6 sawtooth is the ability to make it extra loud. (Extremely overpowered, really.) It would also break anything that relies on the wrap to produce different waveform timbres (Konami games don't do this, but modern NSFs might). I don't think anyone's out there saying the VRC6 sawtooth isn't loud enough?
Last edited by rainwarrior on Sat Jan 30, 2016 11:06 pm, edited 1 time in total.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: NSF player "cheats"?

Post by thefox »

rainwarrior wrote:2. A DPCM sample length that goes past $FFFF wraps back around to $C000.
Hardware wraps to $8000.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: NSF player "cheats"?

Post by lidnariq »

Rahsennor wrote:Sorry, but I don't even know what you're talking about.
Explaining:
B00daW wrote:2a0x audio TEST register support.
When we decap'ed the 2A03G, we discovered pulling pin 30 high made four new registers appear:
Reads from $4018: Return current value of APU pulse channel DACs
Reads from $4019: Return current value of APU triangle and noise channel DACs
Reads from $401A: Return contents of DMC DAC
Writes to $401A: Set triangle phase and "lock channel outputs", whatever that means.
See Quietust's comments: http://wiki.nesdev.com/w/index.php/File:Apu_address.jpg
B00daW wrote:Arcade Dual-2a0x support (Donkey Kong 3).
Same as dual SID or dual AY, just two 2A03s. Does require two separate emulated CPUs.

The arcade DK3 was made before they figured out that DPCM DMA causes glitches when reading from the controller ports, so they did the "normal arcade thing" and added an extra CPU instead.

I can't (yet) tell you how the two CPUs communicate, but you can see if you can figure out mame's source more easily than I: src/mame/drivers/dkong.cpp


Similarly, adding support for dual-2A03 via the Vs. System communications methods might be interesting.
B00daW wrote:DAC out mode of PPU signals for PPU generated audio.
I don't see how this is interesting? It's going to have an overwhelming loud 50/60Hz buzz on top of whatever intended signal is generated.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NSF player "cheats"?

Post by tepples »

lidnariq wrote:
B00daW wrote:DAC out mode of PPU signals for PPU generated audio.
I don't see how this is interesting? It's going to have an overwhelming loud 50/60Hz buzz on top of whatever intended signal is generated.
mouser theme via PPU
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: NSF player "cheats"?

Post by lidnariq »

lidnariq wrote:I can't (yet) tell you how the two CPUs communicate, but you can see if you can figure out mame's source more easily than I: src/mame/drivers/dkong.cpp
There's a Z80 host with four write-only ports at 0x7C00-0x7DFF:
* Z80 port at 0x7C00-0x7C7F is read by 2A03 coprocessor 1 via reads from $4016
* Z80 port at 0x7C80-0x7CFF is read by 2A03 coprocessor 1 via reads from $4017
* Z80 port at 0x7D00-0x7D7F is read by 2A03 coprocessor 2 via reads from $4016
* Z80 port at 0x7D80-0x7DFF ones bit drives both coprocessors' /RESET inputs

Both coprocessors have their own 512 byte RAM and 8 KiB ROM. Z80 Host has 32 KiB of ROM, 4 KiB of RAM, and 2 KiB of video RAM. I see no way for the coprocessors to tell the host anything.
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: NSF player "cheats"?

Post by Rahsennor »

rainwarrior wrote:1. The VRC6's sawtooth accumulator wraps around if you set the volume too loud.
2. A DPCM sample length that goes past $FFFF wraps back around to $C000.
Those was the first things that came to mind, but I didn't see the point in 'fixing' them if that were the case.

I still don't, to be honest; the VRC6 saw is loud enough as it is and running the DMC over the interrupt vectors makes no sense in the first place.
lidnariq wrote:When we decap'ed the 2A03G, we discovered pulling pin 30 high made four new registers appear:
Reads from $4018: Return current value of APU pulse channel DACs
Reads from $4019: Return current value of APU triangle and noise channel DACs
Reads from $401A: Return contents of DMC DAC
Writes to $401A: Set triangle phase and "lock channel outputs", whatever that means.
Interesting. I could add these registers to my emulator easily enough, but I'm not sure it would help anyone. I doubt many other emulators support them and it wouldn't even work on hardware without modifications. What use would it be? :?
za909 wrote:My suggestion would be an option to also silence the triangle at period $7FF because the sound engine used in games like Recca, Kickmaster, and Zombie Nation "silences" the triangle by writing $7FF to the period, which produces a noticable sustained "breathing" sound from the quantization steps of the wave. I don't know how common it is to silence the triangle with period $000 (the Follin engine does it as well, not only the first two Mega Man games), but $7FF is definitely less common.
I didn't reply earlier, but thanks for this, it's just the sort of thing I was looking for.

Just to try and get the thread back on topic, what heuristics are people using to remove DMC clicks? What games are particularly notable for causing them?
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NSF player "cheats"?

Post by rainwarrior »

Rahsennor wrote:Just to try and get the thread back on topic, what heuristics are people using to remove DMC clicks? What games are particularly notable for causing them?
Many soundtracks by Konami tend to set the DMC counter at the start of every sample. Castlevania III, for example.

My click removal is to detect if $4011 is ever written; if so, I maintain an inverse signal that is mixed on top to cancel it out (i.e. the result of the $4011 write steps up the waveform +35, then my "inverse" jumps down -35). Over time I allow the inverted signal to slowly and noiselessly drain out back to 0 (which is important because clicks are often in 1 direction only, and could eventually cause integer overflow).
User avatar
B00daW
Posts: 586
Joined: Thu Jan 03, 2008 1:48 pm

Re: NSF player "cheats"?

Post by B00daW »

I didn't say the fixes were spectacular but may aid to some minor annoyances.

Every suggestion I said was for art. Regarding those glitches possibly to be fixed I've used them to create forms of art already.

All other suggestions are also purely art related. :) If you don't see a point, you may just not share a similar perspective. It seems that your perspective is to get cleaner sounds out of commercial music and games. Myself and many other people use older hardware and consoles to create art for expression.

http://average.truechiptilldeath.com/ne ... poc-02.nsf

Here is an example of using the triangle channel for FM and the DMC channel for AM that I made as a PoC.
Post Reply