time
module reference
time
module reference
Time-variant operators.
index
- Default clock source (60fps).
- Generate rhythms based on a sequence of delays
- Create a clock source.
- Delay a !-stream event
- Emit events regularly.
- Low-frequency oscillator.
- Sawtooth LFO.
- Scale clock time.
- Smooth out value transitions
- Integrate impulses using easing
- Count ticks.
- Emit a sequence of values as events over time.
details
- Default clock source (60fps).
- Generate rhythms based on a sequence of delays
(bang-seq [clock] delay0 delay1…)
Emits
bang!
s with delaysdelay0
,delay1
, … in between.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.delay0
,delay1
, … must be num~ streams.
- Create a clock source.
(clock)
(clock fps)
Creates a new
time/clock!
stream.The clock event stream is an IO that triggers other operators at a fixed frame rate.
fps
has to be a num= constant and defaults to60
if omitted.
- Delay a !-stream event
(delay! [clock] delay evt)
Delays incoming
evt
s bydelay
.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.delay
should be a num= or num~ stream.evt
is a !-stream.
- Emit events regularly.
(every [clock] period [evt])
Emits
evt
as an event once everyperiod
seconds.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.period
should be a num~ stream.evt
can be a value of any type. It defaults tobang
.- the return type will be an event stream with the same type as
evt
.
- Low-frequency oscillator.
(lfo [clock] freq [wave])
Oscillates betwen
0
and1
at the frequencyfreq
.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.freq
should be a num~ stream.wave
selects the wave shape from one of the following:'sin'
(the default)'saw'
'tri'
- Sawtooth LFO.
(ramp [clock] period [max])
Ramps from
0
tomax
once everyperiod
seconds.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.period
should be a num~ stream.max
should be a num~ stream and defaults toperiod
if omitted.
- Scale clock time.
(scale-time [clock] scale)
Creates a new clock event stream scaled by
scale
.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.scale
should be a num~ stream.
- Smooth out value transitions
(smooth [clock] value rate)
Creates smooth transitions when
value
changes.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.value
should be a num~ or num! stream.rate
is a num~ or num= value.
- Integrate impulses using easing
(spring [clock] evt0 [evt1…])
Every arriving
evt
triggers an impulse that is integrated asclock
ticks. Returns a num~ stream that starts at 0.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.evt!
are !-streams of structs. The following struct keys can be specified:amp
: amplitude of the impulsedur
: duration of the impulse (seconds)del
: start delay (seconds)ease
: easing function to use
Instead of
dur
,in
andout
can be specified to create both an impulse and counterimpulse, which has an amplitude of-amp
and is delayed so as to start immediately after the original impulse. Similarily,easein
andeaseout
can be specified instead of the singleease
value. - Count ticks.
(tick [clock] period)
Counts upwards by one every
period
seconds.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.period
should be a num~ stream.- returns a
num~
stream that increases by 1 everyperiod
.
- Emit a sequence of values as events over time.
(val-seq [clock] delay0 evt1 delay1 evt2 delay2…)
Emits
evt1
,evt2
, … as events with delaysdelay0
,delay1
, … in between.clock
should be atime/clock!
stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*
instead.delay0
,delay1
, … must be num~ streams.evt1
,evt2
, … must be signal streams of the same type.- the return type will be an event stream with the same type as the
evt
s.