So, for the past week or so I've been revisiting the idea -- this time implementing the audio side of things as an NSF player, so that the game could be played stand-alone, without having to have another computer/player "driving" the emulator.
Now...
I've got myself to roughly the same point I was before -- namely, the code checks for writes to 4003/4007. This seems to work fine for some games, but on others I'm noticing some notes aren't showing up. Some examples I can think of off the top of my head -- the first track to "Metal Gear", the first stage music for "Castlevania 1", first stage music for "Yo Noid!"
Having only a cursory knowledge of how the NES works, and going purely off of what I've read in the nesdev wiki about the APU, my two guesses would be that there's something going on with looped envelopes, or that there's some writing to 4002/4006 (which I'm not really doing anything with at the moment). Or maybe there's some huge chunk of the puzzle I'm missing?
Another weird quirk I've noticed happens in the "Bionic Commando" area 1 music -- there's a few sustained notes that constantly write to 4003/4007. At first I thought this was an error on my part, but listening to the individual channels isolated, I can audibly hear some clicking, which makes me think it's just how the music's written?
Any information on this, or any insight into how I could better detect the start of a note would be much appreciated -- again, I've got a very superficial knowledge of how the NES works, so any and all information, no matter how obvious it is will be useful for me.