Triangle wave from sin LFO

Algorithm development and general DSP issues

Moderator: frank

Post Reply
DrAlx
Posts: 25
Joined: Wed Feb 20, 2019 11:01 am
Location: Surrey, UK

Triangle wave from sin LFO

Post by DrAlx »

Here's something I came up with which might be useful if the ramp LFOs are being used for something else.
You can get a good approximation to a triangle wave using this formula

( 1 - abs(sin(t)) ) ^ 0.564476

The power is chosen to give best linearity based on the value at the halfway point.
Due to the limited floating point ranges on the FV-1, I had to slightly tweak the numbers.
Here's the code

Code: Select all

CHO RDAL,SIN0		; Read sin0 LFO value (-1 to +1)
ABSA			; Take absolute value
SOF -0.999,0.999	; ACC = 0.999( 1 - abs(sin(t)) )
LOG 0.564831,0
EXP 1,0			; ACC contains triangle wave (0 to 1)
Last edited by DrAlx on Sun Apr 07, 2019 6:53 am, edited 1 time in total.
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Re: Triangle wave from sin LFO

Post by igorp »

Nice snippet thank you!
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Re: Triangle wave from sin LFO

Post by igorp »

and this is my typical triangle LFO snippet. 6 lines, but you can use them as much LFOs as you need and use sine LFO for tail smearing
and tempo may be from 1/32Hz to 16kHz

Code: Select all

	ldax rate		; 0x100, for example
	rdax	RRR3 , 1	; drrr3+ rrr3 - counter
	and 	0x3fFFff	; 0 .. 0.5
	wrax RRR3 , 1	; Sawtooth 0..0.5

	sof 	1 , -0.25	; sawtooth -0.25..0.25
	absa			; triangle LFO, double speed 0 .. 0.25
DrAlx
Posts: 25
Joined: Wed Feb 20, 2019 11:01 am
Location: Surrey, UK

Re: Triangle wave from sin LFO

Post by DrAlx »

Thanks for the code snippet.
gkaiomenos
Posts: 19
Joined: Thu Oct 16, 2014 11:59 am

Re: Triangle wave from sin LFO

Post by gkaiomenos »

Hello

Is it possible to incorporate any of these snippets in a simple chorus algorithm like the one below from SpinCAD Designer which has sine LFO??

SKP RUN ,1
WLDS 0,50,64
RDAX POT1,0.0068613000
WRAX SIN0_RANGE,0.0000000000
RDAX POT0,0.1379256360
WRAX SIN0_RATE,0.0000000000
LDAX ADCL
WRA 0,0.0
CHO RDA,0,REG | COMPC,257
CHO RDA,0,0,258
WRAX REG0,0.0000000000
;------ Output
RDAX REG0,1.0000000000
WRAX DACL,0.0000000000
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Re: Triangle wave from sin LFO

Post by Digital Larry »

To use arbitrary waveforms in pursuit of "chorusey" type things in SpinCAD Designer, use the "Servo Flanger" block. The Chorus blocks use the chorus specific instructions (can't remember them any more... CHO RDA or something) which are hardwired to use one of the SIN/COS LFOs.
gkaiomenos
Posts: 19
Joined: Thu Oct 16, 2014 11:59 am

Re: Triangle wave from sin LFO

Post by gkaiomenos »

Digital Larry wrote: Sat Dec 21, 2019 8:31 am To use arbitrary waveforms in pursuit of "chorusey" type things in SpinCAD Designer, use the "Servo Flanger" block. The Chorus blocks use the chorus specific instructions (can't remember them any more... CHO RDA or something) which are hardwired to use one of the SIN/COS LFOs.
Thank you Larry!

I'm not quite sure how to use the servo flanger block to produce these tones. I tried to connect the Ramp LFO's block triangle output to the delay time control port of the servo flanger block

Is this the correct way to do this?
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Re: Triangle wave from sin LFO

Post by Digital Larry »

You'll need to mix the servo delay output with the dry signal to get flanging. You might want to try a phase inversion also.

If you're having trouble hearing anything, turn everything up - delay time, servo gain, LFO width and frequency. You should now be on a merry go round ride from heck. Now turn things down until they sound better.
gkaiomenos
Posts: 19
Joined: Thu Oct 16, 2014 11:59 am

Re: Triangle wave from sin LFO

Post by gkaiomenos »

Thanks again for your help Larry!

Cheers
Digital Larry wrote: Sun Jan 05, 2020 9:28 pm You'll need to mix the servo delay output with the dry signal to get flanging. You might want to try a phase inversion also.

If you're having trouble hearing anything, turn everything up - delay time, servo gain, LFO width and frequency. You should now be on a merry go round ride from heck. Now turn things down until they sound better.
Post Reply