Decay question?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Decay question?
by on (#24229)
So here's a question: I'm throwing together a playroutine, and I want to be able to have decaying instruments that start at less than full volume. Is it possible to do this without resorting to emulating the decay by manually changing the volume?

by on (#24234)
Can't do it, the decay has to start from full volume. The volume bits change the decay rate. Writing to $4003/$4007 triggers it.

by on (#24237)
That's what I figured. Manual envelope emulation it is, then.

by on (#24240)
Bummer.

by on (#24244)
However, an interesting fact is that the hardware decay allow you to change the decay rate on the fly (without reseting the volume to maximum).
It does in no way beats software decay, because that way you can at any volume level, stop decaying at any volume leve, and you're not forced to decay lineary.

by on (#24252)
Most commercial NES games use software-defined volume envelopes most of the time, right?

by on (#24254)
Pretty much every single developper used their own unique methods, so you cannot conclude general rules like that. That's what makes the NES sound hardware so interesting actually. You can listen a whole new soundtrack, and only by hearing how it "sounds" chances are that you can say wich company developped the game (at least the sound).
Tracks by Rare, Konami, Capcom and Squaresoft are unique and mostly reconizable jus by "how they sound".

by on (#24279)
Yeah, not much after 1985 used the decay hardware. I'm kinda hard-pressed to name a decent soundtrack that relies on it.. the first Dragon Warrior comes to mind. Mostly was stuff like Duck Hunt and Donkey Kong, which didn't have much music anyways,

And really, almost all games beyond the first-generation ones controlled everything manually. About the only exceptions are Rare using the length counter for the pulse and noise channels, and Konami always using the linear counter for the triangle channel (those blips in the Rush 'n Attack intro were always kinda interesting, what are they, 1/240th of a second long? heh).

by on (#24284)
Quote:
the first Dragon Warrior comes to mind

Agreed, and the first Wizards and Warriors too.
I think Battletoads kind of use Decay in the song that is not used in the game, just for one single frame at the begining of a note.

by on (#24285)
Bregalad wrote:
However, an interesting fact is that the hardware decay allow you to change the decay rate on the fly (without reseting the volume to maximum).
It does in no way beats software decay, because that way you can at any volume level, stop decaying at any volume leve, and you're not forced to decay lineary.

Hmm. So you can change the decay rate without resetting the volume, but you can't switch it from sustain to decay mode without resetting the volume?

by on (#24292)
Quote:
So you can change the decay rate without resetting the volume, but you can't switch it from sustain to decay mode without resetting the volume?

Reading my doc, it seems you can switch modes, but not get a useful effect, since the envelope's internal volume counter is always being updated, even when you have selected constant volume mode. So when you start a note (write to fourth channel register), the envelope resets and then is decrementing. If you switch to envelope mode after that, you get whatever volume it had, not the previous constant volume you were using.

In my opinion the APU shouldn't have any LFO units except those that significantly reduce CPU load. Changing the volume every 1/60 second isn't something you need hardware support for.

by on (#24293)
What I basically understand is that there is always an internal volume, that decays at the rate specified by the low 4 bits of any channel's first register, and that is reseted to $f when the channel's fourth register is written to. This internal volume either staty at zero or wrap arround to $f in function of a bit written in the first register. Then, another bit in the first register selects if the actual volume is from this internal volume, or if the low 4 bits of the first register are directly used, bypassing the internal decaying volume.

I'd agree that most hardware LFOs on the NES are plain useless, they can allow some simplification in very simple sound players, tough. The only real usefull feature is the sweep, because it allows sweeping to be clocked 4 or 5 times faster than what it would if you'd just change the frequency manually. Also, sweeping can tend to be a bit annoying to do and space confusing for simple music replayers, so they definitely want to use hardware sweep well calibrated to suit the needs instead of using software frequency changing.

by on (#24298)
Yeah, I'm definitely sticking with the hardware sweep for this version, as it's specifically designed for a set of songs I've written, which don't do complex pitch bends; the only reason I need to do manual envelope control is to achieve decaying notes that don't start at full volume.