very simple sine generator algorithm

Status
Not open for further replies.

MacroMachines

Well-known member
I've been working on a project using the teensy/audio and FV-1 effects chip, and in the process I am learning many efficient techniques to make assembler dsp code for the FV-1. I just found a sine/cosine oscillator technique that uses only a few multiply/accumulate and registers to create a sine/cosine oscillator. I wanted to post the PDF here in case anyone wanted to check them out and possibly implement them before I get to it.

http://www.claysturner.com/dsp/digital_resonators.pdf

I think its possible with these methods to make an extremely efficient group of library objects that could allow for loads of oscillators.


The Assembler code for the FV-1 implementation is :

Code:
equ	oscSin	reg0
equ	oscCos	reg1
equ	oscFreq	pot0 

;----------- load ---------------
SKP 	RUN ,	3            ; skips the next 3 instructions after the initial first run
WRAX 	oscSin,	0    ; writes to the register defined by equ oscSin above (reg0) 
                                      ;  and multiplies the accumulator by 0
SOF 	0,	-1                   ; scale and offset the accumulator, times 0 plus -1
WRAX 	oscCos,	0    ;  write to cosine register and clear accumulator

;___________________
;------ Oscillator--------------
RDAX 	oscSin,	0.6   ; read sine register multiplied by 0.6
MULX 	oscFreq             ; multiply by register defined by equ above (pot input 0)

RDAX 	oscCos,	1      ; add cosine register times 1
WRAX 	oscCos,	-0.6  ; write to cosine register and multiply accumulator by -0.6
MULX 	oscFreq             ; multiply by register currently defined as pot0

RDAX 	oscSin,	1      ; add sine register times 1
WRAX 	oscSin,	0      ; write to sine register and clear accumulator
 
Be careful if you run this loop for long durations -- because of roundoff error in the multiplication, the amplitude may not remain precisely constant. For some frequencies, it may grow to overflow or decay to zero eventually. Digital oscillators like this need an amplitude regulation loop to avoid this behaviour.
 
@Jp3141:
Very interesting, do you know of any resources I could read more about this issue or what I might google to find more? I haven't had any issues yet in my tests but most of them are using multiple oscillators for FM/amp/ring modulation.

Also wondering if you know if it is possible to inject signal or triggers into these as resonators and for them to decay (like a resonant bandpass filter). I am looking for the best way to implement a low resource sine resonator bank for physical modeling of harmonic/inharmonic modes.
 
Status
Not open for further replies.
Back
Top