animader-cli 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,836 @@
1
+ ; The hosted `it/` tier — the Impulse Tracker vocabulary (P99, plan 02;
2
+ ; the it set's 02 with its 2026-08-25 amendments).
3
+ ;
4
+ ; One `(module …)` root holding the song-level forms, the instruments, the
5
+ ; samples and the patterns. Every form mirrors a real IT concept with
6
+ ; ITTECH.TXT provenance; omission means the IT default, so a minimal
7
+ ; document is tiny; and bulk bytes ride `(bin :at :len)` refs against the
8
+ ; anchor's file rather than living in the text.
9
+ ;
10
+ ; Adopted from the 2026-08-25 amendments: hex integers on `(bin …)`
11
+ ; offsets and the created-with / compatible-with pair (1); slot-locals for
12
+ ; `row`, `ev`, `node`, `range`, `ch`, `macro`, `vibrato`, `data` — and for
13
+ ; `notemap` and the three envelopes, which are as generic and as
14
+ ; instrument-only (2); positional counts, so "at most 25 nodes" is
15
+ ; `positional_too_many` at the node that crosses the ceiling rather than
16
+ ; prose (3); `:requires` for the keys that are inert alone — `:loop-mode`,
17
+ ; `:sustain-mode`, a MIDI `:program` / `:bank`, a `(range …)`'s
18
+ ; `:transpose` (5); and the numeric refinements with the byte-width
19
+ ; caveat — `:repr u32` / `u16` where they fit and plain integer bounds for
20
+ ; every byte-wide field, `(unit-shape :reject true)` throughout (6).
21
+ ; `scalar-or-ref` on `:ins` is adopted with its reference half UNCHECKED
22
+ ; (7's cross-ref needs a symbol `:name` on `(instrument …)`, which the
23
+ ; it set parks at T1 and its own examples spell as a string), so `:ins 2`
24
+ ; and `:ins bass` both validate and the writer emits the integer.
25
+ ; Recorded and not adopted: variants (4) — no enum here gates a key yet —
26
+ ; and PatternQuery authoring (8).
27
+ ;
28
+ ; `source`, `timing` and `options` are GLOBAL here where the it set's
29
+ ; amendment 2 makes them slot-locals of `module`. That is not a
30
+ ; disagreement about how generic the names are; it is what tempura's own
31
+ ; spelling needs. A dump inside a timeline document writes its heads
32
+ ; QUALIFIED — `(it/module … (it/timing …) (it/orders …))` — and a
33
+ ; qualified head bypasses locals by design, resolving global-only
34
+ ; (`portable-manifest-v1.md` §5.2). The leaf forms stay local because
35
+ ; tempura's own example spells them bare: `(row 0 (ev 3 "C-5" …))`,
36
+ ; `(data :bits 16 … (bin …))`. `(bin …)` is global, as the amendment
37
+ ; says, because it appears under both `data` and `pattern`.
38
+ ;
39
+ ; One key is tempura's and is not in the it set's manifest: `:raw` on
40
+ ; `(instrument …)` and `(sample …)`, an opaque-body spelling
41
+ ; (plan 06, "The binary model"). tempura materialises the TIMING subset —
42
+ ; header fields, orders, patterns, message — and keeps instruments and
43
+ ; samples as opaque records with their names and a `(bin …)` per body, so
44
+ ; a batida dump validates here while a document that spells an instrument
45
+ ; field tempura did not materialise is `it_field_not_materialized` at
46
+ ; build. The key is filed to the it set as an ask.
47
+ ;
48
+ ; Owner of record: this manifest restates the it set's, whose repo
49
+ ; (batida) does not exist yet; when it does, one owner is picked per
50
+ ; manifest (plan 01, "Two sibling repos, one owner per file").
51
+ ;
52
+ ; No `:version`, for the reason `schema/tempura.sjon` declares none.
53
+
54
+ (plugin :name it
55
+ :description "An Impulse Tracker module as a document: the header, the channel defaults, the order list, the message, the instruments and samples (opaque bodies with their names), and the patterns as sparse rows of cells."
56
+
57
+ ; =====================================================================
58
+ ; Identifiers and counts
59
+ ; =====================================================================
60
+
61
+ (value-kind :name pattern-id
62
+ :description "A pattern number, 0..199 — the order list's entries and a (pattern …)'s own id."
63
+ :underlying number
64
+ :numeric (numeric-bounds :min 0 :max 199 :integer true)
65
+ :unit (unit-shape :reject true))
66
+
67
+ (value-kind :name order-symbol
68
+ :description "An order-list entry that is not a pattern."
69
+ :underlying symbol
70
+ :members (member-set
71
+ (member :name skip :description "254, shown as +++: play nothing and move on.")
72
+ (member :name end :description "255, shown as ---: the end of the song. A trailing one is implicit and not written.")))
73
+
74
+ (value-kind :name order-entry
75
+ :description "One order-list entry: a pattern number, or `skip` / `end`."
76
+ :underlying union
77
+ :union (union-shape :alternatives [pattern-id order-symbol]))
78
+
79
+ (value-kind :name instrument-id
80
+ :description "An instrument number, 1..99."
81
+ :underlying number
82
+ :numeric (numeric-bounds :min 1 :max 99 :integer true)
83
+ :unit (unit-shape :reject true))
84
+
85
+ (value-kind :name ins-ref
86
+ :description "An instrument: its number, or a bare symbol naming one. The writer always emits the number; the symbol half is authoring comfort and is not checked against the module's instruments here (the it set parks the cross-ref at T1, since it would need a symbol :name on (instrument …) and its own examples spell that as a string)."
87
+ :underlying scalar-or-ref
88
+ :scalar-or-ref (scalar-or-ref-shape :base instrument-id))
89
+
90
+ (value-kind :name sample-id
91
+ :description "A sample number, 1..99."
92
+ :underlying number
93
+ :numeric (numeric-bounds :min 1 :max 99 :integer true)
94
+ :unit (unit-shape :reject true))
95
+
96
+ (value-kind :name channel-number
97
+ :description "A channel, 1..64, counted from 1 as IT's own display does."
98
+ :underlying number
99
+ :numeric (numeric-bounds :min 1 :max 64 :integer true)
100
+ :unit (unit-shape :reject true))
101
+
102
+ (value-kind :name rows-count
103
+ :description "A pattern's row count. IT writes 32..200; 1..1024 is accepted on read with a diagnostic."
104
+ :underlying number
105
+ :numeric (numeric-bounds :min 1 :max 1024 :integer true)
106
+ :unit (unit-shape :reject true))
107
+
108
+ ; =====================================================================
109
+ ; Header scalars
110
+ ; =====================================================================
111
+
112
+ (value-kind :name speed-value
113
+ :description "Ticks per row (IT's IS). 6 is the default; 0 on disk reads as 6."
114
+ :underlying number
115
+ :numeric (numeric-bounds :min 1 :max 255 :integer true)
116
+ :unit (unit-shape :reject true))
117
+
118
+ (value-kind :name tempo-value
119
+ :description "Initial tempo in IT's own units (its IT field), 32..255 in practice. A lower value is playable and warned about rather than refused."
120
+ :underlying number
121
+ :numeric (numeric-bounds :min 1 :max 255 :integer true)
122
+ :unit (unit-shape :reject true))
123
+
124
+ (value-kind :name highlight-component
125
+ :description "One of the row-highlight pair: rows per beat, then rows per measure."
126
+ :underlying number
127
+ :numeric (numeric-bounds :min 1 :max 255 :integer true)
128
+ :unit (unit-shape :reject true))
129
+
130
+ (value-kind :name highlight-pair
131
+ :description "The editor's row highlight as [minor major] — rows per beat and per measure. It is also where an IT conductor's default meter comes from."
132
+ :underlying vector
133
+ :vector (vector-shape :len 2 :element highlight-component))
134
+
135
+ (value-kind :name it-byte
136
+ :description "A byte-wide header scalar, 0..255. There is no u8 repr tag, so byte-wide fields carry plain integer bounds."
137
+ :underlying number
138
+ :numeric (numeric-bounds :min 0 :max 255 :integer true)
139
+ :unit (unit-shape :reject true))
140
+
141
+ (value-kind :name it-vol
142
+ :description "A volume, 0..64 — IT's own range."
143
+ :underlying number
144
+ :numeric (numeric-bounds :min 0 :max 64 :integer true)
145
+ :unit (unit-shape :reject true))
146
+
147
+ (value-kind :name it-pan
148
+ :description "A pan position, 0..64 — 0 hard left, 32 centre, 64 hard right."
149
+ :underlying number
150
+ :numeric (numeric-bounds :min 0 :max 64 :integer true)
151
+ :unit (unit-shape :reject true))
152
+
153
+ (value-kind :name it-level
154
+ :description "A global / mix / separation level, 0..128."
155
+ :underlying number
156
+ :numeric (numeric-bounds :min 0 :max 128 :integer true)
157
+ :unit (unit-shape :reject true))
158
+
159
+ (value-kind :name version-word
160
+ :description "A created-with (Cwt/v) or compatible-with (Cmwt) version word, read and written in hex: 0x0214, 0x0200."
161
+ :underlying number
162
+ :numeric (numeric-bounds :min 0 :max 65535 :integer true)
163
+ :unit (unit-shape :reject true)
164
+ :repr (repr-shape :type u16))
165
+
166
+ ; =====================================================================
167
+ ; Cells
168
+ ; =====================================================================
169
+
170
+ (value-kind :name note-name
171
+ :description "A note as IT's editor shows it: \"C-0\" through \"B-9\", sharps spelled with #. Three characters exactly; the pitch is checked at build."
172
+ :underlying string
173
+ :string-bounds (string-bounds :min-len 3 :max-len 3))
174
+
175
+ (value-kind :name note-symbol
176
+ :description "A note-column entry that is not a pitch."
177
+ :underlying symbol
178
+ :members (member-set
179
+ (member :name off :description "255 — note off.")
180
+ (member :name cut :description "254 — note cut.")
181
+ (member :name fade :description "246 — note fade.")))
182
+
183
+ (value-kind :name note-cell
184
+ :description "A note column: a pitch name, or off / cut / fade."
185
+ :underlying union
186
+ :union (union-shape :alternatives [note-name note-symbol]))
187
+
188
+ (value-kind :name ev-cell
189
+ :description "A cell's positional children: the channel first, then the note when there is one."
190
+ :underlying union
191
+ :union (union-shape :alternatives [channel-number note-name note-symbol]))
192
+
193
+ (value-kind :name volcol-number
194
+ :description "A volume-column value, 0..64 — set the volume."
195
+ :underlying number
196
+ :numeric (numeric-bounds :min 0 :max 64 :integer true)
197
+ :unit (unit-shape :reject true))
198
+
199
+ (value-kind :name volcol-code
200
+ :description "A volume-column command, spelled with the letter IT's editor shows: \"a4\" fine volume up, \"b4\" fine down, \"c4\" slide up, \"d4\" slide down, \"e4\" pitch slide down, \"f4\" up, \"g4\" tone portamento, \"h4\" vibrato depth, \"p32\" pan. (IT.TXT and the display code are the source; SUMMARY.TXT lists A/C and B/D swapped.)"
201
+ :underlying string
202
+ :string-bounds (string-bounds :min-len 2 :max-len 3))
203
+
204
+ (value-kind :name volcol
205
+ :description "A volume column: a number that sets the volume, or a letter command."
206
+ :underlying union
207
+ :union (union-shape :alternatives [volcol-number volcol-code]))
208
+
209
+ (value-kind :name fx-string
210
+ :description "The effect column: one letter A..Z and two hex digits, as IT shows it — \"D0F\", \"SB1\", \"T80\". One effect column, as in IT; the letter and its sub-command are range-checked at build, with warnings rather than errors for params IT would still play."
211
+ :underlying string
212
+ :string-bounds (string-bounds :min-len 3 :max-len 3))
213
+
214
+ ; =====================================================================
215
+ ; Instrument enums and shapes
216
+ ; =====================================================================
217
+
218
+ (value-kind :name nna-kind
219
+ :description "New Note Action: what happens to the sounding voice when a new note arrives on the channel."
220
+ :underlying symbol
221
+ :members (member-set
222
+ (member :name cut :description "Stop it immediately.")
223
+ (member :name continue :description "Let it run.")
224
+ (member :name off :description "Release it (note off).")
225
+ (member :name fade :description "Fade it out at :fadeout.")))
226
+
227
+ (value-kind :name dct-kind
228
+ :description "Duplicate Check Type: what counts as a duplicate of the new note."
229
+ :underlying symbol
230
+ :members (member-set
231
+ (member :name off :description "Nothing; never duplicate-check.")
232
+ (member :name note :description "The same note.")
233
+ (member :name sample :description "The same sample.")
234
+ (member :name instrument :description "The same instrument.")))
235
+
236
+ (value-kind :name dca-kind
237
+ :description "Duplicate Check Action: what to do with the duplicate the check found."
238
+ :underlying symbol
239
+ :members (member-set
240
+ (member :name cut :description "Stop it immediately.")
241
+ (member :name off :description "Release it (note off).")
242
+ (member :name fade :description "Fade it out.")))
243
+
244
+ (value-kind :name fadeout-value
245
+ :description "Fade-out rate. ITTECH documents 0..128; the disk byte holds 0..255 and a higher value is warned about rather than refused."
246
+ :underlying number
247
+ :numeric (numeric-bounds :min 0 :max 255 :integer true)
248
+ :unit (unit-shape :reject true))
249
+
250
+ (value-kind :name pitch-pan-component
251
+ :description "One of the pitch-pan pair: the separation (-32..32), then the centre note (0..119)."
252
+ :underlying number
253
+ :numeric (numeric-bounds :min -32 :max 119 :integer true)
254
+ :unit (unit-shape :reject true))
255
+
256
+ (value-kind :name pitch-pan-pair
257
+ :description "Pitch-to-pan as [separation centre-note]."
258
+ :underlying vector
259
+ :vector (vector-shape :len 2 :element pitch-pan-component))
260
+
261
+ (value-kind :name swing-component
262
+ :description "One of the random-variation pair: volume swing as a percentage (0..100), then pan swing (0..64)."
263
+ :underlying number
264
+ :numeric (numeric-bounds :min 0 :max 100 :integer true)
265
+ :unit (unit-shape :reject true))
266
+
267
+ (value-kind :name swing-pair
268
+ :description "Random variation as [volume-swing pan-swing]."
269
+ :underlying vector
270
+ :vector (vector-shape :len 2 :element swing-component))
271
+
272
+ ; `nil` is NOT expressible as a union alternative in manifest v1: a
273
+ ; `(union-shape :alternatives …)` takes a `type-list`, whose elements
274
+ ; are `type-ref` symbols, and `nil` lexes as the nil LITERAL rather than
275
+ ; a symbol. So every slot IT spells "a number or nil" — this pair, a
276
+ ; sample's `:pan`, a MIDI `:program` and `:bank` — types its element as
277
+ ; `any` and says the range in prose. Filed to SJON as an ask; the arity
278
+ ; check survives here, which is the half worth keeping.
279
+ (value-kind :name filter-pair
280
+ :description "The instrument's default filter as [cutoff resonance]. Each is 0..127, or nil to leave it alone; the range is checked at build, since a nil alternative is not expressible in a manifest."
281
+ :underlying vector
282
+ :vector (vector-shape :len 2 :element any))
283
+
284
+ (value-kind :name transpose-value
285
+ :description "Semitones a notemap range shifts its sample by."
286
+ :underlying number
287
+ :numeric (numeric-bounds :min -120 :max 120 :integer true)
288
+ :unit (unit-shape :reject true))
289
+
290
+ (value-kind :name midi-out-channel
291
+ :description "The MIDI channel an instrument plays out on, 1..16."
292
+ :underlying number
293
+ :numeric (numeric-bounds :min 1 :max 16 :integer true)
294
+ :unit (unit-shape :reject true))
295
+
296
+ ; =====================================================================
297
+ ; Envelopes
298
+ ; =====================================================================
299
+
300
+ (value-kind :name node-index
301
+ :description "An index into an envelope's node list, 0..24."
302
+ :underlying number
303
+ :numeric (numeric-bounds :min 0 :max 24 :integer true)
304
+ :unit (unit-shape :reject true))
305
+
306
+ (value-kind :name node-index-pair
307
+ :description "A loop or sustain span as [begin end], both node indices."
308
+ :underlying vector
309
+ :vector (vector-shape :len 2 :element node-index))
310
+
311
+ (value-kind :name env-node-field
312
+ :description "One of a node's two positional numbers: the tick (0..9999, strictly increasing across a node list — a relation between children, so it stays a build check) and the value (volume 0..64, pan and pitch -32..32)."
313
+ :underlying number
314
+ :numeric (numeric-bounds :min -32 :max 9999 :integer true)
315
+ :unit (unit-shape :reject true))
316
+
317
+ ; =====================================================================
318
+ ; Samples
319
+ ; =====================================================================
320
+
321
+ (value-kind :name c5-rate
322
+ :description "The sample rate middle C plays back at, in Hz. A 32-bit field."
323
+ :underlying number
324
+ :numeric (numeric-bounds :min 0 :max 4294967295 :integer true)
325
+ :unit (unit-shape :reject true)
326
+ :repr (repr-shape :type u32))
327
+
328
+ (value-kind :name loop-point
329
+ :description "A loop boundary, in frames. A 32-bit field."
330
+ :underlying number
331
+ :numeric (numeric-bounds :min 0 :max 4294967295 :integer true)
332
+ :unit (unit-shape :reject true)
333
+ :repr (repr-shape :type u32))
334
+
335
+ (value-kind :name loop-pair
336
+ :description "A loop as [begin end], in frames."
337
+ :underlying vector
338
+ :vector (vector-shape :len 2 :element loop-point))
339
+
340
+ (value-kind :name loop-kind
341
+ :description "How a loop plays."
342
+ :underlying symbol
343
+ :members (member-set
344
+ (member :name forward :description "Begin to end, then back to begin.")
345
+ (member :name pingpong :description "Begin to end, then end to begin.")))
346
+
347
+ (value-kind :name wave-kind
348
+ :description "An auto-vibrato waveform."
349
+ :underlying symbol
350
+ :members (member-set
351
+ (member :name sine :description "A sine wave — IT's default and the smoothest of the four.")
352
+ (member :name ramp-down :description "A downward sawtooth ramp.")
353
+ (member :name square :description "A square wave: the depth alternates between its two extremes.")
354
+ (member :name random :description "Random per tick. Deterministic on replay only because the module's own generator is.")))
355
+
356
+ (value-kind :name vibrato-field
357
+ :description "One of auto-vibrato's three numbers: speed, depth (0..64 each) and rate (0..255)."
358
+ :underlying number
359
+ :numeric (numeric-bounds :min 0 :max 255 :integer true)
360
+ :unit (unit-shape :reject true))
361
+
362
+ (value-kind :name enc-kind
363
+ :description "How the STORED sample bytes are encoded. A (bin …) ref keeps whatever the anchor holds; the writer re-encodes only when policy says to."
364
+ :underlying symbol
365
+ :members (member-set
366
+ (member :name pcm :description "Signed PCM — the default.")
367
+ (member :name pcm-unsigned :description "Unsigned PCM.")
368
+ (member :name pcm-delta :description "Delta-coded PCM.")
369
+ (member :name it214 :description "IT 2.14 compression.")
370
+ (member :name it215 :description "IT 2.15 compression.")))
371
+
372
+ (value-kind :name sample-bits
373
+ :description "Bits per sample frame: 8 or 16."
374
+ :underlying number
375
+ :numeric (numeric-bounds :min 8 :max 16 :integer true :multiple-of 8)
376
+ :unit (unit-shape :reject true))
377
+
378
+ ; =====================================================================
379
+ ; Binary regions
380
+ ; =====================================================================
381
+
382
+ (value-kind :name bin-offset
383
+ :description "A byte offset into the anchor's file. Written in hex — (bin :at 0x8728 …) reads next to a hex dump."
384
+ :underlying number
385
+ :numeric (numeric-bounds :min 0 :max 4294967295 :integer true)
386
+ :unit (unit-shape :reject true)
387
+ :repr (repr-shape :type u32))
388
+
389
+ (value-kind :name bin-length
390
+ :description "A region's length in bytes, from :at."
391
+ :underlying number
392
+ :numeric (numeric-bounds :min 0 :max 4294967295 :integer true)
393
+ :unit (unit-shape :reject true)
394
+ :repr (repr-shape :type u32))
395
+
396
+ (value-kind :name foreign-tag
397
+ :description "A trailing chunk's four-character tag, e.g. \"STPM\"."
398
+ :underlying string
399
+ :string-bounds (string-bounds :min-len 4 :max-len 4))
400
+
401
+ (value-kind :name macro-field
402
+ :description "A MIDI macro's two positional values: its name, then its 32-character macro string."
403
+ :underlying union
404
+ :union (union-shape :alternatives [macro-name macro-string]))
405
+
406
+ (value-kind :name macro-name
407
+ :description "A MIDI macro's slot name, one of the block's 153 slots in ITTECH's order: the nine globals start, stop, tick, note-on, note-off, volume, pan, bank and program (MIDI start, MIDI stop, MIDI tick, note on, note off, change volume, change pan, bank select, program change), then the sixteen parametric macros sf0..sff, then the 128 fixed macros z80..zff. Hex digits are lower-case as written and either case as read. A name outside the set is it_midi_macro_invalid at build."
408
+ :underlying symbol)
409
+
410
+ (value-kind :name macro-string
411
+ :description "A MIDI macro body: up to 32 printable ASCII characters (0x20..0x7E) in MIDI.TXT's macro language, the slot's bytes up to their NUL. A dump leaves out a slot holding any other byte and names it (it_midi_macro_invalid), and that slot rebuilds empty; a build cuts a longer body to 32 and refuses one with a byte outside the range, each with the same code."
412
+ :underlying string)
413
+
414
+ ; =====================================================================
415
+ ; Positional slots
416
+ ; =====================================================================
417
+
418
+ (value-kind :name module-section
419
+ :description "A module's children: the file's own identity, the header sections, and the instruments, samples and patterns."
420
+ :underlying form
421
+ :heads (head-set
422
+ (head :name source :max 1 :description "The file this module was read from.")
423
+ (head :name timing :max 1 :description "Initial speed, tempo and row highlight.")
424
+ (head :name options :max 1 :description "The header flags and scalars.")
425
+ (head :name channels :max 1 :description "Per-channel pan and volume defaults.")
426
+ (head :name orders :max 1 :description "The order list.")
427
+ (head :name message :max 1 :description "The song message.")
428
+ (head :name midi :max 1 :description "The MIDI macro configuration.")
429
+ (head :name instrument :description "One instrument.")
430
+ (head :name sample :description "One sample.")
431
+ (head :name pattern :description "One pattern.")
432
+ (head :name foreign :description "A preserved trailing chunk.")
433
+ (head :name edit-history :max 1 :description "The preserved edit-history block.")))
434
+
435
+ (value-kind :name channel-section
436
+ :description "The channel defaults a (channels …) lists. Unlisted channels get pan 32 and volume 64."
437
+ :underlying form
438
+ :heads (head-set :names [ch]))
439
+
440
+ (value-kind :name envelope-section
441
+ :description "An envelope's nodes. At most 25, which is the format's own ceiling; the 26th is positional_too_many, reported at the node to delete."
442
+ :underlying form
443
+ :heads (head-set
444
+ (head :name node :max 25 :description "One envelope node: (node tick value).")))
445
+
446
+ (value-kind :name notemap-section
447
+ :description "A notemap's explicit ranges, when the whole-range :sample shorthand is not enough."
448
+ :underlying form
449
+ :heads (head-set :names [range]))
450
+
451
+ (value-kind :name notemap-entry
452
+ :description "One number of the raw keyboard table: a note 0..119, or the sample 1..99 it plays. One element kind types both halves of a pair, so the note-versus-sample reading of a position is the build's."
453
+ :underlying number
454
+ :numeric (numeric-bounds :min 0 :max 119 :integer true)
455
+ :unit (unit-shape :reject true))
456
+
457
+ (value-kind :name notemap-table
458
+ :description "The escape hatch IT's own format is: the 120-pair keyboard table written out flat, [note sample note sample …], exactly 240 numbers. Reach for it when neither the whole-range :sample shorthand nor (range …) children can say what the table holds."
459
+ :underlying vector
460
+ :vector (vector-shape :len 240 :element notemap-entry))
461
+
462
+ (value-kind :name notemap-content
463
+ :description "A notemap's content: either (range …) children, or the raw 240-number table. The two spellings are alternatives and the arms are disjoint by node shape, so a wrong-length table reports its own length mismatch rather than a collapsed union error."
464
+ :underlying union
465
+ :union (union-shape :alternatives [notemap-section notemap-table]))
466
+
467
+ (value-kind :name midi-section
468
+ :description "The MIDI macro slots."
469
+ :underlying form
470
+ :heads (head-set :names [macro]))
471
+
472
+ (value-kind :name bin-section
473
+ :description "One (bin …) reference into the anchor's file."
474
+ :underlying form
475
+ :heads (head-set
476
+ (head :name bin :min 1 :max 1 :description "The region's offset and length, or the file holding it.")))
477
+
478
+ (value-kind :name bin-ref
479
+ :description "A (bin …) reference, as the value of a key."
480
+ :underlying form
481
+ :heads (head-set :names [bin]))
482
+
483
+ ; ---------------------------------------------------------------------
484
+ ; The four slots that carry a LEADING ID and then child forms.
485
+ ;
486
+ ; `:positional` is one policy for every child, which reads at first like
487
+ ; "an id and a child set cannot both be narrowed" — and it is not. A
488
+ ; union whose arms are a number kind and a form kind is DISJOINT BY NODE
489
+ ; SHAPE, so a number can only have meant the id and a form can only have
490
+ ; meant the child set, and each reports its own diagnostic rather than a
491
+ ; collapsed `union_no_branch_matched` (manifest spec §4.9). An id out of
492
+ ; range is `number_above_max` naming the bound; a head outside the set is
493
+ ; `not_head_member` naming the set; a string or a vector, which neither
494
+ ; arm reaches, keeps the collapsed code. `:positional any` gave all three
495
+ ; of those a pass.
496
+ ;
497
+ ; What a union CANNOT carry is the per-head count: `(head … :max 1)`
498
+ ; inside one of these is inert, because counts are enforced at a form's
499
+ ; positional slot and a union alternative is not that slot. So
500
+ ; "(pattern …) has row children XOR one bin child" stays a build check,
501
+ ; as it would have anyway — per-head counts cannot express "many of one
502
+ ; or exactly one of the other" (the it set's amendment 4 says so).
503
+ ; ---------------------------------------------------------------------
504
+
505
+ (value-kind :name instrument-section
506
+ :description "An instrument's children: the note-to-sample map and the three envelopes."
507
+ :underlying form
508
+ :heads (head-set
509
+ (head :name notemap :max 1 :description "The note-to-sample map.")
510
+ (head :name vol-env :max 1 :description "The volume envelope.")
511
+ (head :name pan-env :max 1 :description "The pan envelope.")
512
+ (head :name pitch-env :max 1 :description "The pitch (or filter) envelope.")))
513
+
514
+ (value-kind :name instrument-content
515
+ :description "An instrument's positional slot: its number first, then its children."
516
+ :underlying union
517
+ :union (union-shape :alternatives [instrument-id instrument-section]))
518
+
519
+ (value-kind :name sample-section
520
+ :description "A sample's children: where its body is, or the .wav to ingest in its place."
521
+ :underlying form
522
+ :heads (head-set
523
+ (head :name data :max 1 :description "The stored body, by reference.")
524
+ (head :name wav :max 1 :description "A .wav to ingest at build time instead.")))
525
+
526
+ (value-kind :name sample-content
527
+ :description "A sample's positional slot: its number first, then its body."
528
+ :underlying union
529
+ :union (union-shape :alternatives [sample-id sample-section]))
530
+
531
+ (value-kind :name pattern-section
532
+ :description "A pattern's children: its rows, or the one (bin …) of a skeleton dump. Rows XOR bin is a build check — a count can cap the bin at one but cannot say \"many of one or exactly one of the other\"."
533
+ :underlying form
534
+ :heads (head-set :names [row bin]))
535
+
536
+ (value-kind :name pattern-content
537
+ :description "A pattern's positional slot: its number first, then its rows (or its packed dump)."
538
+ :underlying union
539
+ :union (union-shape :alternatives [pattern-id pattern-section]))
540
+
541
+ (value-kind :name row-index
542
+ :description "Which row of the pattern this is, 0..1023 — one below the row count's ceiling."
543
+ :underlying number
544
+ :numeric (numeric-bounds :min 0 :max 1023 :integer true)
545
+ :unit (unit-shape :reject true))
546
+
547
+ (value-kind :name row-section
548
+ :description "A row's children: its cells, one per channel that carries something."
549
+ :underlying form
550
+ :heads (head-set :names [ev]))
551
+
552
+ (value-kind :name row-content
553
+ :description "A row's positional slot: its index first, then its cells."
554
+ :underlying union
555
+ :union (union-shape :alternatives [row-index row-section]))
556
+
557
+ ; =====================================================================
558
+ ; Forms
559
+ ; =====================================================================
560
+
561
+ (form :name module
562
+ :description "An Impulse Tracker module. Everything below it is optional: omission means the IT default, so the smallest module is a title and an order list."
563
+ :positional module-section
564
+ (key :name title :type string :optional true
565
+ :description "The song name — the header's 26-byte field."))
566
+
567
+ (form :name source
568
+ :description "The file this module was read from, and the identity every (bin …) offset is meaningful against. Inside a timeline document the (anchor …) says the same thing; the two must agree (anchor_conflict)."
569
+ (key :name file :type string
570
+ :description "Path to the .it file.")
571
+ (key :name size :type bin-length :optional true
572
+ :description "The file's length in bytes.")
573
+ (key :name sha256 :type string :optional true
574
+ :description "Hex digest of the file's bytes."))
575
+
576
+ (form :name timing
577
+ :description "The module's starting time: the initial speed and tempo, and the editor's row highlight."
578
+ (key :name speed :type speed-value :optional true
579
+ :description "Ticks per row at the start. Default 6.")
580
+ (key :name tempo :type tempo-value :optional true
581
+ :description "Tempo at the start. Default 125.")
582
+ (key :name highlight :type highlight-pair :optional true
583
+ :description "Row highlight as [minor major] — rows per beat and per measure."))
584
+
585
+ (form :name options
586
+ :description "The header's flags and scalar fields, one key each. Every key has IT's own default, so an absent (options …) is a stereo, instrument-mode, linear-slides module — the modern common case."
587
+ (key :name stereo :type boolean :optional true :default true
588
+ :description "Stereo output.")
589
+ (key :name vol0-optimizations :type boolean :optional true :default false
590
+ :description "Stop channels whose volume has been 0 for some rows.")
591
+ (key :name instruments :type boolean :optional true :default true
592
+ :description "Instrument mode rather than sample mode.")
593
+ (key :name linear-slides :type boolean :optional true :default true
594
+ :description "Linear rather than Amiga frequency slides.")
595
+ (key :name old-effects :type boolean :optional true :default false
596
+ :description "IT 1.x effect behaviour.")
597
+ (key :name compat-gxx :type boolean :optional true :default false
598
+ :description "Link G (tone portamento) memory with E and F.")
599
+ (key :name midi-pitch :type boolean :optional true :default false
600
+ :description "Use MIDI pitch controller.")
601
+ (key :name embedded-midi :type boolean :optional true :default false
602
+ :description "The file carries its own MIDI configuration block.")
603
+ (key :name global-vol :type it-level :optional true :default 128
604
+ :description "Global volume, 0..128.")
605
+ (key :name mix-vol :type it-level :optional true :default 48
606
+ :description "Mixing volume, 0..128.")
607
+ (key :name pan-separation :type it-level :optional true :default 128
608
+ :description "Stereo separation, 0..128.")
609
+ (key :name pitch-wheel-depth :type it-byte :optional true :default 0
610
+ :description "Pitch-wheel depth in semitones.")
611
+ (key :name cwtv :type version-word :optional true
612
+ :description "Created with tracker version (Cwt/v), in hex: 0x0214.")
613
+ (key :name cmwt :type version-word :optional true
614
+ :description "Compatible with tracker version (Cmwt), in hex: 0x0200. Below 0x0200 marks old-format instruments."))
615
+
616
+ (form :name channels
617
+ :description "Per-channel pan and volume defaults. Only the channels that differ from the default need listing."
618
+ :positional channel-section
619
+ (form :name ch
620
+ :description "One channel's defaults. The channel number is positional."
621
+ :positional channel-number
622
+ (key :name pan :type it-pan :optional true :default 32
623
+ :description "Pan position, 0..64.")
624
+ (key :name vol :type it-vol :optional true :default 64
625
+ :description "Channel volume, 0..64.")
626
+ (key :name muted :type boolean :optional true :default false
627
+ :description "Muted — pan bit 7. Effects on the channel still process.")
628
+ (key :name surround :type boolean :optional true :default false
629
+ :description "Surround — pan value 100.")))
630
+
631
+ (form :name orders
632
+ :description "The order list: which pattern plays when, positionally. A trailing `end` is implicit and is not written."
633
+ :positional order-entry)
634
+
635
+ (form :name message
636
+ :description "The song message, positionally — one string, CR-separated as IT stores it."
637
+ :positional string)
638
+
639
+ (form :name midi
640
+ :description "The MIDI macro configuration: one (macro …) per non-empty slot of the 4896-byte embedded block, in slot order. Omitted, the module uses IT's own default macros (the filter pair F0F000z and F0F001z); a dump writes the form whenever the file embeds a block that is not that default, and a build embeds one from it, every unlisted slot empty."
641
+ :positional midi-section
642
+ (form :name macro
643
+ :description "One macro slot: its name, then its body. A slot spelled twice keeps the later body (it_midi_macro_invalid)."
644
+ :positional macro-field))
645
+
646
+ (form :name instrument
647
+ :description "One instrument: the voice rules, the note-to-sample map and the three envelopes. tempura keeps instruments OPAQUE — it writes the name and a :raw body and re-emits the bytes — so a document that spells a field tempura did not materialise is it_field_not_materialized at build until --full exists. The instrument number is positional, and so are the children."
648
+ :positional instrument-content
649
+ (key :name name :type string :optional true
650
+ :description "The instrument's name — the 26-byte field.")
651
+ (key :name raw :type bin-ref :optional true
652
+ :description "tempura's opaque body: the instrument's 554 bytes as a (bin …) into the anchor's file, re-emitted verbatim. Not part of the it set's own manifest.")
653
+ (key :name nna :type nna-kind :optional true :default cut
654
+ :description "New Note Action.")
655
+ (key :name dct :type dct-kind :optional true :default off
656
+ :description "Duplicate Check Type.")
657
+ (key :name dca :type dca-kind :optional true :default cut
658
+ :description "Duplicate Check Action.")
659
+ (key :name fadeout :type fadeout-value :optional true :default 0
660
+ :description "Fade-out rate for an NNA of fade.")
661
+ (key :name global-vol :type it-byte :optional true :default 128
662
+ :description "Instrument global volume.")
663
+ (key :name pan :type it-pan :optional true
664
+ :description "Pan override, 0..64. Absent means \"do not override\".")
665
+ (key :name pitch-pan :type pitch-pan-pair :optional true
666
+ :description "Pitch-to-pan as [separation centre-note].")
667
+ (key :name swing :type swing-pair :optional true
668
+ :description "Random variation as [volume-swing pan-swing].")
669
+ (key :name filter :type filter-pair :optional true
670
+ :description "Default filter as [cutoff resonance], either nil.")
671
+ ; `:type form` rather than a head-set kind: a key that carries inline
672
+ ; slot-local forms must be `.form`-typed, and the local IS the
673
+ ; narrowing — a bare `(midi-out …)` resolves to the body below,
674
+ ; anything else falls through to the global catalog and is unknown.
675
+ (key :name midi :type form :optional true
676
+ :description "Where this instrument plays out over MIDI."
677
+ (form :name midi-out
678
+ :description "An instrument's MIDI output routing."
679
+ (key :name channel :type midi-out-channel :optional true
680
+ :description "Output channel, 1..16.")
681
+ (key :name program :type any :optional true :requires [channel]
682
+ :description "Program to select, or nil for none. Typed `any` because a nil alternative is not expressible in a manifest. Meaningless without a channel.")
683
+ (key :name bank :type any :optional true :requires [channel]
684
+ :description "Bank to select, or nil for none. Typed `any` for the same reason. Meaningless without a channel.")))
685
+
686
+ (form :name notemap
687
+ :description "The note-to-sample map, compiled to IT's 120-pair keyboard table. Three spellings, in the order you should reach for them: the whole-range :sample shorthand, explicit (range …) children, or the raw 240-number table written out flat."
688
+ :positional notemap-content
689
+ (key :name sample :type sample-id :optional true
690
+ :description "One sample for the whole range.")
691
+ (form :name range
692
+ :description "One span of the keyboard mapped to one sample. The two note names are positional: first, last."
693
+ :positional note-name
694
+ (key :name sample :type sample-id :optional true
695
+ :description "The sample this span plays.")
696
+ (key :name transpose :type transpose-value :optional true :requires [sample]
697
+ :description "Semitones to shift it by. Meaningless without a sample.")))
698
+
699
+ (form :name vol-env
700
+ :description "The volume envelope. Node values are 0..64."
701
+ :positional envelope-section
702
+ (key :name off :type boolean :optional true :default false
703
+ :description "The envelope is present but disabled.")
704
+ (key :name loop :type node-index-pair :optional true
705
+ :description "Loop span as [begin end] node indices.")
706
+ (key :name sustain :type node-index-pair :optional true
707
+ :description "Sustain span as [begin end] node indices.")
708
+ (key :name carry :type boolean :optional true :default false
709
+ :description "Carry the envelope position across a new note.")
710
+ (form :name node
711
+ :description "One envelope node: (node tick value)."
712
+ :positional env-node-field))
713
+
714
+ (form :name pan-env
715
+ :description "The pan envelope. Node values are -32..32."
716
+ :positional envelope-section
717
+ (key :name off :type boolean :optional true :default false
718
+ :description "The envelope is present but disabled.")
719
+ (key :name loop :type node-index-pair :optional true
720
+ :description "Loop span as [begin end] node indices.")
721
+ (key :name sustain :type node-index-pair :optional true
722
+ :description "Sustain span as [begin end] node indices.")
723
+ (key :name carry :type boolean :optional true :default false
724
+ :description "Carry the envelope position across a new note.")
725
+ (form :name node
726
+ :description "One envelope node: (node tick value)."
727
+ :positional env-node-field))
728
+
729
+ (form :name pitch-env
730
+ :description "The pitch envelope — or the filter envelope, when :filter is set. Node values are -32..32."
731
+ :positional envelope-section
732
+ (key :name off :type boolean :optional true :default false
733
+ :description "The envelope is present but disabled.")
734
+ (key :name loop :type node-index-pair :optional true
735
+ :description "Loop span as [begin end] node indices.")
736
+ (key :name sustain :type node-index-pair :optional true
737
+ :description "Sustain span as [begin end] node indices.")
738
+ (key :name carry :type boolean :optional true :default false
739
+ :description "Carry the envelope position across a new note.")
740
+ (key :name filter :type boolean :optional true :default false
741
+ :description "Drive the filter cutoff instead of the pitch — the envelope flag byte's bit 7.")
742
+ (form :name node
743
+ :description "One envelope node: (node tick value)."
744
+ :positional env-node-field)))
745
+
746
+ (form :name sample
747
+ :description "One sample: its playback parameters and its body. tempura keeps sample headers and data OPAQUE — a :raw header region and a (data …) whose extent it computed — and never decodes anything. The sample number is positional, and so is the body."
748
+ :positional sample-content
749
+ (key :name name :type string :optional true
750
+ :description "The sample's name — the 26-byte field.")
751
+ (key :name raw :type bin-ref :optional true
752
+ :description "tempura's opaque body: the sample's 80-byte header as a (bin …) into the anchor's file, re-emitted verbatim. Not part of the it set's own manifest.")
753
+ (key :name c5 :type c5-rate :optional true :default 8363
754
+ :description "The rate middle C plays at, in Hz.")
755
+ (key :name vol :type it-vol :optional true :default 64
756
+ :description "Default volume, 0..64.")
757
+ (key :name global-vol :type it-vol :optional true :default 64
758
+ :description "Sample global volume, 0..64.")
759
+ (key :name pan :type any :optional true
760
+ :description "Pan override, 0..64, or nil for pan off (the DfP bit clear). Typed `any` because a nil alternative is not expressible in a manifest; the range is checked at build.")
761
+ (key :name loop :type loop-pair :optional true
762
+ :description "Loop span as [begin end], in frames.")
763
+ (key :name loop-mode :type loop-kind :optional true :requires [loop]
764
+ :description "How the loop plays. A loop mode with no loop means nothing, hence :requires.")
765
+ (key :name sustain-loop :type loop-pair :optional true
766
+ :description "Sustain loop span as [begin end], in frames.")
767
+ (key :name sustain-mode :type loop-kind :optional true :requires [sustain-loop]
768
+ :description "How the sustain loop plays.")
769
+ (key :name vibrato :type form :optional true
770
+ :description "Auto-vibrato."
771
+ (form :name vibrato
772
+ :description "The sample's auto-vibrato."
773
+ (key :name speed :type vibrato-field :optional true :default 0
774
+ :description "Vibrato speed.")
775
+ (key :name depth :type vibrato-field :optional true :default 0
776
+ :description "Vibrato depth.")
777
+ (key :name rate :type vibrato-field :optional true :default 0
778
+ :description "How fast the depth ramps in.")
779
+ (key :name wave :type wave-kind :optional true :default sine
780
+ :description "Vibrato waveform.")))
781
+
782
+ (form :name data
783
+ :description "The sample's body: how the stored bytes are encoded, and where they are."
784
+ :positional bin-section
785
+ (key :name bits :type sample-bits :optional true :default 8
786
+ :description "Bits per frame: 8 or 16.")
787
+ (key :name enc :type enc-kind :optional true :default pcm
788
+ :description "How the stored bytes are encoded.")
789
+ (key :name stereo :type boolean :optional true :default false
790
+ :description "Split-stereo layout: the left block then the right. Read, and written only with --stereo-samples."))
791
+
792
+ (form :name wav
793
+ :description "A .wav file to ingest at build time in place of a (data …): its PCM and its sampler-chunk loop points."
794
+ (key :name file :type string
795
+ :description "Path to the .wav file.")))
796
+
797
+ (form :name pattern
798
+ :description "One pattern, row-major and sparse: only rows with content appear, and only cells with content per row. The pattern number is positional, and so are the rows. A (bin …) child instead of rows is the skeleton dump — packed data by reference, which --patterns=bin produces; rows XOR bin is a build check, since a per-head count cannot say \"many of one or exactly one of the other\"."
799
+ :positional pattern-content
800
+ (key :name rows :type rows-count :optional true :default 64
801
+ :description "How many rows the pattern has.")
802
+ (form :name row
803
+ :description "One row: its index, positionally, then its cells."
804
+ :positional row-content
805
+ (form :name ev
806
+ :description "One cell: the channel, then the note when there is one, then the columns that carry something."
807
+ :positional ev-cell
808
+ (key :name ins :type ins-ref :optional true
809
+ :description "The instrument: its number, or a symbol naming one.")
810
+ (key :name vol :type volcol :optional true
811
+ :description "The volume column: a number 0..64, or a letter command.")
812
+ (key :name fx :type fx-string :optional true
813
+ :description "The effect column: a letter and two hex digits."))))
814
+
815
+ (form :name foreign
816
+ :description "A trailing chunk tempura did not write and does not understand, preserved byte for byte under --preserve-foreign. tempura's own TMPU chunk is never shown as foreign."
817
+ :positional bin-section
818
+ (key :name tag :type foreign-tag
819
+ :description "The chunk's four-character tag."))
820
+
821
+ (form :name edit-history
822
+ :description "The preserved edit-history block, kept under --preserve-history."
823
+ :positional bin-section)
824
+
825
+ (form :name bin
826
+ :description "A region of the anchor's file, by reference. Global rather than slot-local because it appears under (data …), under (pattern …), under :raw and under the preserved chunks, and one declaration in one place is the point. Bounds are checked against the anchor's :size before the offset is honoured."
827
+ (key :name at :type bin-offset :optional true
828
+ :description "Byte offset into the anchor's file, written in hex. Exclusive with :file.")
829
+ (key :name len :type bin-length :optional true :requires [at]
830
+ :description "The region's length from :at. Meaningless without an offset.")
831
+ (key :name file :type string :optional true
832
+ :description "A separate file holding the region instead. Exclusive with :at.")
833
+ (exclusive-group :cardinality exactly-one
834
+ (alt :keys [at])
835
+ (alt :keys [file])))
836
+ )