by opl3 » Thu May 24, 2012 6:33 am
I use a similar table, but with a different negative amplitude. Usually I just compare captured values to values generated by software.
A sine wave and other applicable waveforms can have both positive and negative sign, even if the attenuation is so high that the output value is 0. In OPL, the positive zero is 0, and the negative zero is -1, because it is done as ones complement.
Thus, for example a square wave is either +4084 or -4085, in offset binary 36852 (0x8FF4) or 28683 (0x700B).
This is why sometimes some calculations seem wrong, if the assumption is that an operator always outputs 0 when it has high attennuation. But if the phase generator is running (phase increment is larger than 0), and the waveform has a negative part, then it will alternate between 0 and -1 accordingly. I solve that by selecting a waveform that only has positive sign. Attack speed of 0 will also keep that max attenuation so output keeps at 0.
That is also the noise that can be seen output from the chip when all notes are just turned off and set to high attenuation. There might be any number of channels having phase generators running and outputing 0 or -1. So to reset a chip into silent mode, every channel needs a note on-note off sequence which starts a zero frequency note with waveform that only has positive part and also the attack speed of 0 so the envelope will stay at max attenuation.