Before I delve into the coding examples and instructions again I was wondering if anyone knows if it possible to use a pot skp to manipulate a LFO so that it can be altered from say, Sine,triangle and square waves. This would be a very useful block of code if it can be done.
I was just looking for a yes or no before researching through the manuals to save a bit of time if it is a no.
LFO and pot skip routine
Moderator: frank
-
- Posts: 338
- Joined: Mon Nov 12, 2012 1:12 pm
- Contact:
From what I've seen, triangle is most easily generated from Ramp LFO. 4096 width ramp = 0 to 0.5. Subtract 0.25 and now it's centered on 0.0. Do an ABSA and it becomes a 0 to 0.25 triangle. Do whatever SOF(s) you need to get the range you want.
So you could switch between sine and square by simply checking default -1.0 to 1.0 SIN LFO for ZRC | NEG or ZRC | GEZ and then set the output to 0.0 or 0.999 (or whatever you wanted the levels to be).
I don't think it's straightforward to generate all 3 from one LFO, which is too bad. But maybe someone knows a way?
So you could switch between sine and square by simply checking default -1.0 to 1.0 SIN LFO for ZRC | NEG or ZRC | GEZ and then set the output to 0.0 or 0.999 (or whatever you wanted the levels to be).
I don't think it's straightforward to generate all 3 from one LFO, which is too bad. But maybe someone knows a way?
-
- Posts: 34
- Joined: Thu Nov 09, 2006 6:58 am
- Contact:
Triangle isn't that great for tremolo, sine gives you more of a log response and sounds smoother. If you want to do sine and square, you can use a crossfade to pan between them which is super cool. As DL says, you can get sine and square from the same oscillator with either SOFs (gets you more of a trapezoidal wave) or a skip routine.
Using a straight up ramp would be pretty gnarly, I might have to mess around with that at some point!
Using a straight up ramp would be pretty gnarly, I might have to mess around with that at some point!
If anyone's interested here's a tremolo I did using pot skip routines to do Sine, rectified sine both ways so pointy or humpy up and down ramps, triangle, trapezoid and square. All the wave shapes are scaled to the same range. Some of the wave shapes aren't that useful it was more an exercise in generating them than an attempt at a decent trem.
Feel free to do what you like with it.
Feel free to do what you like with it.
Code: Select all
;POT0 wave shape
;POT1 depth
;POT2 speed
;set up LFOs, only at start up
equ sine reg0
equ tri reg1
equ rampup reg2
equ rampdown reg3
equ square reg4
equ hypsin reg5
equ trap reg6
equ hump reg7
equ wave reg8
skp run, START
wlds sin0,0,16384
wlds sin1,0,16384
wldr rmp0,0,4096
START:
;get LFO speed from POT2
ldax pot2
sof 0.985,0.015
wrax rmp0_rate,1
sof 0.7849,0
wrax sin0_rate,1
sof 0.5,0
wrax sin1_rate,0
cho rdal,sin0
sof 1,0.5
wrax sine,0 ;sine wave
cho rdal,sin1
absa
sof -2,0.999
sof 1,0.001
wrax hypsin,1 ;Hyper triangle sort of
sof -1,0.999
sof 1,0.001
wrax hump,0 ;rectified sine humps
cho rdal,rmp0
sof -2,0.999
sof 1,0.001
wrax rampdown,1 ;downwards ramp
sof -1,0.999
sof 1,0.001
wrax rampup,1 ;upwards ramp
sof 1,-0.5
absa
sof -2,0.999
sof 1,0.001
wrax tri,1 ;triangle
sof 1,-0.5
sof -2,0
sof -2,0
sof 0.5,0.5
wrax trap,1 ;trapezoid
sof 1,-0.5
sof -2,0
sof -2,0
sof -2,0
sof -2,0
sof -2,0
sof 0.5,0.5
wrax square,0 ;square sort of might need more sofs to straighten the sides up more
ldax pot0
and %01110000_00000000_00000000
skp zro,ONE
sof 1,-0.125
skp zro,TWO
sof 1,-0.125
skp zro,THREE
sof 1,-0.125
skp zro,FOUR
sof 1,-0.125
skp zro,FIVE
sof 1,-0.125
skp zro,SIX
sof 1,-0.125
skp zro,SEVEN
EIGHT:
ldax square
wrax wave,0
skp zro,TREM
ONE:
ldax sine
wrax wave,0
skp zro,TREM
TWO:
ldax hump
wrax wave,0
skp zro,TREM
THREE:
ldax hypsin
wrax wave,0
skp zro,TREM
FOUR:
ldax tri
wrax wave,0
skp zro,TREM
FIVE:
ldax rampup
wrax wave,0
skp zro,TREM
SIX:
ldax rampdown
wrax wave,0
skp zro,TREM
SEVEN:
ldax trap
wrax wave,0
skp zro,TREM
TREM:
ldax wave
mulx pot1
sof -1,0.99
mulx adcl
wrax dacl,0
-
- Posts: 34
- Joined: Thu Nov 09, 2006 6:58 am
- Contact:
Slacker, that's a nice bit of code. Thanks for sharing.
I've played around with making a square wave starting with a sine or ramp and using SOFS but it takes a lot of them to get something that even approaches a real square wave.
Try something like this to really get square - start with the output of the sine wave in the accumulator (courtesy of livingston)
We're just taking the sign of the sine (if that makes sense) and using it to drive the output to the SOF statement values. Obviously tweak those to match the rest of your code. It's quick and actually gets a square.
I've played around with making a square wave starting with a sine or ramp and using SOFS but it takes a lot of them to get something that even approaches a real square wave.
Try something like this to really get square - start with the output of the sine wave in the accumulator (courtesy of livingston)
Code: Select all
skp NEG, out_low ; If negative, then skip
sof 0,0.5 ; Positive output
skp GEZ, scale_out ;Skip to the output step
out_low: sof 0,-0.5 ; Negative output
scale_out: mulx pot1
wrax square, 0