by carbon14 » Fri Aug 27, 2010 9:36 am
Most of the waveforms break down into variations on the basic 256 entry lookup table, so it made sense to me to combine the wave select, and the two msb of the counter to form a lookup (implemented as a switch) into those variant algorithms. This is probably efficient, and I hope that each individual variation is efficient in itself.
If you want, you can trade memory for cpu cycles and generate a full set of 8, 1024 entry lookups for these waveforms. 16K bytes is quite a chunk of memory, but can save a significant number of cpu operations per lookup, and you need to make 1 lookup per operator, per sample. You can then dispense with the original 256 entry logsin table completely, because it is incorporated in the first 256 entries of the waveform 1 table.
It seems likely that the ymf262 uses 1s complement internally for it's arithmetic, and it may well also use a floating point representation internally. Since it shouldn't have to do anything more arduous that addition and subtraction, this could be very efficient. I have chosen not to attempt that in my algorithms because generally microprocessors are better at 2s complement arithmetic and lack the end-around-carry operations that aid 1s complement. As I have noted elsewhere, the 1s complement output from the ymf262 is actually not quite in step with the expectations of the YAC512 DAC, but the operational difference is minimal. The sign-bit approach that I have taken will allow me to do the exponential lookups independantly of the sign, and then quicly convert the data to 2s complement before accumulation. The final output of my code is likely to be an offset 2s complement result which will differ from that produced by the ymf262, but which should produce the expected result when used directly in wav or aiff form.