Classes (extension) | Libraries > CTK

CtkEvent : CtkObj : Object

An event prototyping system for use with the CTK objects
Source: CTK.sc


Part of the Composer's Tool Kit (CTK) system. See CTK for more details.

CtkEvent lets you create a single layer or gesture, with a global amp and envelope control, and render it out as a score (or play back in real-time).

CtkEvent keeps an internal clock that is advanced by 'next'. All notes are scheduled relative to this clock, so starttimes of 0 will schedule an event at wherever that internal clock is. These times can be offset with CtkEvents' 'starttime' parameter.

You control how many times the function runs with 'condition'... either an integer saying how many times to loop, or an Envelope. When the internal clock has been advanced to the end of the Envelope, it will stop.

Class Methods

CtkEvent.new(starttime: 0.0, condition, amp: 1, function, addAction: 0, target: 1, server)

Create a new CtkEvent



An offset from the current time (in play mode) or the starttime of the event (if non-real-time rendering is used).


A control for note event creation. See -condition for more details.


An amplitude scaler


A function to be evaluated for every occurrence in the CtkEvent. See -function for more details.


A symbol (\head, \tail, \before, \after or \replace) or an addAction id (see Server Command Reference: /s_new)


A node ID (synth or group) or an instance of CtkGroup or CtkNote


The server to execute the node on. Defaults to Server.default for real-time performance


a CtkEvent

Inherited class methods

Instance Methods


Plays this CtkEvent, while the condition is true.


.function = newfunction

A function to be evaluated for every occurrence in the CtkEvent. May be defined at the creation time (see *new). It should be used to -collect CtkObjects for this CtkEvent. If the -condition is an Env, the function will also be typically used to set the -next parameter, scheduling repeated execution appropriately. The function will have five parameters passed to it:

While the condition is true and the CtkEvent's 'next' parameter is not nil, the function will be repeatedly called.



Function to be used.

.collect( ... ctkevents)

This is the method to populate CtkEvent with CtkObjects (like CtkNote). Typically .collect will be called inside this CtkEvent's -function.


... ctkevents

any number of CtkObjects to be performed by this event.


.condition = value

If this is a number, the -function of the CtkEvent will be executed that many times. If it is an Env, the function will be executed until the duration is satisfied (or, if the Env has a releaseNode, until .release is called and the Env has finished). Condition can also be a Boolean, or a function to be evaluated on each execution of the function. If a function is given for the condition, the internal CtkTimer and instance var 'inc' are available as arguments. The function should return a Boolean.


Condition to be used by this CtkEvent


.next = inval

From superclass: Object

A duration in beats for rescheduling the execution of the CtkEvent function. Defaults to 'nil'. If the value remains 'nil', no further execution will be allowed, regardless of condition. 0.0 is an allowable value, but if this is the case, your condition must terminate the execution of the event to avoid an infinite loop.



Duration in beats.

.score(sustime: 0)

Get a CtkScore with notes that are collected from the function while the condition is true.



If the condition is a sustaining envelope, the sustain duration can be passed into the method


An instance of CtkScore


Plays the CtkEvent, and records the performance into a CtkScore.


An instance of CtkScore



Current time since the start of the CtkEvent



The CtkControl where global amplitude data is written to


Release this CtkEvent. This works if a sustained Envelope is used as a -condition.


Free this CtkEvent.


From superclass: CtkObj

Add this object to a CtkScore



An instance of CtkScore







Inherited instance methods