square wave tremolo

Algorithm development and general DSP issues

Moderator: frank

Post Reply
theo
Posts: 3
Joined: Sun Jun 08, 2008 8:04 pm
Location: California

square wave tremolo

Post by theo »

hi, noob here. i'm trying to create a "square wave" panner/tremolo to alternate between the right and left channels. the rate would be controlled by one of the control pots.

however, i would like to create a 'trapezoidal' waveform to provide appox. 7ms crossfade times (about 230 sampes at 32768) to reduce the transients.

in the docs on the site i've seen the application of using two ramp LFO's offset by half their period to create a crossfade/interpolation shape that is exactly the geometry i am trying to achieve, but i'm struggling to translate this technique into a waveform (and its inverse) that i can use as an amplitude multiplier for the incoming adcl and adcr respectively.

forgive me if this is obvious and i'm overlooking it, any help appreciated! thanks in advance. -theo
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Hmmmm, good question. I'll need to think about it a bit. The hardware I designed to generate the waves doesn't directly map to instructions, it creates one ramp, derives the 2nd ramp, use them to create the waveform, etc.
Frank Thomson
Experimental Noize
theo
Posts: 3
Joined: Sun Jun 08, 2008 8:04 pm
Location: California

Post by theo »

thanks frank.

could one load a single ramp of appropriate length into a delay memory at start, then use zero crossings of one of the sine lfos (and a flip-flop counter) to trigger reading that out into register to multiply by the audio once per sine cycle (culminating the a steady-state coefficient until next sine zero-crossing)

just thinking out loud here. -t
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Ugly way to make a trapezoidal wave from a ramp by making it a triangle and taking advantage of the saturation limiting to clip the peaks (some one check me on this )

Code: Select all

skp	run, 	start
wldr	0, 32767,4096

start:
clr
cho	rdal,	RMP0	; read in the ramp, ranges 0 -> 0.5
sof	1,-0.25		; ramp now -0.25 -> 0.25
absa			; make it a triangle 0 -> 0.25
sof	-2.0,0.25	; change range to -0.25/0.25
sof	-2.0,0		; ranges -0.5/0.5
sof	-2.0,0		; ranges -1.0/1.0
sof	-2.0,0		; clip the peaks of the tri wave to make trapezoidal -1.0/1.0
sof	0.5,0.5		; scale to -0.5/0.5 and add 0.5 to make it 0/1.0
wrax	dacl,	1.0
To adjust the shape (faster slopes) add more "sof -2.0,0" commands
Frank Thomson
Experimental Noize
theo
Posts: 3
Joined: Sun Jun 08, 2008 8:04 pm
Location: California

Post by theo »

this turns out to work quite nicely frank, thank you! -t
Post Reply