bbbradsmith / nsfplay

Nintendo NES sound file NSF music player
https://bbbradsmith.github.io/nsfplay/
277 stars 42 forks source link

Unpleasure pop noise #42

Closed Yave-Yu closed 4 years ago

Yave-Yu commented 4 years ago

Any version: Pop noise will be produced when a triangle sound play over, such as intro triangle bong bong bong of Mega Man 4 Bright Man song. 2.5 beta version: Each time play an nsf, it usually pop 1 time at beginning.

bbbradsmith commented 4 years ago

So in bright man you have some falling triangle sounds at the start HHHH MMMM LL.L, you are referring to a popping noise on the L notes, right?

Comparing with hardware recording, there is a pop there sometimes, but often it is very quiet. NSFPlay gives a loud pronounced pop there every time.

This is an interesting example, I will have to investigate it more closely. Thank you.

bbbradsmith commented 4 years ago

I believe this is fixed with eeff32d10708da076064f1cf53666c8ec371591b but you need to use the "randomize triangle on startup" option in APU2. However, it will still make a pop sometimes in MM4 Bright Man, but only sometimes. I believe this closely matches how the original hardware behaves, which also pops some of the time.

What happens is it writes to $400A slightly before $400B, which because it's crossing from just below $100 to just above $100 as the pitch falls, you end up with a very short period of time (~60 cycles) where the period is set to something very low (still waiting on the high bit to be written to $400B), causing the triangle to advance very quickly for a short period of time.

The change I made makes the APU wait for the next step of the triangle before it is allowed to change pitch. This means that most of the time, $400A and $400B will not be written far enough apart for the pop to happen, but it still can happen some of the time (~25% of the time?).

bbbradsmith commented 4 years ago

Could you explain more about "Each time play an nsf, it usually pop 1 time at beginning." Is there a specific NSF/track that you can recommend to demonstrate this?

bbbradsmith commented 4 years ago

Aha! I think I found the problem. In 29eaf0cd4efebb6fe79755d3d6b72d1070114ba9 I inverted the starting position of the triangle, but I never balanced the output at the start, so I start with a jump up. I think this is the problem.

There was supposed to be a feature to automatically balance any starting level... but I thought I had already put it in. Turns out I hadn't. So I finished adding it with 14cb23159584427053a6e5456bb1f9ce8d0918d5 .

I hope both problems you brought up are now addressed? I think I have fixed both things now.

New build can be found here: https://ci.appveyor.com/project/bbbradsmith/nsfplay/branch/master/artifacts

Yave-Yu commented 4 years ago

Nice! It really fixed! Thank you!