A Slew Like Opcode
| Date | 2016-12-21 02:01 |
| From | Peter Burgess |
| Subject | A Slew Like Opcode |
Hi again Csound world! I've been thinking for ages an opcode that
limits the rate a figure can increase or decrease would be good. Kind
of like a slew effect, but more of a cap on how quickly figures can
change, rather than a general slow down of change.
It's easy to make a super simple UDO version, but it would be a great
tool to have in general:
opcode slew_linear k, ki
kIn, iIncrememt xin
; kIn sets where we want the slew to get to
; kPrev/kOut is where we are currently
if kPrev < kIn then
kOut = kPrev + iIncrement
elseif kPrev > kIn then
kOut = kPrev - iIncrement
endif
kPrev = kOut
xout kOut
endop
opcode slew_exponential k, ki
kIn, iIncrememt xin
; kIn sets where we want the slew to get to
; kPrev/kOut is where we are currently
if kPrev < kIn then
kOut = kPrev * iIncrement
elseif kPrev > kIn then
kOut = kPrev / iIncrement
endif
kPrev = kOut
xout kOut
endop
I'm going to make them more usable by sending a miniumum time to slide
from 0-0dbfs parameter so the code can work out the increment based on
sr/kr and what not, instead of a basic increment parameter that is
sr/kr dependant, and not so easy to conceptualise while using.
If this already exists, then fantastic :D if not I'm going to write one.
To anyone who was following, I have nearly finished the a-rate loopseg
opcode now too... one more problem to iron out and it's ready to go ;) |
| Date | 2016-12-21 02:23 |
| From | mskala@ANSUZ.SOOKE.BC.CA |
| Subject | Re: A Slew Like Opcode |
The "port" opcode is what people usually use for this. It's exponential like a capacitor, which is a little different from being exponential like the code you posted. If you do roll your own implementation, take care handling overshoot; you probably don't want it to oscillate around the target value in case of not hitting exactly. |
| Date | 2016-12-21 09:01 |
| From | Peter Burgess |
| Subject | Re: A Slew Like Opcode |
Oh! Good point, I hasn't considered that yet. I also forgot to add an initialisation of kPrev, which should be initialised to kin. I'll check out port anyway, if it does the trick, then no need for any roll ups ;) On 21 Dec 2016 2:23 a.m., <mskala@ansuz.sooke.bc.ca> wrote: The "port" opcode is what people usually use for this. It's |