Flanger

Algorithm development and general DSP issues

Moderator: frank

Post Reply
slacker
Posts: 116
Joined: Tue Feb 01, 2011 1:13 pm

Flanger

Post by slacker »

Thought I'd share this flanger I've been working on. Still needs some work, I'm not happy with the speed range of the LFO and the code needs tidying up a bit. Hopefully the comments explain what's going on. Big thanks to Frank and everyone else who worked on the knowledge base and anyone who's contributed to the forum, everything I've learned so far about the FV-1 is from this site.

Code: Select all

;Flanger
;Pot 0 - LFO speed/comb filter select, controls speed of the LFO. If it's set to zero then the LFO is disabled 
;Pot 1 - Range, controls the range of the LFO, if the LFO is disabled it sets the delay time making the effect into a comb filter
;Pot 2 - Feedback, zero in the centre, clockwise = positive feedback, anticlockwise = negative feedback

;Set up useful equates

equ long 500		;maximum delay time in samples ~15ms
equ short 5		;minimum delay time in samples ~0.15ms
equ maxfback 1.8		;set max feedback level, above 1.8 it will self oscillate in a nasty way 

;Set up register equates

equ feedback reg0
equ filter reg2
equ modpos reg3
equ flangeout reg4

;Set up delay memory, using values from above

mem flange long+short+1

;set up LFOs, only at start up
skp run, START
wldr rmp0,0,4096		;ramp0 used for chorus operations
wlds sin0,0,32767		;sin0 used for LFO

START:

;get LFO speed from POT0 or disable if zero

ldax pot0		          ;read pot0, if it's zero accumulator will be zero else it will be positive
skp zro, MANUAL		;if zero skip to MANUAL otherwise do LFO stuff

mulx pot0		;multiply it by its self a few time to get a nicer taper, needs work
mulx pot0
sof 175/511,0.2/511	;set minimum and maximum rates
wrax sin0_rate,1		;write to sin0 rate	
cho rdal,sin0		;get sin0 value 
absa 			;rectify to give a positive "hyper triangle"
mulx pot1 		;multiply by pot1 for variable range 
sof long/32767,short/32767 	;scale LFO output and shift so it sweeps between the short and long times
wrax modpos,0		;write to modulation register
skp gez,FLANGER		;accumulator will always be positive so skip to FLANGER

MANUAL:
sof 1,long/32767		;write long time
mulx pot1 		;multiple by pot1 for variable range 
sof 1,short/32767	 	;add short time so output is between the short and long times 
wrax modpos,0		;write to modulation register

FLANGER:
ldax pot2		;read pot2
sof 1,-0.5		;level shift so it's between -0.5 to 0.5 to get positive or negative feedback
sof maxfback,0		;scale to max feedback level
mulx feedback		;multiple by feedback register 
rdax adcl,1		;mix with input signal

wra flange,0		;write to head of delay

cho rdal,rmp0		;servo ramp0 to correct position using value in modpos
rdax modpos,-1		;copied from knowledge base
wrax rmp0_rate,0
cho rda,rmp0,reg|compc,flange	;read from delay
cho rda,rmp0,0,flange+1

wrax flangeout,1		;write to flangeout register

rdfx filter,1		;lowpass filter at ~5KHz
wrlx filter,-1
wrax feedback,0		;write feedback register

rdax flangeout,0.5		;read flangeout register
rdax adcl,0.5		;mix with input signal
wrax dacl,1		;write to DACL
wrax dacr,0		;write to DACR
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

I like reading other peoples code, to see how they attack the problem. I always learn something from them. Please post updates as you make changes, like to watch the evolution of code.
Frank Thomson
Experimental Noize
Post Reply