The noise channel is silent any time the envelope decay bit (i.e. bit 4 of $400C) is set to 0.
When bit 4 is 0, the envelope decay is disabled, so `is_manually_controlled` is set to false, and thus the volume of the noise channel gets set to `self.generated_volume` in VolumeGenerator's `volume()` function.
The problem is, `self.generated_volume` is never updated, and so it stays at the default volume of 0, silencing the channel.
As far as I can tell, the noise channel is supposed to work exactly the same as the square channels when it comes to the volume register, so my proposed fix is to duplicate the function used to update the square channels' volume generator, and update the noise channel along with the squares in `clock_sequencer()`.
When the sweep is disabled, but the negate flag is set (%00001000 written to $4001), the `frequency_generator_output()` function shouldn't be called. In fact, because the last 3 bits are set to 0, the `adjust_period_based_on_frequency_generator()` function doesn't end up calling it.
But, it's being called to check if channel should be silenced:
`!self.enabled || self.period < 8 || self.length_counter == 0 || self.frequency_generator_output() >= 0x7FF`
When `frequency_generator_output()` is called here (with the sweep disabled), self.period is shifted by 0 bits, so period_delta = self.period.
Thus `self.period.wrapping_sub( period_delta ).wrapping_sub( 1 )` = (0-1), underflowing to 0xFFFF which is indeed greater than 0x7FF. So the channel is silenced.
Added an additional check to see if the sweep is enabled before checking its state.
This addresses cases where WebGL is either broken or disabled. The
error message on Chrome was a Cannot read property 'create'Shader' of
null TypeError, however, the cause of this error was the variable `gl`
being null after attempting to retrieve all valid WebGL rendering contexts.