public final class Clock extends Object implements Graph.Dependent
Clock provides a Linkable.Int for subscribing to triggers,
maintaining a continuously rising count. It is also possible to add Runnable
functions to be called on each clock trigger.
Clock fields may be annotated with Inject.
| Constructor and Description |
|---|
Clock() |
| Modifier and Type | Method and Description |
|---|---|
void |
attach(Graph graph)
Optional hook called when attached to the Graph.
|
double |
bpm() |
Clock |
bpm(double bpm) |
Clock |
clearLinks()
Clear all Linkables from this Trigger.
|
int |
index()
Get the current index.
|
Clock |
index(int idx)
Set the current index.
|
Clock |
link(Runnable runnable)
Run the provided Runnable each time this Trigger is triggered.
|
int |
maxIndex()
Get the current maximum index.
|
Clock |
maxIndex(int max)
Set the maximum index, at which the index will wrap back to zero.
|
Linkable.Int |
on()
Returns a new
Linkable.Int for listening to each trigger. |
int |
subdivision() |
Clock |
subdivision(int subdivision) |
void |
update()
Called before every new buffer is processed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdetachpublic void attach(Graph graph)
Graph.Dependentattach in interface Graph.Dependentgraph - the Graph being added topublic void update()
Graph.Dependentupdate in interface Graph.Dependentpublic Clock bpm(double bpm)
public double bpm()
public Clock subdivision(int subdivision)
public int subdivision()
public Clock clearLinks()
public Clock link(Runnable runnable)
on().link(i -> runnable.run());.runnable - function to run on triggerpublic Linkable.Int on()
Linkable.Int for listening to each trigger. The int
passed to the created linkable will be the same as index, incrementing
each time, wrapping at maxIndex.public Clock index(int idx)
idx - new indexpublic Clock maxIndex(int max)
max - maximum indexpublic int index()
public int maxIndex()
Copyright © 2020. All rights reserved.