Tremolo filter

Algorithm development and general DSP issues

Moderator: frank

Post Reply
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Tremolo filter

Post by Digital Larry »

This one's a little odd.

Two pole state variable filter, highpass and lowpass outputs go to either input of a crossfade. Crossfade mix position is controlled by an LFO. Kind of sounds like the filter center frequency is moving, but it's not!

The sound is a bit thin when the width is all the way down. I may add code to mix more of the dry or bandpass signal back into the output as the width goes down.

I might also add a control to move the filter's center frequency around a bit for different tones. As this algorithm doesn't take a ton of instructions, it might be cool to double it, send one filter to the left, one to the right, and add some envelope control to the LFO speed for pseudo-Leslie type sounds.

Pot 1 = speed
Pot 2 = depth


Code: Select all

;  Program: Render Block exported from SpinCAD Designer
;------ Input
;------ SVF 2P
SOF 0.0000000000,0.0000000000
RDAX 20,1.0000000000
RDAX 34,-1.0000000000
RDAX 33,-1.0000000000
WRAX 32,0.1351716281
RDAX 33,1.0000000000
WRAX 33,0.1351716281
RDAX 34,1.0000000000
WRAX 34,0.1351716281
;------ Pot 0
;------ Pot 1
;------ LFO 0
SKP RUN ,1
WLDS 0,143,32767
RDAX 16,0.2798434442
WRAX 0,0.0000000000
RDAX 17,1.0000000000
WRAX 1,0.0000000000
CHO RDAL,0
WRAX 35,1.0000000000
;------ Scale/Offset
SOF 0.5000000000,0.5000000000
WRAX 37,0.0000000000
;------ Crossfade
RDAX 32,1.0000000000
RDAX 34,-1.0000000000
MULX 37
RDAX 34,1.0000000000
WRAX 39,1.0000000000
;------ Output
RDAX 39,1.0000000000
WRAX 22,0.0000000000
RDAX 39,1.0000000000
WRAX 23,0.0000000000
Here's a hand-optimized version with register names used to make it easier to understand.

Code: Select all

;------ SVF 2P 
SOF 0.0,0.0 
RDAX ADCL,1.0 
RDAX REG2,-1.0 
RDAX REG1,-1.0 
WRAX REG0,0.1351716281 
RDAX REG1,1.0 
WRAX REG1,0.1351716281 
RDAX REG2,1.0 
WRAX REG2,0.1351716281 
;------ LFO 0 
SKP RUN ,1
WLDS SIN0_RATE,143,32767 
RDAX POT0, 0.2798434442 
WRAX SIN0_RATE,0.0 
RDAX POT1,1.0 
WRAX SIN0_RANGE,0.0 
CHO RDAL,0 
;------ Scale/Offset 
SOF 0.5,0.5 
WRAX REG4,0.0 
;------ Crossfade 
RDAX REG0,1.0 
RDAX REG2,-1.0 
MULX REG4
RDAX REG2,1.0 
;------ Output 
WRAX DACL, 1.0
WRAX DACR, 0.0
Aaron
Posts: 54
Joined: Wed Mar 04, 2015 8:10 pm
Location: Oklahoma

Post by Aaron »

Hey Larry, I have been in the process of developing a very similar type of tremolo based on the early brown face fenders. I have been trying to accomplish this by splitting the input and sending them through a single LPF and HPF and crossfading them with the sin LFO. It kind of works but it definitely does not get that phasing type of sound that yours is getting.

I would like to implement the same type of two pole filter that you have worked up but I would like to understand it a bit more. Could you point me to some documentation that may help me to grasp how you found the coefficients?

Code: Select all

skp run, START		;skip instruction after initalizing, go to START
wlds SIN0,0,16384	;load SIN0 LFO and set freq and amp parameters for Tremolo

START:
clr			;clear ACC

;set up pot0 as RATE
ldax pot0		;load pot0 into ACC
sof 0.5667,0.0235	;scale it for .5Hz to 12Hz
wrax SIN0_RATE,0		;save value to SIN0_RATE, clear ACC
rdax pot1,1		;read pot1 value into ACC
wrax SIN0_RANGE,0	;set pot1 value as Depth

;setup high pass and low pass filters
rdax adcl,.5		;read left*.5 into ACC
rdax adcr,.5		;read right*.5 into ACC
wrax mono,1		;set mono input, keep in ACC
rdfx inlp,0.01371		;LPfilter ~ 72Hz
wrlx inlp,-1		;set LP shelf to infinite
wrax inlp,0		;write inlp, clear ACC
rdax mono,1		;read mono into ACC
rdfx inhp,0.11548		;HPfilter ~ 640Hz
wrhx inhp,-,1		;set HP shelf to infinite
wrax inhp,0		;write inhp, clear ACC

;load LFO 
cho rdal,SIN0		;read SIN0 LFO into the accumulator
sof 0.5,0.5		;set LFO 0 to 1
wrax lfol,0		;write value to lfol, clear ACC

rdax inlp,1			        ;inlp in ACC
rdax inhp,-1			;subtract inhp
mulx lfol				;use lfol to crossfade between the two
rdax inhp,1			;add inhp
wrax tremout,0			;write to tremout, clear ACC

Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

Hi Aaron,

I built this patch up using SpinCAD Designer. See:

http://holycityaudio.com/spincad-designer-2/

Here is the Java code that creates the 2 pole SVF block in question. Look for the function setCoefficients() towards the bottom. Then see how the lines in the function generateCode() use the values for q1 and fZ.

https://github.com/HolyCityAudio/SpinCA ... Block.java

Let me know if you need more info.
Aaron
Posts: 54
Joined: Wed Mar 04, 2015 8:10 pm
Location: Oklahoma

Post by Aaron »

Thank you for the code, Larry.

Just to make sure I'm understanding fully, the coeff for fZ that you are using in your posted code then would be centered around 707Hz?

sin(2*PI*fZ/Fs)

sin(2*PI*707/32768) = .13515
Aaron
Posts: 54
Joined: Wed Mar 04, 2015 8:10 pm
Location: Oklahoma

Post by Aaron »

And to take this further, if using the equations found here for state variable filter:

Code: Select all

rdax adcl,.5		        ;read left*.5 into ACC
rdax adcr,.5		        ;read right*.5 into ACC
wrax mono,1		        ;set mono input, keep in ACC
rdax lowpass,-1		        ;q * input - LPF 
rdax bndpass,-1		        ;q * input - LPF + (-q * BPF) =
wrax hipass,0.12241	        ;HPF * Fc
rdax bndpass,1		        ;HPF * Fc + BPF =
wrax bndpass,0.12241	;BPF * Fc
rdax lowpass,1		        ;BPF * Fc + LPF =
wrax lowpass,0.12241   	;LPF * Fc
Fc = Cutoff frequency coeff
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

Hi Aaron,

Yes I think that is correct. Note that many digital filter designs are based on analog filter designs, transformed into the digital domain through some mathematical process. Some of these transformations work better than others and all of them work best at frequencies below 1/4 of the sampling frequency.

So is the filter really centered at exactly 707 Hz? Well... maybe. It's probably very close. Following on with the general philosophy offered by Keith Barr, these numbers are just guidelines and the final decision should be made with your ears.

Cheers,

DL
Aaron
Posts: 54
Joined: Wed Mar 04, 2015 8:10 pm
Location: Oklahoma

Post by Aaron »

I will definitely keep that in mind. Thank you for all of your help!
Post Reply