EventLoop:
Filter:
KtlLoop (extension) | Libraries > JITLib

EventLoop
ExtensionExtension

Play with lists of events with recorded absolute and delta times.

Description

EventLoop is the base class for several XLoop classes that can record any kind of events (such as note events, controller events from gesture capturing, key presses etc) and play them back flexibly. It aims to unify earlier such classes like CtLoop (in the GamePad quark), KeyPlayerRec (in the KeyPlayer quark), and others.

EventLoop records events as

Its subclasses add features:

KeyLoop - events by keys

- event has time and single key as ID for events, e.g. char of keystroke on a computer keyboard, and a lookup dict of functions what to do for each key.

KtlLoop - lists of key/value pairs

- single func, all set e.g. a specific proxy to new settings; it can rescale parameter values by shift, scale, invert.

AutoLoop - still to be done, records movements of one slider as an semi-autonomous loop.

Class Methods

.new

make a new instance, with a key and a function to evaluate on playback.

Instance Methods

Instance Variables

.key

the key of the EventLoop

.task

a taskproxy for playback of recorded list

.func

the function to evaluate when playing back for each recorded event

.list

the current list of recorded events

.verbosity

get and set verbosity level for debugging. 0 is off.

Recording

.startRec

start recording. if instant = true, recording starts instantly; otherwise, recording will start with the first recorded event.

.recordEvent

record a new event into the list. event will consist of [abstime, deltatime ] ++ ... args provided

.stopRec

stop recording

.toggleRec

toggle recording on/off

.isRecording

flag whether EventLoop is currently recording

.getTimes

get current absolute and delta recording times

.addList

add the current list to the lists, e.g. after recording.

.clear

store current list and clear for recording

Playback

.play

play the recorded events using the taskproxy

.pause

.resume

pause and resume the playback taskproxy

.stop

stop the playback taskproxy

.togglePlay

toggle between play and stop

.isPlaying

flag whether internal taskproxy is playing

.loop

get and set flag whether playback loops.

.tempo

get and set playback tempo

.startPos

get and set where in (normalized) range of list event playback starts

.length

get and set which length in (normalized) range of list event playback to use

.endPos

startPos + length, position in normalized range where playback ends or loops

.jitter

get and set how much playback event order should jitter.

.step

get and set how much playback index moves at each step. 1 = forward.

.forward

set step to +1

.reverse

set step to -1

.isReversed

flag whether playback is reversed

.flip

reverse playback direction

.resetLoop

reset loop playback params to default

.quantizeTo

quantize recorded delta times for playback

Arguments:

quant

the quant to round absolute times to

totalDur

the duration to set the full duration to

.unquantize

reset delta times to unquantized state

Multiple List Handling

.lists

the recorded lists. first is newest list.

.listInfo

print indices and sizes of the current lists

.setList

set current list to one of the stored lists, by index.

.listDur

get the current list duration

.maxIndex

get the last index of current list

.currIndex

get the index of the current list in lists

.numLists

get the number of recorded lists

.printLists

print the lists in readabe form

Examples