A pulse counting UGen. Each trigger increments a counter which is output as a
signal. The counter wraps inside the interval from lo
to hi
(inclusive).
That if you use a lo
other than zero, you might want to adjust resetVal
as
well. Stepper
always starts with the value in resetVal
, no matter what lo
is or whether the reset
trigger is high or not.
===Examples===
// arpeggio
play {
val tr = Impulse.ar(10)
val step = Stepper.ar(tr, lo = 4, hi = 16)
val freq = step * 100
SinOsc.ar(freq) * AmpComp.ar(freq) * 0.1
}
- See also
- Companion
- class
Type members
Value members
Concrete methods
- Value Params
- hi
The maximum value output. For an incremental
step
value, the counter jumps tolo
if it were to rise beyondhi
. Note that values greater than0x7FFFFFBF
(the default) cause numeric overflow and the UGen to malfunction.- lo
The minimum value output. For a decremental
step
value, the counter jumps tohi
if it were to fall belowlo
.- reset
A trigger which resets the counter to
resetVal
immediately.- step
The amount by which the counter increases or decreases upon receiving triggers. Note that if you use a decremental counter, still
lo
must be the minimum andhi
must be the maximum value output. Iflo
>hi
, the UGen behaves wrongly. In the case of decremental counter, setresetVal
tohi
. E.g. to count from 4 down to 0, useStepper.kr(trig, lo = 0, hi = 4, step = -1, resetVal = 4)
, or, if you want to ignore an initial high trigger, you could doStepper.kr(Impulse.kr(1), lo = 0, hi = 4, step = -1, resetVal = 0)
-- soresetVal
islo
but due to the initial trigger fromImpulse
theStepper
will in fact start outputting from4
.- trig
The trigger signal which increments the counter. A trigger happens when the signal changes from non-positive to positive. Note that if the UGen is created with the trigger initially high, the counter will also be incremented immediately. Thus a
Stepper.kr(Impulse.kr(1))
will begin by outputting1
. If you want to avoid this, you could their subtractImpulse.kr(0)
from the trigger input, or setresetVal
tohi
. E.g.Stepper.kr(Impulse.kr(1), lo = 0, hi = 4, resetVal = 4)
will produce the sequence 0, 1, 2, 4, 0, ...
- Value Params
- hi
The maximum value output. For an incremental
step
value, the counter jumps tolo
if it were to rise beyondhi
. Note that values greater than0x7FFFFFBF
(the default) cause numeric overflow and the UGen to malfunction.- lo
The minimum value output. For a decremental
step
value, the counter jumps tohi
if it were to fall belowlo
.- reset
A trigger which resets the counter to
resetVal
immediately.- step
The amount by which the counter increases or decreases upon receiving triggers. Note that if you use a decremental counter, still
lo
must be the minimum andhi
must be the maximum value output. Iflo
>hi
, the UGen behaves wrongly. In the case of decremental counter, setresetVal
tohi
. E.g. to count from 4 down to 0, useStepper.kr(trig, lo = 0, hi = 4, step = -1, resetVal = 4)
, or, if you want to ignore an initial high trigger, you could doStepper.kr(Impulse.kr(1), lo = 0, hi = 4, step = -1, resetVal = 0)
-- soresetVal
islo
but due to the initial trigger fromImpulse
theStepper
will in fact start outputting from4
.- trig
The trigger signal which increments the counter. A trigger happens when the signal changes from non-positive to positive. Note that if the UGen is created with the trigger initially high, the counter will also be incremented immediately. Thus a
Stepper.kr(Impulse.kr(1))
will begin by outputting1
. If you want to avoid this, you could their subtractImpulse.kr(0)
from the trigger input, or setresetVal
tohi
. E.g.Stepper.kr(Impulse.kr(1), lo = 0, hi = 4, resetVal = 4)
will produce the sequence 0, 1, 2, 4, 0, ...