Chorus code

Algorithm development and general DSP issues

Moderator: frank

Post Reply
ice-nine
Posts: 192
Joined: Thu May 24, 2012 9:03 am

Chorus code

Post by ice-nine »

I just thought I would post this little chorus I have been playing around with today. It had Rate and Depth controls and sounds just like a normal chorus but adds in the 2nd rate control to spook things up a bit. It's a very simple program and just 35 lines of code.
Hope its of use.

I might drop the second rate control and replace it with a tone control on the chorus but that's for tomorrow.

Code: Select all

;Chorus 

;Pot0=Chorus Level
;Pot1=Chorus Rate Special
;Pot2=Chorus Rate

;memory declarations

mem 	chodel 	4096

;register equates

equ	mono	reg0
equ	chorout	reg1

skp 	run,	START
wlds 	SIN0,	0,800	;alter the 800 and 1200 valuea to adjust the amount of
wlds	SIN1,	0,1200	;pitch bend lower number = shorter freq span.

START:

;sum inputs to mono

rdax 	adcl,0.5		;read left input /2
rdax	adcr,0.5		;read right input /2
wra	chodel,1		;write to head of chorus delay line
wrax	mono,0.5	;write to mono register /2

;prepare pot2 for chorus rate sin0 rate
 
rdax 	pot2,1
mulx 	pot2
sof	0.02,0.01	;apprx 1Hz to 3Hz
wrax	sin0_rate,0	;load sin0 rate register 

;prepare pot1 for chorus rate sin0 rate
 
rdax 	pot1,1
mulx 	pot1
sof	0.04,0.01	
wrax	sin1_rate,0	;load sin1 rate register 

;Do chorus lines

cho 	rda, SIN0,SIN|REG|COMPC,chodel+1400
cho 	rda, SIN0,SIN,chodel+1401

cho 	rda, SIN0,COS|REG|COMPC,chodel+1200
cho 	rda, SIN0,COS,chodel+1201

cho 	rda, SIN0,SIN|REG|COMPA,chodel+1600
cho 	rda, SIN0,SIN|COMPC|COMPA,chodel+1601

cho 	rda, SIN0,COS|REG|COMPA,chodel+1200
cho 	rda, SIN0,COS|COMPC|COMPA,chodel+1201


cho 	rda, SIN1,SIN|REG|COMPC,chodel+900
cho 	rda, SIN1,SIN,chodel+901

cho 	rda, SIN1,COS|REG|COMPC,chodel+1100
cho 	rda, SIN1,COS,chodel+1101

cho 	rda, SIN1,SIN|REG|COMPA,chodel+700
cho 	rda, SIN1,SIN|COMPC|COMPA,chodel+701

cho 	rda, SIN1,COS|REG|COMPA,chodel+1600
cho 	rda, SIN1,COS|COMPC|COMPA,chodel+1601

mulx 	pot0
wrax	chorout,0	;write chorus result to chotusout

;mix dry and chorus signals together and send to left output

rdax	mono,1		;read mono dry signal into acc and keep
rdax	chorout,0.5	;add chorus signal /2 into acc
wrax 	dacl,0		;write result to left output
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

That's fairly interesting.

Normally I see algorithms with just one "REG" per program, the idea being that you fix the LFO value once and then do all your offset and interpolations from that one point. So if you "REG" for each pair of CHO RDA's which are offset from each other by 1, does this mean that the LFO keeps moving in between those pairs?

Also I see you are using the "COMPA" which I haven't yet figured out. The Assembler manual says that this "Complements the address offset" and further "USED with  'CHO' instruction: 1's comp address offset 
(Generate SIN or COS)".

I haven't tracked down any other explicit uses of "COMPA". What good does it do to "complement the address offset"?

Edit:
OK Sorry, I just found: http://www.spinsemi.com/knowledge_base/ ... tml#Chorus

Apparently "COMPA" makes the modulation waveform go the other direction through the buffer?

OK a couple other questions then...

1) Does "COMPA" have any significance when using the RAMP LFOs?

2) Seems like you could easily get that "through-zero" flanger by using a couple of pairs of CHO RDA instructions with the same offset(s), but one pair using COMPA. True?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Using COMPA to comp the address offset basically inverts the waveform so between SIN, COS and the comp of each you can create 4 waves offset by 90 degrees from each other in a single LFO.
Frank Thomson
Experimental Noize
ice-nine
Posts: 192
Joined: Thu May 24, 2012 9:03 am

Post by ice-nine »

I basically just read through the AN0001 notes on the basics of the LFO and used the examples to make up a chorus. I set up two LFO's to operate independently on different sets of chorus.

I am thinking of changing the second LFO to to modulate the first LFO, are there any notes on doing this that I can read up on ?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

No notes on doing that but basically use a CHO RDAL to read the controlling LFO, adjust the value to be in the desired range and write it to the chorusing LFO. Set the amp coefficient of the controlling LFO to max as that also effects the value read by a CHO RDAL.
Frank Thomson
Experimental Noize
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

So back to one of my questions, is there any advantage or difference to using multiple "REG" flags, or is it sufficient to simply do this with the first CHO x instruction per LFO per program?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Best practice is to REG an LFO only once, since they are updated in the background it could be possible to get a slightly different value if you REG it a second time.
Frank Thomson
Experimental Noize
Post Reply