Expressions
Expressions in Midio allow you to write small snippets of logic directly inside function inputs. They can be used anywhere a function input is editable and are a powerful way to perform computations or dynamically construct values inline.

What You Can Do with Expressions
Expressions support many of the constructs you'd expect from a general-purpose language:
Unary and binary operators: Use operators like
+
,-
,*
,/
,!
, and more to perform arithmetic and logical operations.Ternary operator: Use the
condition ? valueIfTrue : valueIfFalse
form to choose between values based on a condition.Literals: You can use basic data literals including numbers (
42
), strings ("hello"
), booleans (true
,false
), objects ({a: 1}
), and lists ([1, 2, 3]
).Use Local Variables: Local variables can be retrieved by prefixing their name with
@
, e.g.@myVariable
.Inputs: Add inputs to your expression by simply writing an identifier name (e.g.,
inputValue
). This adds an additional input property underneath the input you placed the expression in.Indexing and calls: Use
[index]
to access list or object properties and()
to call functions. Note: Functions must currently be passed in as inputs to be called in expressions.String interpolation: Embed expressions inside strings using
${...}
syntax. For example:"Hello, ${name}!"
.Call various builtin math functions, like math.cos(1.0), og math.random(0, 10). Following is a list of all builtin functions:
math.is_nan(x)
math.is_finite(x)
math.is_infinite(x)
math.is_normal(x)
math.cos(angle)
math.sin(angle)
math.tan(angle)
math.acos(x)
math.asin(x)
math.atan(x)
math.atan2(y, x)
math.cosh(x)
math.sinh(x)
math.tanh(x)
math.acosh(x)
math.asinh(x)
math.atanh(x)
math.ln(x)
math.log2(x)
math.log10(x)
math.log(base, x)
math.exp(x)
math.exp2(x)
math.pow(base, exponent)
math.sqrt(x)
math.cbrt(x)
math.abs(x)
math.hypot(x, y)
math.random()
math.min(a, b)
math.max(a, b)
math.clamp(x, min_val, max_val)
math.lerp(a, b, t)
math.sign(x)
math.floor(x)
math.ceil(x)
math.round(x)
math.trunc(x)
math.fract(x)
Limitations
Expressions currently cannot be used directly inside object literals—this will be added in a future update. See the working with data guide for more information about how you can work around this limitation for now.
Last updated
Was this helpful?