1--- 2title: Mondo Notation 3layout: ../../layouts/MainLayout.astro 4--- 5 6import { MiniRepl } from '../../docs/MiniRepl'; 7import { JsDoc } from '../../docs/JsDoc'; 8 9# Mondo Notation 10 11"Mondo Notation" is a new kind of notation that is similar to [Mini Notation](/learn/mini-notation/), but with enough abilities to make it work as a standalone pattern language. 12Here's an example: 13 14<MiniRepl 15 mondo 16 client:idle 17 tune={`$ note (c2 # euclid <3 6 3> <8 16>) # *2 18 # s "sine" # add (note [0 <12 24>]*2) 19 # dec(sine # range .2 2) 20 # room .5 21 # lpf (sine/3 # range 120 400) 22 # lpenv (rand # range .5 4) 23 # lpq (perlin # range 5 12 # * 2) 24 # dist 1 # fm 4 # fmh 5.01 # fmdecay <.1 .2> 25 # postgain .6 # delay .1 # clip 5 26 27$ s [bd bd bd bd] # bank tr909 # clip .5 28 29# ply <1 [1 [2 4]]> 30 31$ s oh\*4 # press # bank tr909 # speed.8 32 33# dec (<.02 .05>\*2 # add (saw/8 # range 0 1)) 34 35`} 36/> 37 38## Mondo in the REPL 39 40For now, you can only use mondo in the repl like this: 41 42<MiniRepl client:idle tune={'mondo`s hh*8`'} /> 43 44The rest of this site will only use the mondo notation itself. 45In the future, the REPL might get a way to use mondo notation directly. 46 47## Calling Functions 48 49Compared to Mini Notation, the most notable feature of Mondo Notation is the ability to call functions using round brackets: 50 51<MiniRepl mondo client:idle tune={`(s hh*8)`} /> 52 53The first element inside the brackets is the function name. In JS, this would look like: 54 55<MiniRepl client:idle tune={`s("hh*8")`} /> 56 57The outermost parens are not needed, so we can drop them: 58 59<MiniRepl mondo client:idle tune={`s hh*8`} /> 60 61## Mini Notation Features 62 63Besides function calling with round parens, Mondo Notation has a lot in common with Mini Notation: 64 65### Brackets 66 67- `[]` for 1-cycle sequences 68- `<>` for multi-cycle sequences 69- `{}` for stepped sequences (more on that later) 70 71### Infix Operators 72 73- \* => [fast](/learn/time-modifiers/#fast) 74- / => [slow](/learn/time-modifiers/#slow) 75- ! => [extend](/learn/stepwise/#extend) 76- @ => [expand](/learn/stepwise/#expand) 77- % => [pace](/learn/stepwise/#pace) 78- ? => [degradeBy](/learn/random-modifiers/#degradeby) (currently requires right operand) 79- : => tail (creates a list) 80- .. => range (between numbers) 81- , => [stack](/learn/factories/#stack) 82- | => [chooseIn](/learn/random-modifiers/#choose) 83 84### Example 85 86<MiniRepl 87 mondo 88 client:idle 89 tune={`note < 90[e5 [b4 c5] d5 [c5 b4]] 91[a4 [a4 c5] e5 [d5 c5]] 92[b4 [~ c5] d5 e5] 93[c5 a4 a4 ~] 94[[~ d5] [~ f5] a5 [g5 f5]] 95[e5 [~ c5] e5 [d5 c5]] 96[b4 [b4 c5] d5 e5] 97[c5 a4 a4 ~] 98>`} 99/> 100 101## Chaining Functions 102 103Similar to how "." works in javascript (JS), we can chain functions calls with the "#" operator: 104 105<MiniRepl 106 mondo 107 client:idle 108 tune={`n <0 2 4 [3 1] -1>*4 109 # scale C4:minor 110 # jux rev 111 # dec .2 112 # delay .5`} 113/> 114 115Here's the same written in JS: 116 117<MiniRepl 118 client:idle 119 tune={`n("<0 2 4 [3 1] -1>*4") 120 .scale("C4:minor") 121 .jux(rev) 122 .dec(.2) 123 .delay(.5)`} 124/> 125 126### Chaining Functions Locally 127 128A function can be applied to a single element by wrapping it in round parens: 129 130<MiniRepl mondo client:idle tune={`s [bd hh bd (cp # delay .6)] # bank tr909`} /> 131 132in this case, `delay .6` will only be applied to `cp`. compare this with the JS version: 133 134<MiniRepl client:idle tune={`s(seq("bd", "hh", "bd", "cp".delay(.6))).bank('tr909')`} /> 135 136here we can see how much we can save when there's no boundary between mini notation and function calls! 137 138### Chaining Infix Operators 139 140Infix operators exist as regular functions, so they can be chained as well: 141 142<MiniRepl client:idle mondo tune={`s [bd hh] # bank tr909 # *2`} /> 143 144In this case, the \*2 will be applied to the whole pattern. 145 146### Lambda Functions 147 148Some functions in strudel expect a function as input, for example: 149 150<MiniRepl client:idle tune={`n("0 .. 7").scale("C:minor").sometimes(x=>x.dec(.1))`} /> 151 152in mondo, the `x=>x.` can be shortened to: 153 154<MiniRepl client:idle mondo tune={`n 0..7 # scale C:minor # sometimes (# dec .1)`} /> 155 156chaining works as expected: 157 158<MiniRepl client:idle mondo tune={`n 0..7 # scale C:minor # sometimes (# dec .1 # jux rev)`} /> 159 160## Strings 161 162You can use "double quotes" and 'single quotes' to get a string: 163 164<MiniRepl client:idle mondo tune={`n 0..7 # scale 'C minor'`} /> 165 166## Multiple Patterns 167 168The `$` sign can be used to separate multiple patterns: 169 170<MiniRepl 171 client:idle 172 mondo 173 tune={`$ s [bd rim [~ bd] rim] # bank tr707 174$ chord <Dm9!3 Db7> # voicing 175 # struct[x ~ ~ x ~ x ~ ~] # delay .5`} 176/> 177 178The `$` sign is an alias for `,` so it will create a stack behind the scenes. 179 180## variables 181 182using the `def` keyword, you can define variables: 183 184<MiniRepl 185 client:idle 186 mondo 187 tune={` 188$ def melody [0 1 2 3] 189$ n melody # scale C:minor 190`} 191/>