New Phaser code

Algorithm development and general DSP issues

Moderator: frank

Post Reply
dslocum
Posts: 13
Joined: Mon May 21, 2012 9:34 am
Contact:

New Phaser code

Post by dslocum »

Hey guys,

I've been working on an enhanced version of the GT_DEMO Phaser code.

I really don't know DSP and this is the first program I've done for the FV-1. I just beat / hacked it into submission, not really knowing what I was doing.

I’ve now got a great sounding phaser with LFO, Depth / Manual, and # of stages (4,6,8,10). I’ve decided to give back to the Spin community and post the finished code (copy attached).

BTW – it took every last bloody program line!!!!

Enjoy

Doug

Code: Select all

;Slocum Phase shifter  (From GA_DEMO - mods by Doug Slocum 10/20/2017)
; Uses every last bloody program line!

;Pot0 = Phase rate (manual if fully CCW)
;Pot1 = Sweep width (or manual)
;Pot2 = Num of Stages (4,6,8,10)


;register equates:

equ	mono	reg0
equ	lp1	reg1
equ	lp2	reg2
equ	phase	reg3
equ	p1	reg4
equ	p2	reg5
equ	p3	reg6
equ	p4	reg7
equ	p5	reg8
equ	p6	reg9
equ	p7	reg10
equ	p8	reg11
equ	p9	reg12
equ	p10	reg13
equ	temp	reg14
equ	temp1	reg15


;clear registers and initialize LFOs:

skp	run,endclr 

wrax	lp1,0
wrax	lp2,0
wlds	sin0,12,100     ;sin0 used for phaser operations 
wlds	sin1,0,32767    ;sin1 used for LFO

endclr:

;sum inputs to mono:
rdax	adcl, 0.5
rdax	adcr, 0.5
wrax	mono, 0

;Do phase shifter from sin1
; Manual or LFO mode test
ldax 	pot0           ;read pot0, if it's zero then accumulator will be zero, else it will be positive 
skp 	zro, MANUAL   	;if zero, then skip to MANUAL otherwise do LFO stuff 

;LFO stuff
rdax	pot0, 1
mulx	pot0
sof	0.12, 0.003
wrax	sin1_rate, 0
cho	rdal, sin1		;read sin1 as +/-1
sof	0.5,0.5		;make positive only sin ranges 0 to 1
log	0.5,0
exp	1,0		;square root function
sof	1,-0.5		;make +/-0.5
sof	1.999,0		;make +/-1 again
mulx	pot1		;pot1 controls phaser depth
sof	0.26,0.72

skp 	gez, PHASER	;accumulator will always be positive so skip to PHASER:


MANUAL: 
rdax	pot1, 1
mulx 	pot1	;multiply by pot1 for variable range 
sof	-.999,.999
log	0.9, 0
exp	1,0 


PHASER:
wrax 	phase,0	;write to modulation register 

rdax	mono, 1/64	;input to phase shift network
wrax	temp1, 0	; save it away

; pot ship routines for selecting number of stages
rdax	pot2, 1
and	%01100000_00000000_00000000  	;mask off only 2 bits, leaving only 4 possibilities
skp	zro,STAGES4	;if zero, the skip over other code to reverb1
sof	1,-0.25	;subtract 1/4
skp	zro,STAGES6	;if zero, skip over other code to reverb2
sof	1,-0.25	;subtract 1/4
skp	zro,STAGES8	;if zero, skip over other code to reverb3
clr	 	;clear the accumulator, there's 1/4 left in it!


STAGES10:
rdax	p1,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p1,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p2,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p2,-1
mulx	phase
rdax	temp,1
wrax	temp1,0


STAGES8:
rdax	p3,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p3,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p4,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p4,-1
mulx	phase
rdax	temp,1
wrax	temp1,0


STAGES6:
rdax	p5,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p5,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p6,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p6,-1
mulx	phase
rdax	temp,1
wrax	temp1,0


STAGES4:
rdax	p7,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p7,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p8,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p8,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p9,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p9,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p10,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p10,-1
mulx	phase
rdax	temp,1


sof	-2,0
sof	-2,0
sof	-2,0
sof	-2,0
sof	-2,0
sof	-2,0	;output of phase shifter in acc

rdax	mono,1
wrax	dacl,1
sof	1,-0.04
wrax	dacr,0

donstavely
Posts: 53
Joined: Thu Jan 07, 2010 2:29 pm
Location: Windsor, Colorado

Post by donstavely »

Good stuff, Doug. I also find that I fight for every instruction.

A couple of things that might save a few lines: The final "sof 1, -0.04" I believe was only necessary to avoid a glitch around zero in the D/A converter on an early rev of the FV-1. Note that there was a "sof 1, 0.02" on the other channel in the original GA code. Maybe Frank can clarify.

Also, there is the 64X attenuation before the phaser code, and then six "sof -2, 0" lines to gain it back up again. This seems like overkill for avoiding clipping in the math. Maybe 4X would be more reasonable. Again, it would be good for Frank to weigh in.
Don Stavely
dslocum
Posts: 13
Joined: Mon May 21, 2012 9:34 am
Contact:

Post by dslocum »

I actually have very little idea what you are referring to, as I really don't have the Spin chops yet, and may never.. But I'm happy to have the "experts" chime in and help me learn. And if it helps someone else, that's good too.!!!
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

You can delete these references as well:

equ lp1 reg1
equ lp2 reg2

wrax lp1,0
wrax lp2,0

lp1 and lp2 are never used beyond being cleared to zero at init time.

Call me crazy but I generally skip clearing my filter registers at init time. I suppose it might cause a pop under some circumstances but I don't recall it ever being an issue. YMMV of course.
donstavely
Posts: 53
Joined: Thu Jan 07, 2010 2:29 pm
Location: Windsor, Colorado

Post by donstavely »

Not crazy.

No need to clear registers at run time.
Don Stavely
ice-nine
Posts: 192
Joined: Thu May 24, 2012 9:03 am

Post by ice-nine »

Digital Larry wrote:You can delete these references as well:

equ lp1 reg1
equ lp2 reg2

wrax lp1,0
wrax lp2,0

lp1 and lp2 are never used beyond being cleared to zero at init time.

Call me crazy but I generally skip clearing my filter registers at init time. I suppose it might cause a pop under some circumstances but I don't recall it ever being an issue. YMMV of course.
Yeah remove those lines, they were used for LPF in the reverb code which has been totally removed anyway.
www.stanleyfx.co.uk
"It's fairly straight forward, if you want to start it press start, you can work out the rest of the controls yourself."
leetut
Posts: 20
Joined: Sat Oct 27, 2018 2:33 pm

Re: New Phaser code

Post by leetut »

<0000>[ Pass 1] [ 1015] Line: 192 "sof -2,0 " - ERROR:Program Length Exceeds Limit -
<0001>[ Pass 1] [ 1031] Line: 192 "sof -2,0 " - ERROR:FAILED On Pass - ONE


2 Log Messages
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: New Phaser code

Post by frank »

Try this one, there seems to be some issues with some of the code after the forum update

Code: Select all

;Slocum Phase shifter  (From GA_DEMO - mods by Doug Slocum 10/20/2017)
; Uses every last bloody program line!

;Pot0 = Phase rate (manual if fully CCW)
;Pot1 = Sweep width (or manual)
;Pot2 = Num of Stages (4,6,8,10)


;register equates:

equ	mono	reg0
equ	lp1	reg1
equ	lp2	reg2
equ	phase	reg3
equ	p1	reg4
equ	p2	reg5
equ	p3	reg6
equ	p4	reg7
equ	p5	reg8
equ	p6	reg9
equ	p7	reg10
equ	p8	reg11
equ	p9	reg12
equ	p10	reg13
equ	temp	reg14
equ	temp1	reg15


;clear registers and initialize LFOs:

skp	run,endclr 

wrax	lp1,0
wrax	lp2,0
wlds	sin0,12,100     ;sin0 used for phaser operations 
wlds	sin1,0,32767    ;sin1 used for LFO

endclr:

;sum inputs to mono:
rdax	adcl, 0.5
rdax	adcr, 0.5
wrax	mono, 0

;Do phase shifter from sin1
; Manual or LFO mode test
ldax 	pot0           ;read pot0, if it's zero then accumulator will be zero, else it will be positive 
skp 	zro, MANUAL   	;if zero, then skip to MANUAL otherwise do LFO stuff 

;LFO stuff
rdax	pot0, 1
mulx	pot0
sof	0.12, 0.003
wrax	sin1_rate, 0
cho	rdal, sin1		;read sin1 as +/-1
sof	0.5,0.5		;make positive only sin ranges 0 to 1
log	0.5,0
exp	1,0		;square root function
sof	1,-0.5		;make +/-0.5
sof	1.999,0		;make +/-1 again
mulx	pot1		;pot1 controls phaser depth
sof	0.26,0.72

skp 	gez, PHASER	;accumulator will always be positive so skip to PHASER:


MANUAL: 
rdax	pot1, 1
mulx 	pot1	;multiply by pot1 for variable range 
sof	-.999,.999
log	0.9, 0
exp	1,0 


PHASER:
wrax 	phase,0	;write to modulation register 

rdax	mono, 1/64	;input to phase shift network
wrax	temp1, 0	; save it away

; pot ship routines for selecting number of stages
rdax	pot2, 1
and	%01100000_00000000_00000000  	;mask off only 2 bits, leaving only 4 possibilities
skp	zro,STAGES4	;if zero, the skip over other code to reverb1
sof	1,-0.25	;subtract 1/4
skp	zro,STAGES6	;if zero, skip over other code to reverb2
sof	1,-0.25	;subtract 1/4
skp	zro,STAGES8	;if zero, skip over other code to reverb3
clr	 	;clear the accumulator, there's 1/4 left in it!


STAGES10:
rdax	p1,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p1,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p2,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p2,-1
mulx	phase
rdax	temp,1
wrax	temp1,0


STAGES8:
rdax	p3,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p3,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p4,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p4,-1
mulx	phase
rdax	temp,1
wrax	temp1,0


STAGES6:
rdax	p5,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p5,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p6,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p6,-1
mulx	phase
rdax	temp,1
wrax	temp1,0


STAGES4:
rdax	p7,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p7,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p8,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p8,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p9,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p9,-1
mulx	phase
rdax	temp,1
wrax	temp1,0

rdax	p10,1
wrax	temp,1
mulx	phase
rdax	temp1,1
wrax	p10,-1
mulx	phase
rdax	temp,1


sof	-2,0
sof	-2,0
sof	-2,0
sof	-2,0
sof	-2,0
sof	-2,0	;output of phase shifter in acc

rdax	mono,1
wrax	dacl,1
sof	1,-0.04
wrax	dacr,0
Frank Thomson
Experimental Noize
Post Reply