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.clockshould 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.
fpshas to be a num= constant and defaults to60if omitted.
- Delay a !-stream event
(delay! [clock] delay evt)Delays incoming
evts bydelay.clockshould be atime/clock!stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*instead.delayshould be a num= or num~ stream.evtis a !-stream.
- Emit events regularly.
(every [clock] period [evt])Emits
evtas an event once everyperiodseconds.clockshould be atime/clock!stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*instead.periodshould be a num~ stream.evtcan 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
0and1at the frequencyfreq.clockshould be atime/clock!stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*instead.freqshould be a num~ stream.waveselects the wave shape from one of the following:'sin'(the default)'saw''tri'
- Sawtooth LFO.
(ramp [clock] period [max])Ramps from
0tomaxonce everyperiodseconds.clockshould be atime/clock!stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*instead.periodshould be a num~ stream.maxshould be a num~ stream and defaults toperiodif omitted.
- Scale clock time.
(scale-time [clock] scale)Creates a new clock event stream scaled by
scale.clockshould be atime/clock!stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*instead.scaleshould be a num~ stream.
- Smooth out value transitions
(smooth [clock] value rate)Creates smooth transitions when
valuechanges.clockshould be atime/clock!stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*instead.valueshould be a num~ or num! stream.rateis a num~ or num= value.
- Integrate impulses using easing
(spring [clock] evt0 [evt1…])Every arriving
evttriggers an impulse that is integrated asclockticks. Returns a num~ stream that starts at 0.clockshould 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,inandoutcan be specified to create both an impulse and counterimpulse, which has an amplitude of-ampand is delayed so as to start immediately after the original impulse. Similarily,easeinandeaseoutcan be specified instead of the singleeasevalue. - Count ticks.
(tick [clock] period)Counts upwards by one every
periodseconds.clockshould be atime/clock!stream. This argument can be omitted and the stream be passed as a dynamic definition in*clock*instead.periodshould 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.clockshould 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
evts.