|
BTW I don't get how you doubled the length of the saw wave in olddmcwaves.html. The $4011 volume control thing I get (although I don't know what values put here correspond to the different volumes), but how'd you get it to double in volume?
An 8-step stairstep sample of 1-byte length is played repeatedly. This decrements the DAC by 2 each step, for a total of 16 each sample. The IRQ routine triggers after each 8-step sample plays.
If the DAC is reset between each 8-step sample (every IRQ), this gives 17 possible volume levels from 0 through 16. For example, if the DAC is reset to 8 each IRQ (second figure), it will be decremented to 6, then 4, then 2, then 0, and stay at 0 for the remaining steps until the IRQ fires again. Any level above 16 will be (almost) equivalent to 16, since the DAC will only be decremented by 16 total. For example, if the DAC is reset to 30 each IRQ, it will only be decremented to 14 by the next IRQ, thus cover 16 levels as before, resulting in (almost) the same wave with a DC offset (due to the non-linearity of the DAC, it will be slightly quieter).
If the DAC is reset every n IRQs (fourth figure), then it will be decremented n*16 for each wave cycle (n 8-step samples each decrementing by 16). This allows the volume to vary from 0 to n*16. So if n is 2, the volume can be between 0 and 32, which is (about) twice as loud as possible when the DAC is reset every IRQ.
Note that the delay described in old_dmc_waves.html isn't possible, since I later found that the DMC sample unit runs continuously and can't be reset in the middle of a sample. I had to go the route hinted at there, of changing the DMC frequency after each 1-byte sample finished.
If you're supporting these waves in a new driver, be sure to support saw waves in addition to triangle waves.
|