1. This one is accurate sine production, not wavetable based?
2. Can someone remind where to put resync node?
3. Can this be optimized (via ASM code) without loosing freq/phase accuracy?
1) No - the sin1 funstion is the same 65536 entry lookup table.
The precision of the counter is what will determine the phase/frequency accuracy. This can be improved by using double precision numbers (e.g. look inside some of the sample player modules - you will find a "precise" counter in double maths).
But double precision is not available in code or assembly, and cannot work with mono4 data - so, in the interests of low CPU, I would imagine that the stock oscillators stick with single precision (though I don't know for sure).
This possibly explains the greater accuracy of CoolEdit - it may be using maths with greater precision for the counter (and possibly the sine function too).
In terms of the sine function itself - the only way to increase accuracy would be either a larger lookup table, or to use the super-precise fsincos opcode. As we saw earlier in the thread, using fsincos, while accurate, is extremely greedy for CPU - several orders of magnitude slower than a lookup table.
in fact, your code could well be less accurate than the stock osc', as it reads a only single lookup value directly without interpolation (i.e. there may be 'steps' in the waveform at low frequencies).
2) To resync, you just need to set the counter (a) back to zero, according to whatever rule you want for the re-sync input. The usual way it to look for rising edges (i.e. current sync input is greater than the previous one). Something like...
- Code: Select all
a = a & (Trigger <= OldTrigger);
OldTrigger = Trigger;
3) I have done an optimisation on the sin1 function in the past - I'll see if I can find it. However, the CPU savings were quite modest, and it is not possible to improve the accuracy/function of the sine function this way. Again, it is possible that the stock oscillator uses more efficient code already (the dev's possibly have access to a wider set of instruction than we can use in code/assembly).