News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Silencing Pulse Channels (without using $4015)  (Read 2810 times)

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Silencing Pulse Channels (without using $4015)
« on: November 11, 2014, 12:28:17 pm »
I'm finalizing the Legend of Iowa soundtrack, and have come across an odd effect with respect to the Pulse-1 channel. The original game didn't have "hard" rests, merely the "soft" variety wherein a melodic channel was allowed to fade away into nothingness until a new frequency was issued. I recoded the rest-handler to differentiate between soft and hard, the latter getting a nice big #00 sent straight to $4000 / $4004 to silence the prior pitch.

However, I'm now getting these weird high-pitched clinking noises on Pulse-1 (haven't tested Pulse-2 yet) whenever a hard rest is encountered by the music engine. They're extremely brief, but distracting nonetheless. I've found that I can adjust the severity by altering the value that gets sent to $4001 upon hard-rest, but nothing seems to completely eliminate it.

Anyone know what value can be fed to $4001 (and $4005, for that matter) to instantly silence the Pulse Channel? [I don't want to play around with $4015, as that'd likely annoy the DPCM sampler.]

Bregalad

  • Hero Member
  • *****
  • Posts: 2751
    • View Profile
Re: Silencing Pulse Channels (without using $4015)
« Reply #1 on: November 11, 2014, 02:24:41 pm »
You should write $30, (or $70, $b0, $f0) to $4000/$4004 to silence a pulse channel.

Writing 0 to both frequency registers is also an option, as the sweep unit will automatically silent ultra-sounds.

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Silencing Pulse Channels (without using $4015)
« Reply #2 on: November 11, 2014, 05:52:44 pm »
Quote
Writing 0 to both frequency registers is also an option, as the sweep unit will automatically silent ultra-sounds.

From what I was able to gleam from NESDev, the Pulse-1's sweep register ($4001) handles its stuff differently from its Pulse-2 counterpart at $4005:

"For reasons unknown, pulse channel 1 hardwires its adder's carry input rather than using the state of the negate flag, resulting in the subtraction operation adding the one's complement instead of the expected two's complement (as pulse channel 2 does). As a result, a negative sweep on pulse channel 1 will subtract the shifted period value minus 1. "

Before, when I was writing #00 to both $4000 and $4001, hard rests would silence the P1 channel, but with a brief sweeping-click. Almost as if the channel was burning through its highest pitch-range before exiting Stage Up. Is it possible that $4001 requires a different "silence" byte than $4005?

I tried STA #1E $4015, STA #1F $4015. As I predicted earlier, it worked in cutting off the Pulse-1 channel, but triggered a reiteration of the last DPCM sample executed. (Those of you familar with the chorus of Paul Oakenfold's "Southern Sun", imagine Link's flying sword sound effect on every. single. beat.)  >:(


Addendum: Okay, apparently writing #00 to both $4000 and $4002 is the magic combination. [I decided to throw in an extra write to $4003 for good measure, just in case my results were due to the nature of the high-frequency notes currently in-play (and thus, the high-timer value at $4003 already being zeroed-out).]
« Last Edit: November 11, 2014, 06:41:47 pm by Dr. Floppy »

Bregalad

  • Hero Member
  • *****
  • Posts: 2751
    • View Profile
Re: Silencing Pulse Channels (without using $4015)
« Reply #3 on: November 12, 2014, 05:32:26 am »
Quote
Before, when I was writing #00 to both $4000 and $4001, hard rests would silence the P1 channel, but with a brief sweeping-click.
Sorry but this is impossible. Writing $00 to $4001 will disable the sweep unit entierely, like writing any other positive value.
As for writing $00 to $4000, it means decay at the fastest rate. As I said, write $30 for silence.

Quote
Addendum: Okay, apparently writing #00 to both $4000 and $4002 is the magic combination.
No it is not, if $4003 has a number greater than $00, this will still mean to play a audible tune with decay at the fastest rate. If you insist of refusing to listen to me and write $30 to $4000, then $00 to both $4002 and $4003 should work. But don't write $00 to $4000 please, this makes no sense at all.

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Silencing Pulse Channels (without using $4015)
« Reply #4 on: November 12, 2014, 08:43:55 am »
Quote
No it is not, if $4003 has a number greater than $00, this will still mean to play a audible tune with decay at the fastest rate.

Re-read the second half of my addendum.

Quote
If you insist of refusing to listen to me and write $30 to $4000, then $00 to both $4002 and $4003 should work. But don't write $00 to $4000 please, this makes no sense at all.

Why? All the high-nybble controls is duty cycle.

Bregalad

  • Hero Member
  • *****
  • Posts: 2751
    • View Profile
Re: Silencing Pulse Channels (without using $4015)
« Reply #5 on: November 12, 2014, 08:57:16 am »
Quote
Why? All the high-nybble controls is duty cycle.
No.

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Silencing Pulse Channels (without using $4015)
« Reply #6 on: November 12, 2014, 10:51:20 am »
Ack, my bad. I meant to say "timbre". Only d7-d6 control the duty cycle.

That corrected, I can't deny the results: Writing #00 to $4000 and $4001 yielded an audible clicking noise. Writing #00 to $4000, $4002 and $4003 yields immediate silence. I can send you a copy of the prior case if-

 :huh:

You sly dog! You almost tricked me into handing over an advance copy of The Legend of Iowa!

Almost.  ;)