Is $4011's default value $00 at start up?

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Is $4011's default value $00 at start up?

Post by frantik » Tue Oct 06, 2020 6:51 pm

I'm working on some code which streams PCM audio to 4011.. with 7 bit pcm data, the value of $40 represents the middle of the waveform and is "silence".. but I notice in emulators that I'm getting a "pop" in my initialization code when I set 4011 to $40 before I play the samples. I'm not sure if this is poor emulation or if that's how the nes would react too.

Is this how the hardware acts too? And to remove the pops, should I ramp up from $00 to $40 and then ramp back down to $00 at the end?

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

Re: Is $4011's default value $00 at start up?

Post by lidnariq » Tue Oct 06, 2020 8:02 pm

The upper 6 bits are explicitly set to 0 during reset (visual2a03 transistors t13729, t13590, t13426, t13263, t13119, t13027). However, the least significant bit is left unchanged.

As far as advice goes, I don't think it's really worth worrying about. Working from a 0-as-default will add distortion to the beginning and end of your samples. If that pop really bothers you, either slowly ramp up the DC bias over the first second with writes to $4011, or have a short sample prepared that will move from $00 to $40. (Note that either way this will be audible as brief tonal hum)

User avatar
rainwarrior
Posts: 8000
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Is $4011's default value $00 at start up?

Post by rainwarrior » Tue Oct 06, 2020 8:39 pm

It's pretty normal to hear a pop when you hit reset on a console, I don't think it's really a problem to just set it to $40 at reset? Kinda fits with all the other garbage you see for an instant.

However, maybe worth noting that the noise and triangle get slightly quieter the higher the DMC output is set due to their shared non-linear DAC. That's not necessarily a problem, you can just compose the music etc. with the adjusted levels in mind. (You can use Z40 in Famitracker to do this, and the effect will be fairly accurate.)

frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Re: Is $4011's default value $00 at start up?

Post by frantik » Tue Oct 06, 2020 10:54 pm

I can live with the pop at start up but the code I'm adding these samples later sets 4011 back to 00 to use the volume control that you mentioned. I never heard it pop at start up until I added my code. I think I might try out the ramping in and out thing, I don't think it should be audible if it's slow enough

User avatar
Memblers
Site Admin
Posts: 3898
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Is $4011's default value $00 at start up?

Post by Memblers » Wed Oct 07, 2020 12:06 am

Oddly, SMB does something like that, too. It ramps it up to $30 when you're playing, then ramps it down to $00 when you die. But why, it's a mystery.

frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Re: Is $4011's default value $00 at start up?

Post by frantik » Wed Oct 07, 2020 1:24 am

Memblers wrote:
Wed Oct 07, 2020 12:06 am
Oddly, SMB does something like that, too. It ramps it up to $30 when you're playing, then ramps it down to $00 when you die. But why, it's a mystery.
yeah, that's the game I'm adding the sounds too :D (turn on audio).. that's an old version with the pops I was mentioning. SMB only ramps up while main theme is playing, presumably to get the mix right I guess? it will ramp down if you go into a room with other music, or if you die like you mentioned. And it probably ramps to avoid the pop


After some experimenting, both Mesen and Fceux will not pop if you initialize $4011 with #$00 and start/end the samples with a ramp from #$00 to #$40 that is ~.015 seconds long (actually, half that also works.. possibly shorter).
Untitled-1.png
Untitled-1.png (11.09 KiB) Viewed 2446 times
Last edited by frantik on Wed Oct 07, 2020 1:42 am, edited 1 time in total.

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

Re: Is $4011's default value $00 at start up?

Post by Bregalad » Wed Oct 07, 2020 1:40 am

Memblers wrote:
Wed Oct 07, 2020 12:06 am
Oddly, SMB does something like that, too. It ramps it up to $30 when you're playing, then ramps it down to $00 when you die. But why, it's a mystery.
Wow I'm surprised such a trick was used in such an early game ! So far I only knew about Life Force doing this when the music fades out.
Last edited by Bregalad on Wed Oct 07, 2020 3:08 am, edited 1 time in total.
Useless, lumbering half-wits don't scare us.

User avatar
rainwarrior
Posts: 8000
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Is $4011's default value $00 at start up?

Post by rainwarrior » Wed Oct 07, 2020 2:38 am

Memblers wrote:
Wed Oct 07, 2020 12:06 am
Oddly, SMB does something like that, too. It ramps it up to $30 when you're playing, then ramps it down to $00 when you die. But why, it's a mystery.
I think it's a per-track setting, where some tracks want it at $30 and some want it at $00, so when a new track starts it slowly moves to the other position. (E.g. the underground music wants it at 0, regular level music at $30). I presume it's being used as a volume control for the triangle.
Bregalad wrote:
Wed Oct 07, 2020 1:40 am
So far I only know about Life Force doing this when the music fades out.
Startropics also uses it when fading out music.

Post Reply