CtkEvent:
Filter:
Ctk/Classes (extension) | Libraries > CTK

CtkEvent
ExtensionExtension

An event prototyping system for use with the CTK objects
 

Description

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

.new

Create a new CtkEvent

Arguments:

starttime

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

condition

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

amp

An amplitude scaler

function

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

addAction

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

target

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

server

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

Returns:

a CtkEvent

Instance Methods

.play

Plays this CtkEvent, while the condition is true.

.function

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.

Arguments:

newfunction

Function to be used.

.collect

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

Arguments:

... ctkevents

any number of CtkObjects to be performed by this event.

.condition

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.

Returns:

Condition to be used by this CtkEvent

.next

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.

Arguments:

inval

Duration in beats.

.score

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

Arguments:

sustime

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

Returns:

An instance of CtkScore

.record

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

Returns:

An instance of CtkScore

.now

Returns:

Current time since the start of the CtkEvent

.envbus

Returns:

The CtkControl where global amplitude data is written to

.release

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

.free

Free this CtkEvent.

.starttime

.server

.timer

.clear

.endtime

.group

Examples