Jaffle Syntax
This page aims to provide an overview of the Jaffle syntax, for people already familiar with the Strudel language.
If necessary, read the Strudel documentation to understand how to write music with Strudel.
Most of this syntax is used both in the yaml and node editors: when editing a node, you can add a prefix or a suffix to change its behavior.
Yaml basics
Jaffle uses the Yaml syntax. Here is the basic usage:
# I'm a comment
- array:
- 1
- 2
- dictionary:
a: 1
b: 2
- array of dictionaries:
- a1: 1
b1: 2
- a2: 3
b2: 4
- inline array: [ 1, 2, 3 ]
- inline dict: { a: 1, b: 2 }
- inline array of dictionaries: [ a: 1, b: 2 ]
- literals:
- string: hello
- quoted string: '[ 1, 2, 3 ]'
- number: 42
- float: 2.21
- null value:
Mini-notation
Mini-notation strings are prefixed with _
:
Strudel | Jaffle |
|
|
Chained functions
Chained functions are array items following the first function, prefixed with .
:
Strudel | Jaffle |
|
|
You can consider that this prefix visually acts as a small indentation character. ;)
Function parameters
Function parameters are defined in an array:
Strudel | Jaffle |
|
|
Note that the yaml root element must also be an array (hence the first -
).
Functions without parameters
It is safe to have a yaml attribute without value (just don’t forget the :
sign):
Strudel | Jaffle |
|
|
List of chained functions
When functions chains follow each other, they are still on the same level:
Strudel | Jaffle |
|
|
In this case it is suggested to split function chains with a blank line.
Data serialization
To pass structured data in a parameter, you must add ^
after the attribute name:
Strudel | Jaffle |
|
|
To serialize data on a specific argument, add its index next to ^
, starting from 1 (ie. foo^1:
).
Signals
Keywords without parenthesis like signals are written with a capital on the first letter:
Strudel | Jaffle |
|
|
Expressions
To put an expression in a parameter, prepend it by the =
sign:
Strudel | Jaffle |
|
|
Such expressions are limited to simple mathematics (+
, -
, *
, /
, **
).
Functions in parameters
To pass a function in a parameter such as in accumulation modifiers, use set
(here with an inline dictionnary):
Strudel | Jaffle |
|
|
If necessary, additional parameters can be passed in the set
value:
Strudel | Jaffle |
|
|
More parameters could be added using an array (ie. set: [ n, m ]
).
Using variables
Variables can be defined using the $
prefix and accessed in expressions (=
):
Strudel | Jaffle |
|
|