From d9ed2848c4709aa5f3757333dab0ec8de5833aef Mon Sep 17 00:00:00 2001 From: s-ol Date: Tue, 11 Feb 2020 10:49:42 +0100 Subject: add MIDI input ops --- lib/util.moon | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/util.moon') diff --git a/lib/util.moon b/lib/util.moon index 849466c..6da3698 100644 --- a/lib/util.moon +++ b/lib/util.moon @@ -1,4 +1,4 @@ -import Op from require 'core' +import Const, Op from require 'core' class switch_ extends Op @doc: "(switch i v0 [v1 v2...]) - switch between multiple inputs @@ -52,17 +52,18 @@ like (switch ...) except that the unused inputs are paused." active\get! class keep extends Op - @doc: "(keep value) - keep the last non-nil value + @doc: "(keep value [default]) - keep the last non-nil value -always reproduces the last non-nil value the input produced" +always reproduces the last non-nil value the input produced or default. +default defaults to zero." - setup: (@i) => + setup: (@i, @default=Const.num 0) => update: (dt) => @i\update dt next = @i\get! - @value = next or @value + @value = next or @value or @default\get! { 'switch': switch_ -- cgit v1.2.3