Hi, I am having a little bit of difficulty understanding intuitively how the noise channel should work. I would appreciate it if anyone could help me understand it better, from an emulation standpoint.
I'll describe how I think it works, ignoring the envelope decay clocking since it secondary to the essence of the channel. So, here is how I understand the channel to work:
1) First, a wavelength value is (indirectly) specified via $400E. For this example, suppose the lower 4 bits of data written were $07, setting the wavelength value to $050, or 80.
2) Next, the length counter is enabled (via $400C) and initialized to a value $400F. Now, the noise channel will start producing audible output until the length counter clocks down to zero. I think this is ok so far. Here is where I become confused.
3) While the length counter is nonzero, the noise channel will count down "wavelength" number of cycles. In this case, 80. When the wavelength counter (which is clocked at the CPU speed) reaches 0, the output level of the noise channel will be set to either 1 or 0, which is dictated by the random number generator. (I will also ignore the functionality of the random number generator, for now) The wavelength counter will then be reset to it's original value (80) and repeat until the length counter reaches zero.
4) If the output level is a "1", the current volume level is the sent from the noise level to some sort of mixer/DAC
So, for this example, suppose I am sampling the noise channel at 96000 samples per second. This equates to 400 samples per 240th of a second (quarter frame). Since the wavelength is set to 80, I will need to generate a new random number (1790000/80+1) times per second, which is roughly 92 times per quarter frame. However, the shift frequency of the random number genrator is clocked at half the speed of the frequency, so the random number generator will generate a random 1 or 0 92/2 = 46 times per quarter frame. so, each value from the random number generator will be written 400/46 = ~9 times, and after every 9th output sample I will call my random number generator to fetch a 1 or 0.
(The random number type/length (93 or 32k bit) will make the audible frequency slightly higher (93 bit) or lower (32k bit), based on the probability of repeating a bit pattern, but I'm not worrying about that just yet.)
Does this example make sense? I guess my main question is how exactly does the wavelength factor in to the noise channel. I'd appreciate any comments, and thanks to all who make this forum such an informative place.