Discovered a new trick while working on Houstontracker. Consider the usual pulse interleaving with variable duty cycle:

```
add hl,de
ld a,b ;b = duty
cp h
sbc a,a
out (#fe),a
;blabla same for 2nd channel
```

Now, as you know, we can add a "SID-style" duty cycle sweep by incrementing the duty when the add counter (HL) overflows.

```
add hl,de
ld a,b ;b = duty
adc a,0
ld b,a
cp h
sbc a,a
out (#fe),a
```

So far, so good. Now for the new stuff, we'll add an extra parameter that will be XORed against the duty setting on every sound loop iteration.

```
add hl,de
ld a,b ;b = duty
adc a,0
xor c ;c = additional XOR parameter
ld b,a
cp h
sbc a,a
out (#fe),a
```

This will produce some very interesting timbres! A primitive form of square wave FM, if you will. The result tends to have some aliasing noise (because the harmonics will cross the Nyquist limit if I understood this correctly), but I suppose it could be filtered out with the low-pass filter algorithm I was talking about earlier.

Now I actually went another step beyond this. Since I'm using a split timer update as usual, I have time to add an offset to the XOR paramter (C) every 256 sound loop iterations. Now this is a double sided sword - it will act nicely as a third FM OP, but only if the value is 1/256th of the base frequency used. When it is not, then the results will vary from "interesting" to "ouch my ears".

The attached .tap demonstrates both techniques. The first pattern starts with a simple duty cycle sweep and the additional XORing disabled, followed by XOR parameters of 8, $10, $20, $40, and $80. The second pattern starts again with regular duty cycle sweep and XOR 0. Following this, the XOR parameter is raised by 1/256th of the base frequncy once per 256 sound loop iterations, and following this the XOR parameter is raised by a fixed value (8 in this case) every 256th iteration. This is then repeated but with the initial XOR set to $80.

Don't ponder too much about the code in the .tap, there is some additional leftover stuff from an earlier experiment.

Anyway, I'm busy with HT at the moment, so if someone wants to pick up this trick in the meantime, be my guest

EDIT: Realized I posted this in the wrong thread, moved for clarity.

**Post's attachments****test.tap** 971 b, 6 downloads since 2016-04-30

You don't have the permssions to download the attachments of this post.