-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax of zwirn
actions are the basic building block of a zwirn program. there are different types of actions:
- definitions
- stream actions
- stream set actions
- etc.
multiple actions can be run simultaneously by separating them with a semicolon, for example
action1;
action2;
..
actionN;
if there is only one action, the semicolon can be omitted.
defintions are of the form
name var1 var2 .. varN = <<expression>>
this will create a new expression that can be referenced via it's name. var1 .. varN are variable names that can appear in the expression on the right-hand side.
Examples: x = [1 2 3 4]
, f x = [x x]
stream actions are of the form
<<id>> <- <<expression>>
this will start streaming the signal defined via the expression on the right hand side on the channel with the name <>, where <> can be a number or a string.
Examples: 1 <- s "bd"
, "myChannel" <- fast 4 $ s "sn"
Tidal's equivalent of the above would be d1 $ s "bd
and p "myChannel" $ fast 4 $ s "sn"
expressions are a way to notate signals and are defined recursively. there are three types of basic expressions:
- numbers:
0
,1.5
,-2
,-0.33333
, etc. - text:
""
,"hello"
,"zwirn"
, etc. - variables:
x
,y11
,hello
,cuteFunction
, etc.
these basic expressions are used to create more complex ones.
sequences are written in square brackets, with spaces between the inside expressions. They can be nested.
Examples: [1 2 3 4]
, [1 [2 3]]
, ["bd" "sn" mySample1 mySample2]
an application of an expression to other expression is written with spaces between the expressions, but not inside of square brackets.
Examples: rev [1 2 3 4]
, fast 2 [3 4]
to write applications inside of sequences, wrap the application in round brackets: [1 (rev [1 2 3 4]) 2 (every 4 (const [1 2]) 1)]