Vibrato

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Vibrato
by on (#41149)
How do most games go about getting vibrato on the square wave channels? Is it alternating up/down sweeps? Originally I was just planning to modulate the pitch manually, but the sound engine has that nasty retrigger any time the upper 4 frequency bits update.

I was thinking careful programming of the sweep units would get a decent vibrato, but that seems a little intensive for a simple effect. How did games handle it back in the day?

by on (#41151)
I can't imagine trying to do it by using the sweep registers. Maybe some games do it, but that just sounds like a headache.

I do it manually, like you were also suggesting. The trick is to only update the MSB of the pitch when it changes. However there are some problems that arise when doing vibrato. A pitch might bend so that the highest pitch in the vibrato has different MSB than the lowest one. This makes a garbly sound. Though I believe Blargg figured out a way to get around this by manipulating the sweep registers or something like that. I'll go see if I can find it.

Honestly though, manually is the way to go. You have much more control over it that way.

EDIT:

http://nesdev.com/bbs/viewtopic.php?t=231

I think that's the one I was thinking of.
Re: Vibrato
by on (#41154)
skrasms wrote:
but the sound engine has that nasty retrigger any time the upper 4 frequency bits update.


I'm not familiar with this side effect( not vibrato, I know what that is). You get some sort of unwanted sound artifact when updating the period system at a higher rate or something?
Re: Vibrato
by on (#41155)
tomaitheous wrote:
skrasms wrote:
but the sound engine has that nasty retrigger any time the upper 4 frequency bits update.


I'm not familiar with this side effect( not vibrato, I know what that is). You get some sort of unwanted sound artifact when updating the period system at a higher rate or something?


Oops, I meant upper 3 frequency bits. The upper 0.75 nibbles of frequency data :wink:

Anytime registers $4007 or $4003 are written it resets other aspects of the sound. The envelopes restart, for example. To do vibrato by direct pitch data changes it's fine starting on a pitch that isn't near an MSB change. In that case it's safe just writing $4002 and $4006. It's those crosses into MSB territory that cause issues.

by on (#41156)
Oh, that's not too bad. Hardware volume envelope isn't that much anyway. I'd just used fixed volume and handle the envelope in software. Lot of systems use(d) 60hz tick envelopes.

I take it that it resets the phase of the duty cycle too? If so, and with the use of an external timer/irq, you could do some nice sync+(fast)volume slides to create interesting instrument effects - like a waning frequency cut filter type effect

by on (#41160)
tomaitheous wrote:
I take it that it resets the phase of the duty cycle too? If so, and with the use of an external timer/irq, you could do some nice sync+(fast)volume slides to create interesting instrument effects - like a waning frequency cut filter type effect


It does, and that's a good idea too. Demon Sword is the only game I can think of that used that feature to it's advantage in a couple songs (title screen and boss fight, I think).

When I had a timer IRQ to play with, I mostly messed around with $4011 (the DAC).

by on (#41195)
Memblers wrote:
Demon Sword is the only game I can think of that used that feature to it's advantage in a couple songs (title screen and boss fight, I think).


Oh cool. I love finding out stuff like that :D How some games used methods and exploits like that to create new <sounds/graphics> that you normally don't see.

Not trying to hi-jack this thread (sorry), but does the (manual) volume change take place on the next the phase of the duty cycle or immediately on the current phase? I would assume it would be on the next phase, i.e. the duty cycle phase and the volume value are multiplexed and feed to the DAC but on the next phase/clock( 1/8 ) or is it re-multiplexed and sent to the DAC immediately?

by on (#41205)
Almost everything takes an immediate effect, since it uses less hardware. About the only delayed things are those that affect the periods of timers, since it takes less hardware to reload the count on zero rather than compare the count with the period to see if it's equal or greater (as some other sound chips do, like the YM-2149 and AY-8910).