Tdef registers tasks by key. All accesses to the registered tasks go through the Tdef class via that key. Registered tasks can be replaced with other tasks while playing. The old task and its replacement can automatically crossfade and the replacement time can be quantized.
Tdef provides an interface to its superclass TaskProxy. Tdef keeps a reference to a task ( time pattern ) that can be replaced while playing. It continues playing when the old stream ended and a new stream is set and schedules the changes to the beat. One Tdef may be used in many tasks in different places. A change in the task definition Tdef propagates through all tasks.
Graphical overview over all current Tdefs: TdefAllGui. Overview: JITLib
A global IdentityDictionary with all proxies.
Store the task in a global dictionary under key, replacing its routine function with the new one.
Using *new(key) you can access the pattern at that key (if none is given, a default task is created)
key |
An identifier for the proxy. Usually, it is a Symbol. The key transparently accesses the global IdentityDictionary. |
item |
An object for (re)defining the source of the proxy. If |
Default source, if none is given. The default task has a function that waits in 1.0 beat steps and does nothing.
Remove all proxies from the global dictionary ( *all )
Clear all proxies, setting their source to silence.
Set or return the environment ( IdentityDictionary ) that stores all instances.
Set the default quantisation for new instances (default: 1.0). This can be an array [quant, phase, timingOffset, outset]
One Tdef may have many tasks in different places. A change in the task definition Tdef propagates through all tasks. The change does not have to be immediate - there is a scheme to schedule when the change becomes effective: a quant and clock (like elsewhere) and a condition.
Set the quantisation time for beat accurate scheduling.
get or set the instance's default clock, used by -play if no other clock is specified. Defaults to TempoClock.default.
(val) |
can be an array [quant, phase, timingOffset, outset], or just [quant, phase] etc. |
Provide a condition under which the pattern is switched when a new one is inserted. The stream value and a count value is passed into the function.
Create and update condition that simply counts up to n and switches the pattern then
Switch the task immediately (stuck conditions can be subverted by this).
Set the environment (an Event) for the Tdef. It is passed as first argument into the Task function.
Set arguments in the default event. If there is none, it is created and the task routine is rebuilt.
Set the source to nil
Returns a Prout that plays the task endlessly, replacing nil with a default value 1. This allows to create streams that idle on until a new pattern is inserted.
A single Tdef may serve as a definition for multiple tasks. These methods show how to fork off separate routines from one instance. Even if they run in different contexts, their definition may still be changed.
Play an independent task in parallel.
clock |
the clock on which to play the forked task |
quant |
can be an array of [quant, phase, offset], or a Quant value. |
event |
an event to pass into the forked task |
Pass a value (typically an Event) into the task function, and embed the Tdef in the stream.
just like any pattern, embeds itself in stream
For live coding, each Tdef also may control one instance that plays one task. This is a PauseStream, accessible in the instance variable -player.
Starts the Tdef and creates a player.
argClock |
a clock on which to play the Tdef. If nil, uses the instance's -clock, which in turn defaults to TempoClock.default. |
doReset |
a flag whether to reset the task if already playing |
quant |
can be an array of [quant, phase, offset] or a Quant value. |
Stops the player
Return the current player (if the Tdef is simply used in other streams this is nil)
Perform this method on the player.
Returns true if player is running. If a Tdef is playing and its stream ends, it will schedule a stream for playing as soon as a new one is assigned to it. If it is stopped by stop, it won't.
Instead of using a Pdefn for time values, it can be useful to use a Tdef. When changing its source, it keeps the stream of values synchronized to its clock.