diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-11 14:31:04 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-11 14:31:04 +0200 |
commit | ae198fa7592e7bf801f3678b11a854c5a4e6d04d (patch) | |
tree | ee50a455e45e4c403be78a4b6bc1bc261c1cf847 /lib/GenEvent.ck | |
parent | e711fce0ae256a18f9034d43888821c86219e15f (diff) | |
download | digitale-debutanten-ae198fa7592e7bf801f3678b11a854c5a4e6d04d.tar.gz |
moved value scaling functions from NanoEvent into "GenEvent" base class
so it can be used for other controller events as well
Diffstat (limited to 'lib/GenEvent.ck')
-rw-r--r-- | lib/GenEvent.ck | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/GenEvent.ck b/lib/GenEvent.ck new file mode 100644 index 0000000..63328ea --- /dev/null +++ b/lib/GenEvent.ck @@ -0,0 +1,43 @@ +/* + * Base class for controller events + */ +public class GenEvent extends Event { + /* normalized value between [0, 1] */ + float value; + + /* + * Getter functions to scale `value' + */ + fun float + getFloat() + { + return value; + } + fun float + getFloat(float max) + { + return max*value; + } + fun float + getFloat(float min, float max) + { + return min + (max - min)*value; + } + + fun dur + getDur(dur max) + { + return max*value; + } + fun dur + getDur(dur min, dur max) + { + return min + (max - min)*value; + } + + fun int + getBool() + { + return value $ int; + } +} |