diff --git a/packages/mondo/mondo.mjs b/packages/mondo/mondo.mjs index fe48509c5..142b856dc 100644 --- a/packages/mondo/mondo.mjs +++ b/packages/mondo/mondo.mjs @@ -309,8 +309,9 @@ export function printAst(ast, compact = false, lvl = 0) { const br = compact ? '' : '\n'; const spaces = compact ? '' : Array(lvl).fill(' ').join(''); if (ast.type === 'list') { - return `${lvl ? br : ''}${spaces}(${ast.children.map((child) => printAst(child, compact, lvl + 1)).join(' ')}${ast.children.find((child) => child.type === 'list') ? `${br}${spaces})` : ')' - }`; + return `${lvl ? br : ''}${spaces}(${ast.children.map((child) => printAst(child, compact, lvl + 1)).join(' ')}${ + ast.children.find((child) => child.type === 'list') ? `${br}${spaces})` : ')' + }`; } return `${ast.value}`; } diff --git a/packages/mondo/test/mondo.test.mjs b/packages/mondo/test/mondo.test.mjs index 41558aaab..6393b10f9 100644 --- a/packages/mondo/test/mondo.test.mjs +++ b/packages/mondo/test/mondo.test.mjs @@ -141,8 +141,8 @@ describe('mondo sugar', () => { describe('mondo arithmetic', () => { let multi = (op) => - (init, ...rest) => - rest.reduce((acc, arg) => op(acc, arg), init); + (init, ...rest) => + rest.reduce((acc, arg) => op(acc, arg), init); let lib = { '+': multi((a, b) => a + b), diff --git a/website/src/pages/learn/mondo-notation.mdx b/website/src/pages/learn/mondo-notation.mdx index 2bc952341..ccf5b72b6 100644 --- a/website/src/pages/learn/mondo-notation.mdx +++ b/website/src/pages/learn/mondo-notation.mdx @@ -14,20 +14,25 @@ Here's an example: <8 16>) . *2 -.s "sine" .add (note [0 <12 24>]*2) -.dec(sine .range .2 2) .room .5 -.lpf(sine/3.range 120 400) -.lpenv(rand .range .5 4) -.lpq(perlin .range 5 12 . * 2) -.dist 1 .fm 4 .fmh 5.01 .fmdecay <.1 .2> -.postgain .6 .delay .1 .clip 5 + tune={`$ note (c2 # euclid <3 6 3> <8 16>) # *2 + # s "sine" # add (note [0 <12 24>]*2) + # dec(sine # range .2 2) + # room .5 + # lpf (sine/3 # range 120 400) + # lpenv (rand # range .5 4) + # lpq (perlin # range 5 12 # * 2) + # dist 1 # fm 4 # fmh 5.01 # fmdecay <.1 .2> + # postgain .6 # delay .1 # clip 5 -$ s [bd bd bd bd] .bank tr909.clip.5 -.ply<1 [1 [2 4]]> +$ s [bd bd bd bd] # bank tr909 # clip .5 -$ s oh*4 .press .bank tr909 .speed.8 -.dec (<.02 .05>*2 .add (saw/8.range 0 1))`} +# ply <1 [1 [2 4]]> + +$ s oh\*4 # press # bank tr909 # speed.8 + +# dec (<.02 .05>\*2 # add (saw/8 # range 0 1)) + +`} /> ## Mondo in the REPL @@ -95,16 +100,16 @@ Besides function calling with round parens, Mondo Notation has a lot in common w ## Chaining Functions -Similar to how it works in JS, we can chain functions calls with the "." operator: +Similar to how "." works in javascript (JS), we can chain functions calls with the "#" operator: *4 -.scale C4:minor -.jux rev -.dec .2 -.delay .5`} + # scale C4:minor + # jux rev + # dec .2 + # delay .5`} /> Here's the same written in JS: @@ -112,29 +117,29 @@ Here's the same written in JS: *4") -.scale("C4:minor") -.jux(rev) -.dec(.2) -.delay(.5)`} + # scale("C4:minor") + # jux(rev) + # dec(.2) + # delay(.5)`} /> ### Chaining Functions Locally -A function can be applied "locally" by wrapping it in round parens: +A function can be applied to a single element by wrapping it in round parens: - + in this case, `delay .6` will only be applied to `cp`. compare this with the JS version: -here we can see much we can save when there's no boundary between mini notation and function calls! +here we can see how much we can save when there's no boundary between mini notation and function calls! ### Chaining Infix Operators Infix operators exist as regular functions, so they can be chained as well: - + In this case, the \*2 will be applied to the whole pattern. @@ -146,17 +151,17 @@ Some functions in strudel expect a function as input, for example: in mondo, the `x=>x.` can be shortened to: - + chaining works as expected: - + ## Strings You can use "double quotes" and 'single quotes' to get a string: - + ## Multiple Patterns @@ -165,9 +170,9 @@ The `$` sign can be used to separate multiple patterns: .voicing -.struct[x - - x - x - -].delay.5`} + tune={`$ s [bd rim [~ bd] rim] # bank tr707 +$ chord # voicing + # struct[x ~ ~ x ~ x ~ ~] # delay .5`} /> The `$` sign is an alias for `,` so it will create a stack behind the scenes.