Classes | JITLib > Patterns

Tdef : TaskProxy : PatternProxy : Pattern : AbstractFunction : Object

task reference definition


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

First Example

Class Methods

Creation, item)

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)


From superclass: TaskProxy

Default source, if none is given. The default task has a function that waits in 1.0 beat steps and does nothing.


From superclass: PatternProxy

Remove all proxies from the global dictionary ( *all )


From superclass: PatternProxy

Clear all proxies, setting their source to silence.


Tdef.all = value

Set or return the environment ( IdentityDictionary ) that stores all instances.


Tdef.defaultQuant = value

From superclass: TaskProxy

Set the default quantisation for new instances (default: 1.0). This can be an array [quant, phase, timingOffset, outset]

Inherited class methods

Undocumented class methods

Tdef.gui(numItems, bounds, preset)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/JITLib/GUI/


Instance Methods

Changing the definition / setting the source

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.


.quant = val

From superclass: PatternProxy

Set the quantisation time for beat accurate scheduling.



can be an array [quant, phase, timingOffset, outset], or just [quant, phase] etc.


.condition = value

From superclass: PatternProxy

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.

.count(n: 1)

From superclass: PatternProxy

Create and update condition that simply counts up to n and switches the pattern then


From superclass: PatternProxy

Switch the task immediately (stuck conditions can be subverted by this).


.envir = value

From superclass: PatternProxy

Set the environment (an Event) for the Tdef. It is passed as first argument into the Task function.

.set( ... args)

From superclass: PatternProxy

Set arguments in the default event. If there is none, it is created and the task routine is rebuilt.


From superclass: PatternProxy

Set the source to nil


From superclass: PatternProxy

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.

Tdef as stream reference

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.

.fork(clock, quant, event)

From superclass: TaskProxy

Play an independent task in parallel.



the clock on which to play the forked task


can be an array of [quant, phase, offset], or a Quant value.


an event to pass into the forked task


From superclass: PatternProxy

Pass a value (typically an Event) into the task function, and embed the Tdef in the stream.

.embedInStream(inval, embed: true, default)

From superclass: PatternProxy

just like any pattern, embeds itself in stream

Tdef as EventStreamPlayer

For live coding, each Tdef also may control one instance that plays one task. This is a PauseStream, accessible in the instance variable -player.

.play(argClock, doReset: false, quant)

From superclass: TaskProxy

Starts the Tdef and creates a player.



a clock on which to play the Tdef


a flag whether to reset the task if already playing


can be an array of [quant, phase, offset] or a Quant value.


From superclass: TaskProxy

Stops the player


From superclass: TaskProxy

Return the current player (if the Tdef is simply used in other streams this is nil)


From superclass: TaskProxy

.resume(clock, quant)

From superclass: TaskProxy


From superclass: PatternProxy

Perform this method on the player.


From superclass: TaskProxy

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.

Inherited instance methods

Undocumented instance methods


.gui(numItems, bounds, preset)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/JITLib/GUI/




Tdef as a Task player

Embed and fork: Tdef within other Tasks / Routines

Tdef as a time pattern

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.