Pulse channel glitch when changing frequency

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
Ben Boldt
Posts: 557
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Pulse channel glitch when changing frequency

Post by Ben Boldt » Mon May 11, 2020 9:31 pm

I am working on some music programming stuff and added a feature to my ROM tonight that lets me automate vibrato on pulse channels. I find that each time that I make slight adjustments to the frequency, I get nasty glitches that don't sound good:
nes_pulse_glitch.png
nes_pulse_glitch_2.png
nes_pulse_glitch_2.png (10.71 KiB) Viewed 1115 times
Is this unavoidable or have I screwed something up?
Attachments
test_rom.zip
(2.01 KiB) Downloaded 18 times

User avatar
Ben Boldt
Posts: 557
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Pulse channel glitch when changing frequency

Post by Ben Boldt » Mon May 11, 2020 10:34 pm

It seems that it works great if I avoid writing to the frequency high bits in register $4003/$4007. Updated ROM attached. Does anyone know of a workaround for this if I do need to update the high bits in some situation, or is that always going to be causing a glitch whenever it is written?
Attachments
test_rom2.zip
(2.01 KiB) Downloaded 19 times
Last edited by Ben Boldt on Mon May 11, 2020 10:34 pm, edited 1 time in total.

lidnariq
Posts: 9491
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Pulse channel glitch when changing frequency

Post by lidnariq » Mon May 11, 2020 10:36 pm

This behavior is mentioned here:
https://wiki.nesdev.com/w/index.php/APU_Pulse

The known workaround is to deliberately clock the sweep to indirectly change the upper byte, and then stop the sweep.

User avatar
Bregalad
Posts: 7889
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Pulse channel glitch when changing frequency

Post by Bregalad » Tue May 12, 2020 12:45 am

Relevant thread about the workaround Blargg found : http://forums.nesdev.com/viewtopic.php?f=2&t=231

Alternate workaround : Tune everything slightly up so that an A note with vibrato will barely stay in the range with the same $4003/$4007 value.

User avatar
Ben Boldt
Posts: 557
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Pulse channel glitch when changing frequency

Post by Ben Boldt » Tue May 12, 2020 8:15 am

Awesome, I am so glad you guys know a trick for this! :wink:

Post Reply