1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//! Mini-notation AST — the pattern language inside double quotes.
use ;
/// A generated melody: `solo(low..high, steps)`.
///
/// Walks the scale degrees `low..=high` in a weighted random walk, `steps`
/// notes per cycle. Deterministic per pattern and cycle — it evolves from
/// cycle to cycle but replays identically from the same buffer, like `?` and
/// `[a|b]`. `steps` may ramp (`solo(0..7, 4..16)`), so a solo can densify
/// across the line's `ramp` span.
/// The top-level mini-notation tree (contents of a quoted pattern string).
/// Represents a full cycle that will be looped.
/// An ordered list of steps that share their parent's time equally
/// (unless weights `@N` are present).
/// A single step in a sequence: an atom, zero or more modifiers, and an
/// optional velocity.
///
/// Modifiers stack and are applied left-to-right in written order, so `x*8?`
/// first expands into eight slots and then gives each of them a drop chance.
///
/// Velocity is a **field rather than a [`Modifier`]** because it is a property
/// of the step, not a transformation of the slots a modifier produced. The
/// slot-generating modifiers (`*N`, `!N`, `(k,n)`) run first and build the
/// slots; a velocity written anywhere in the run — `x:0.6*4` or `x*4:0.6` —
/// therefore applies to every slot the step generates, and cannot be read as
/// applying to only the slots that existed when it was written. It also makes
/// "at most one velocity per step" a type invariant instead of a check.
/// A byte range in a notation string, end exclusive.
///
/// Positions are not part of what a step means, so every `Source` compares
/// equal to every other. Two notations that differ only in spacing are the same
/// line: a test can write its expected AST without counting columns, and a
/// session does not mistake a re-indented line for an edited one and restart
/// its ramps.
/// The core building blocks of the mini-notation.
/// A pitched note with letter, accidental, and octave.
/// How the layers of a bracketed group relate to each other.
/// A bracketed group `[...]`.
///
/// `mode` records which separator was used. A group carries either commas or
/// pipes, never both, so the two never need precedence against each other.
/// A single-layer group is always [`GroupMode::Subdivide`].
/// An alternation `<...>` — cycles through the inner sequence steps, one per
/// loop iteration.
/// Modifiers that can be appended to any atom.