jevstrudel.git / packages / mini / README.md
1# @strudel/mini
2
3This package contains the mini notation parser and pattern generator.
4
5## Install
6
7```sh
8npm i @strudel/mini --save
9```
10
11## Example
12
13```js
14import { mini } from '@strudel/mini';
15
16const pattern = mini('a [b c*2]');
17
18const events = pattern.firstCycle().map((e) => e.show());
19console.log(events);
20```
21
22yields:
23
24```log
25(0/1 -> 1/2, 0/1 -> 1/2, a)
26(1/2 -> 3/4, 1/2 -> 3/4, b)
27(3/4 -> 7/8, 3/4 -> 7/8, c)
28(7/8 -> 1/1, 7/8 -> 1/1, c)
29```
30
31[Play with @strudel/mini codesandbox](https://codesandbox.io/s/strudel-mini-example-oe9wcu?file=/src/index.js)
32
33## Mini Notation API
34
35See "Mini Notation" in the [Strudel Tutorial](https://strudel.cc/learn/mini-notation)
36
37## Building the Parser
38
39The parser [krill-parser.js] is generated from [krill.pegjs](./krill.pegjs) using [peggy](https://peggyjs.org/).
40To generate the parser, run
41
42```js
43npm run build:parser
44```