Vibrato on square without phase reset
Posted: Tue Mar 08, 2005 4:12 am
When the high 3 bits of the timer period of a square channel are changed by writing to $4003 or $4007, the waveform is restarted (phase is reset). This is fine if a new note is starting, but inconvenient if vibrato is being applied to one of the few notes which are near the timer periods of $100, $200, $300, $400, $500, $600, and $700.
After writing the recent sweep test ROMs, I was realized that the sweep could be used to set the high 3 bits of the timer period without restarting the wave. The basic idea is to use the sweep with shift = 7 to increment or decrement the high 3 bits, then clock the sweep immediately by writing to $4017. A shift of 7 results in an offset of of 1 to 15, greater for higher timer periods. If the low 8 bits are set to $ff when adding, $00 when subtracting, the offset will reliably increment or decrement the high 3 bits as desired. Once the high 3 bits have been changed with the sweep, the low 8 bits can be set directly.
I made a simple demo ROM that plays a tone that slow rises and falls, with slight vibrato. The phase never gets reset, so it always sounds clean. This technique might be useful for sound engines. The only issue is that the extra clocking of the sweep would rule out the use of the length counters, linear counter, volume envelopes, and normal sweeps, since the frame counter is used in a non-standard way. This wouldn't be a problem in a modern music engine that implements its own versions of these features in software to allow more flexibility and control.
After writing the recent sweep test ROMs, I was realized that the sweep could be used to set the high 3 bits of the timer period without restarting the wave. The basic idea is to use the sweep with shift = 7 to increment or decrement the high 3 bits, then clock the sweep immediately by writing to $4017. A shift of 7 results in an offset of of 1 to 15, greater for higher timer periods. If the low 8 bits are set to $ff when adding, $00 when subtracting, the offset will reliably increment or decrement the high 3 bits as desired. Once the high 3 bits have been changed with the sweep, the low 8 bits can be set directly.
I made a simple demo ROM that plays a tone that slow rises and falls, with slight vibrato. The phase never gets reset, so it always sounds clean. This technique might be useful for sound engines. The only issue is that the extra clocking of the sweep would rule out the use of the length counters, linear counter, volume envelopes, and normal sweeps, since the frame counter is used in a non-standard way. This wouldn't be a problem in a modern music engine that implements its own versions of these features in software to allow more flexibility and control.