summaryrefslogtreecommitdiff
path: root/lib/GenEvent.ck
diff options
context:
space:
mode:
Diffstat (limited to 'lib/GenEvent.ck')
-rw-r--r--lib/GenEvent.ck34
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/GenEvent.ck b/lib/GenEvent.ck
index 63328ea..ba73445 100644
--- a/lib/GenEvent.ck
+++ b/lib/GenEvent.ck
@@ -2,9 +2,41 @@
* Base class for controller events
*/
public class GenEvent extends Event {
- /* normalized value between [0, 1] */
+ class Port extends Step {
+ fun void
+ update(GenEvent @ev, string control)
+ {
+ while (ev => now)
+ if (control => ev.isControl)
+ ev.getFloat(-1, 1) => next;
+ /* never reached */
+ }
+ }
+
+ /* symbolic control name */
+ string control;
+ /* normalized control value between [0, 1] */
float value;
+ fun int
+ isControl(string c)
+ {
+ return control == c;
+ }
+
+ /*
+ * Create and return UGen that generates a control's value,
+ * normalized between [-1, 1]
+ */
+ fun Step @
+ getPort(string control)
+ {
+ Port p;
+ spork ~ p.update(this, control);
+
+ return p;
+ }
+
/*
* Getter functions to scale `value'
*/