@r_masseater/fumx 0.0.0 → 0.1.2
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.
- package/LICENSE +87 -0
- package/README.md +123 -1
- package/dist/analysis-BAPm6c9P.d.mts +75 -0
- package/dist/analysis-CRyaJD5D.mjs +294 -0
- package/dist/analysis-CRyaJD5D.mjs.map +1 -0
- package/dist/analysis.d.mts +3 -0
- package/dist/analysis.mjs +3 -0
- package/dist/cli-Ci7maCdL.mjs +2506 -0
- package/dist/cli-Ci7maCdL.mjs.map +1 -0
- package/dist/convert-als.d.mts +17 -0
- package/dist/convert-als.mjs +512 -0
- package/dist/convert-als.mjs.map +1 -0
- package/dist/convert-midi.d.mts +17 -0
- package/dist/convert-midi.mjs +273 -0
- package/dist/convert-midi.mjs.map +1 -0
- package/dist/fumx.mjs +9 -0
- package/dist/fumx.mjs.map +1 -0
- package/dist/grammar-Ds8M-PkG.mjs +9836 -0
- package/dist/grammar-Ds8M-PkG.mjs.map +1 -0
- package/dist/habits.d.mts +71 -0
- package/dist/habits.mjs +98 -0
- package/dist/habits.mjs.map +1 -0
- package/dist/index-Bc9UT9HF.d.mts +795 -0
- package/dist/index-C7av_aK1.d.mts +104 -0
- package/dist/index-DOfjU43D.d.mts +71 -0
- package/dist/index-KxUilka8.d.mts +6 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +4 -0
- package/dist/lint-Bnl4l0aI.mjs +296 -0
- package/dist/lint-Bnl4l0aI.mjs.map +1 -0
- package/dist/lint-CJ5lq-Fr.d.mts +37 -0
- package/dist/lint.d.mts +3 -0
- package/dist/lint.mjs +1 -0
- package/dist/mapper.mjs +14 -0
- package/dist/mapper.mjs.map +1 -0
- package/dist/mix-facts-QCYCXdIA.mjs +7006 -0
- package/dist/mix-facts-QCYCXdIA.mjs.map +1 -0
- package/dist/presets.d.mts +35 -0
- package/dist/presets.mjs +814 -0
- package/dist/presets.mjs.map +1 -0
- package/dist/read-song-B9342KUK.mjs +13017 -0
- package/dist/read-song-B9342KUK.mjs.map +1 -0
- package/dist/read-song-CsW4kd7v.d.mts +1326 -0
- package/dist/read-song-DW8MLsln.mjs +2783 -0
- package/dist/read-song-DW8MLsln.mjs.map +1 -0
- package/dist/song-BlIPWk7b.mjs +387 -0
- package/dist/song-BlIPWk7b.mjs.map +1 -0
- package/dist/song-UZ4T_dj9.d.mts +1477 -0
- package/dist/sounding-BCyExbPp.d.mts +20 -0
- package/dist/sounding-DYDZFp4e.mjs +41 -0
- package/dist/sounding-DYDZFp4e.mjs.map +1 -0
- package/dist/style-rules-CjaZTDt_.d.mts +131 -0
- package/dist/ticks-D6yACwHt.mjs +26 -0
- package/dist/ticks-D6yACwHt.mjs.map +1 -0
- package/dist/transform-DGUihHCR.mjs +108 -0
- package/dist/transform-DGUihHCR.mjs.map +1 -0
- package/dist/vite.d.mts +8 -0
- package/dist/vite.mjs +127 -0
- package/dist/vite.mjs.map +1 -0
- package/dist/write-CHtCd-bG.mjs +747 -0
- package/dist/write-CHtCd-bG.mjs.map +1 -0
- package/package.json +111 -5
- package/skills/lint-songs/SKILL.md +54 -0
- package/skills/read-fumx/SKILL.md +89 -0
- package/skills/use-fumx-tools/SKILL.md +69 -0
- package/skills/use-lint-presets/SKILL.md +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-CHtCd-bG.mjs","names":["NONE","NEXT","Arr","Rec","Arr","Rec","Str","NONE","NEXT","Arr","Rec","Arr","NONE","FULL","Arr","Str","NONE","NEXT","Arr","NEXT","headOf","cellsOf","Arr","Rec","Arr","SINGLE","Arr","Arr"],"sources":["../src/entities/timeline/model/general-midi.ts","../src/entities/timeline/model/groups.ts","../src/entities/timeline/model/names.ts","../src/entities/timeline/model/plan.ts","../src/entities/timeline/model/tempo-units.ts","../src/entities/timeline/model/events.ts","../src/entities/timeline/model/cells.ts","../src/entities/timeline/model/layout.ts","../src/entities/timeline/model/control-lines.ts","../src/entities/timeline/model/mix-lines.ts","../src/entities/timeline/model/voice-lines.ts","../src/entities/timeline/model/write.ts"],"sourcesContent":["export const PROGRAMS = [\n \"acoustic-grand-piano\",\n \"bright-acoustic-piano\",\n \"electric-grand-piano\",\n \"honky-tonk-piano\",\n \"electric-piano-1\",\n \"electric-piano-2\",\n \"harpsichord\",\n \"clavinet\",\n \"celesta\",\n \"glockenspiel\",\n \"music-box\",\n \"vibraphone\",\n \"marimba\",\n \"xylophone\",\n \"tubular-bells\",\n \"dulcimer\",\n \"drawbar-organ\",\n \"percussive-organ\",\n \"rock-organ\",\n \"church-organ\",\n \"reed-organ\",\n \"accordion\",\n \"harmonica\",\n \"tango-accordion\",\n \"acoustic-guitar-nylon\",\n \"acoustic-guitar-steel\",\n \"electric-guitar-jazz\",\n \"electric-guitar-clean\",\n \"electric-guitar-muted\",\n \"overdriven-guitar\",\n \"distortion-guitar\",\n \"guitar-harmonics\",\n \"acoustic-bass\",\n \"electric-bass-finger\",\n \"electric-bass-pick\",\n \"fretless-bass\",\n \"slap-bass-1\",\n \"slap-bass-2\",\n \"synth-bass-1\",\n \"synth-bass-2\",\n \"violin\",\n \"viola\",\n \"cello\",\n \"contrabass\",\n \"tremolo-strings\",\n \"pizzicato-strings\",\n \"orchestral-harp\",\n \"timpani\",\n \"string-ensemble-1\",\n \"string-ensemble-2\",\n \"synth-strings-1\",\n \"synth-strings-2\",\n \"choir-aahs\",\n \"voice-oohs\",\n \"synth-voice\",\n \"orchestra-hit\",\n \"trumpet\",\n \"trombone\",\n \"tuba\",\n \"muted-trumpet\",\n \"french-horn\",\n \"brass-section\",\n \"synth-brass-1\",\n \"synth-brass-2\",\n \"soprano-sax\",\n \"alto-sax\",\n \"tenor-sax\",\n \"baritone-sax\",\n \"oboe\",\n \"english-horn\",\n \"bassoon\",\n \"clarinet\",\n \"piccolo\",\n \"flute\",\n \"recorder\",\n \"pan-flute\",\n \"blown-bottle\",\n \"shakuhachi\",\n \"whistle\",\n \"ocarina\",\n \"lead-1-square\",\n \"lead-2-sawtooth\",\n \"lead-3-calliope\",\n \"lead-4-chiff\",\n \"lead-5-charang\",\n \"lead-6-voice\",\n \"lead-7-fifths\",\n \"lead-8-bass-and-lead\",\n \"pad-1-new-age\",\n \"pad-2-warm\",\n \"pad-3-polysynth\",\n \"pad-4-choir\",\n \"pad-5-bowed\",\n \"pad-6-metallic\",\n \"pad-7-halo\",\n \"pad-8-sweep\",\n \"fx-1-rain\",\n \"fx-2-soundtrack\",\n \"fx-3-crystal\",\n \"fx-4-atmosphere\",\n \"fx-5-brightness\",\n \"fx-6-goblins\",\n \"fx-7-echoes\",\n \"fx-8-sci-fi\",\n \"sitar\",\n \"banjo\",\n \"shamisen\",\n \"koto\",\n \"kalimba\",\n \"bagpipe\",\n \"fiddle\",\n \"shanai\",\n \"tinkle-bell\",\n \"agogo\",\n \"steel-drums\",\n \"woodblock\",\n \"taiko-drum\",\n \"melodic-tom\",\n \"synth-drum\",\n \"reverse-cymbal\",\n \"guitar-fret-noise\",\n \"breath-noise\",\n \"seashore\",\n \"bird-tweet\",\n \"telephone-ring\",\n \"helicopter\",\n \"applause\",\n \"gunshot\",\n] as const;\n\nexport const FIRST_DRUM = 35;\n\nexport const DRUMS = [\n \"acoustic-bass-drum\",\n \"bass-drum-1\",\n \"side-stick\",\n \"acoustic-snare\",\n \"hand-clap\",\n \"electric-snare\",\n \"low-floor-tom\",\n \"closed-hi-hat\",\n \"high-floor-tom\",\n \"pedal-hi-hat\",\n \"low-tom\",\n \"open-hi-hat\",\n \"low-mid-tom\",\n \"hi-mid-tom\",\n \"crash-cymbal-1\",\n \"high-tom\",\n \"ride-cymbal-1\",\n \"chinese-cymbal\",\n \"ride-bell\",\n \"tambourine\",\n \"splash-cymbal\",\n \"cowbell\",\n \"crash-cymbal-2\",\n \"vibraslap\",\n \"ride-cymbal-2\",\n \"hi-bongo\",\n \"low-bongo\",\n \"mute-hi-conga\",\n \"open-hi-conga\",\n \"low-conga\",\n \"high-timbale\",\n \"low-timbale\",\n \"high-agogo\",\n \"low-agogo\",\n \"cabasa\",\n \"maracas\",\n \"short-whistle\",\n \"long-whistle\",\n \"short-guiro\",\n \"long-guiro\",\n \"claves\",\n \"hi-wood-block\",\n \"low-wood-block\",\n \"mute-cuica\",\n \"open-cuica\",\n \"mute-triangle\",\n \"open-triangle\",\n] as const;\n\nexport const DRUM_CHANNEL = 9;\n","import { Array as Arr, Option, Order, Record as Rec, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type { Part, TimelineNote } from \"./events.ts\";\nimport { DRUM_CHANNEL } from \"./general-midi.ts\";\n\nconst NONE = 0;\nconst NEXT = 1;\n\nexport const isDrumPart: From<Part, boolean> = (part) => part.channel === DRUM_CHANNEL;\n\nexport interface Group {\n readonly start: number;\n readonly end: number;\n readonly midis: readonly number[];\n readonly velocity: number;\n readonly release: number;\n readonly lyric: Option.Option<string>;\n}\n\nexport type Line = readonly Group[];\n\nconst chordKeyOf: From<TimelineNote, string> = (note) =>\n `${String(note.tick)}:${String(note.end)}:${String(note.velocity)}:${String(note.release)}`;\n\nconst groupOf: From<readonly TimelineNote[], Option.Option<Group>> = (notes) =>\n pipe(\n Arr.head(notes),\n Option.map((first) => ({\n start: first.tick,\n end: first.end,\n midis: pipe(\n notes,\n Arr.map((note) => note.midi),\n ),\n velocity: first.velocity,\n release: first.release,\n lyric: Option.none(),\n })),\n );\n\nconst stackedOf: From<readonly TimelineNote[], readonly (readonly TimelineNote[])[]> = (chord) =>\n pipe(\n chord,\n Arr.map((note, index) => ({\n note,\n layer: pipe(\n Arr.take(chord, index),\n Arr.countBy((earlier) => earlier.midi === note.midi),\n ),\n })),\n Arr.groupBy(({ layer }) => String(layer)),\n Rec.values,\n Arr.map((layer) =>\n pipe(\n layer,\n Arr.map(({ note }) => note),\n ),\n ),\n );\n\nconst chordsOf: From<Part, readonly (readonly TimelineNote[])[]> = (part) => {\n if (isDrumPart(part)) {\n return pipe(\n part.notes,\n Arr.map((note) => [note]),\n );\n }\n return pipe(part.notes, Arr.groupBy(chordKeyOf), Rec.values, Arr.flatMap(stackedOf));\n};\n\nconst byStartThenLonger = Order.combine(\n Order.mapInput(Order.Number, (group: Group) => group.start),\n Order.mapInput(Order.flip(Order.Number), (group: Group) => group.end),\n);\n\nconst withLyrics =\n (part: Part): From<readonly Group[], readonly Group[]> =>\n (groups) =>\n pipe(\n groups,\n Arr.map((group, index) => {\n const leads = pipe(\n Arr.get(groups, index - NEXT),\n Option.match({\n onNone: () => true,\n onSome: (previous) => previous.start !== group.start,\n }),\n );\n const lyric = pipe(\n Arr.findFirst(part.lyrics, (candidate) => candidate.tick === group.start),\n Option.filter(() => leads),\n Option.map((found) => found.text),\n );\n return { ...group, lyric };\n }),\n );\n\nexport const groupsOf: From<Part, readonly Group[]> = (part) => {\n const groups = pipe(chordsOf(part), Arr.map(groupOf), Arr.getSomes);\n return withLyrics(part)(Arr.sort(groups, byStartThenLonger));\n};\n\nconst endOfLine: From<Line, number> = (line) =>\n Option.match(Arr.last(line), { onNone: () => NONE, onSome: (group) => group.end });\n\nconst placeGroup = (lines: readonly Line[], group: Group): readonly Line[] =>\n Option.match(\n Arr.findFirstIndex(lines, (line) => endOfLine(line) <= group.start),\n {\n onNone: () => [...lines, [group]],\n onSome: (index) =>\n pipe(\n lines,\n Arr.map((line, position): Line => {\n if (position === index) {\n return [...line, group];\n }\n return line;\n }),\n ),\n },\n );\n\nexport const linesOf: From<readonly Group[], readonly Line[]> = (groups) =>\n Arr.reduce(groups, [] as readonly Line[], placeGroup);\n","import { Array as Arr, Option, Record as Rec, String as Str, pipe } from \"effect\";\nimport { AstUtils, GrammarAST } from \"langium\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\nimport { FumxTerminals } from \"#generated/langium/ast.ts\";\nimport { FumxGrammar } from \"#generated/langium/grammar.ts\";\n\nconst FIRST_SUFFIX = 2;\n\nconst keywordsIn: From<GrammarAST.Grammar | GrammarAST.AbstractRule, ReadonlySet<string>> = (\n node,\n) =>\n new Set(\n AstUtils.streamAst(node)\n .filter((child): child is GrammarAST.Keyword => GrammarAST.isKeyword(child))\n .map((keyword) => keyword.value),\n );\n\nconst grammar = FumxGrammar();\n\nconst allowedKeywords = pipe(\n grammar.rules,\n Arr.findFirst((rule) => rule.name === \"Name\"),\n Option.match({ onNone: () => new Set<string>(), onSome: keywordsIn }),\n);\n\nconst allKeywords = Arr.fromIterable(keywordsIn(grammar));\n\nconst reserved = new Set(\n pipe(\n allKeywords,\n Arr.filter((keyword) => !allowedKeywords.has(keyword)),\n ),\n);\n\nconst otherTerminals = pipe(\n Rec.toEntries(FumxTerminals),\n Arr.filter(([name]) => name !== \"ID\"),\n Arr.map(([, pattern]) => new RegExp(`^(?:${pattern.source})$`, \"u\")),\n);\n\nconst identifier = new RegExp(`^(?:${FumxTerminals.ID.source})$`, \"u\");\n\nconst isUsable: From<string, boolean> = (name) =>\n identifier.test(name) &&\n !reserved.has(name) &&\n !pipe(\n otherTerminals,\n Arr.some((pattern) => pattern.test(name)),\n );\n\nconst slugOf: From<string, string> = (text) =>\n pipe(\n text,\n Str.normalize(\"NFKD\"),\n Str.toLowerCase,\n Str.replaceAll(/[^a-z0-9]+/gu, \"-\"),\n Str.replaceAll(/^[-0-9]+|-+$/gu, \"\"),\n );\n\nexport const nameFrom: From<readonly string[], string> = (candidates) =>\n pipe(\n candidates,\n Arr.map(slugOf),\n Arr.findFirst(isUsable),\n Option.getOrElse(() => \"part\"),\n );\n\nexport const uniqueAmong: From<ReadonlySet<string>, From<string, string>> = (taken) => (name) =>\n pipe(\n Arr.range(FIRST_SUFFIX, taken.size + FIRST_SUFFIX),\n Arr.map((suffix) => `${name}-${String(suffix)}`),\n Arr.prepend(name),\n Arr.findFirst((candidate) => isUsable(candidate) && !taken.has(candidate)),\n Option.getOrElse(() => `${name}-${String(taken.size)}`),\n );\n","import { Array as Arr, Option, Order, Record as Rec, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type { Level, Part, Timeline, TimelineControl, TrackMix } from \"./events.ts\";\nimport { DRUMS, FIRST_DRUM, PROGRAMS } from \"./general-midi.ts\";\nimport { groupsOf, isDrumPart, linesOf } from \"./groups.ts\";\nimport type { Line } from \"./groups.ts\";\nimport { nameFrom, uniqueAmong } from \"./names.ts\";\n\nconst NONE = 0;\nconst NEXT = 1;\nconst SHARED = 1;\nconst DEFAULT_PROGRAM = 0;\n\nexport type Source =\n | { readonly kind: \"instrument\"; readonly instrument: string; readonly program: number }\n | { readonly kind: \"kit\" };\n\nexport interface PlannedPart {\n readonly part: Part;\n readonly name: string;\n readonly source: Source;\n readonly lines: readonly Line[];\n readonly controls: readonly TimelineControl[];\n readonly mix: TrackMix;\n}\n\nexport interface PlannedBus {\n readonly name: string;\n readonly level: Level;\n}\n\nexport interface Plan {\n readonly parts: readonly PlannedPart[];\n readonly buses: readonly PlannedBus[];\n readonly instruments: ReadonlyMap<number, string>;\n readonly drumVoices: ReadonlyMap<number, string>;\n}\n\nconst drumNameOf: From<number, string> = (midi) =>\n Option.getOrElse(Arr.get(DRUMS, midi - FIRST_DRUM), () => `note-${String(midi)}`);\n\nconst programNameOf: From<number, string> = (program) =>\n Option.getOrElse(Arr.get(PROGRAMS, program), () => `program-${String(program)}`);\n\nexport const controllerKeyOf: From<Pick<TimelineControl, \"controller\">, string> = ({\n controller,\n}) => {\n if (controller.kind === \"cc\") {\n return `cc ${String(controller.number)}`;\n }\n if (controller.kind === \"pressure\") {\n return Option.match(controller.midi, {\n onNone: () => \"pressure\",\n onSome: (midi) => `pressure ${String(midi)}`,\n });\n }\n return controller.kind;\n};\n\nconst isLastAtTick: From<readonly TimelineControl[], From<number, boolean>> =\n (controls) => (index) =>\n pipe(\n Option.all([Arr.get(controls, index), Arr.get(controls, index + NEXT)]),\n Option.match({\n onNone: () => true,\n onSome: ([control, next]) =>\n next.tick !== control.tick || controllerKeyOf(next) !== controllerKeyOf(control),\n }),\n );\n\nconst byControllerThenTick = Order.combine(\n Order.mapInput(Order.String, controllerKeyOf),\n Order.mapInput(Order.Number, (control: TimelineControl) => control.tick),\n);\n\nconst controlsOf: From<Part, readonly TimelineControl[]> = (part) => {\n const drumProgram = pipe(\n part.program,\n Option.filter(() => isDrumPart(part)),\n Option.map((value): TimelineControl => ({\n tick: NONE,\n controller: { kind: \"program\" },\n value,\n })),\n Option.toArray,\n );\n const sorted = Arr.sort([...drumProgram, ...part.controls], byControllerThenTick);\n return pipe(\n sorted,\n Arr.filter((_control, index) => isLastAtTick(sorted)(index)),\n );\n};\n\nconst programOf: From<Part, number> = (part) =>\n Option.getOrElse(part.program, () => DEFAULT_PROGRAM);\n\nconst labelOf: From<Part, string> = (part) => Option.getOrElse(part.name, () => \"\");\n\nconst instrumentsOf: From<readonly Part[], ReadonlyMap<number, string>> = (parts) =>\n new Map(\n pipe(\n parts,\n Arr.filter((part) => !isDrumPart(part)),\n Arr.map(programOf),\n Arr.dedupe,\n Arr.map((program) => [program, nameFrom([programNameOf(program)])] as const),\n ),\n );\n\nconst drumVoicesOf: From<readonly Part[], ReadonlyMap<number, string>> = (parts) => {\n const midis = pipe(\n parts,\n Arr.filter(isDrumPart),\n Arr.flatMap((part) => part.notes),\n Arr.map((note) => note.midi),\n Arr.dedupe,\n );\n return new Map(\n pipe(\n Arr.sort(midis, Order.Number),\n Arr.map((midi) => [midi, drumNameOf(midi)] as const),\n ),\n );\n};\n\nconst channelledOf: From<ReadonlySet<string>, From<Part, string>> = (shared) => (part) => {\n const label = labelOf(part);\n if (shared.has(label)) {\n return `${label} ch${String(part.channel + NEXT)}`;\n }\n return label;\n};\n\nconst fallbackOf: From<Part, string> = (part) => {\n if (isDrumPart(part)) {\n return \"drums\";\n }\n return programNameOf(programOf(part));\n};\n\nconst candidatesOf: From<ReadonlySet<string>, From<Part, readonly string[]>> =\n (shared) => (part) => [\n channelledOf(shared)(part),\n fallbackOf(part),\n `track ${String(part.track)}`,\n ];\n\nconst sharedLabelsOf: From<readonly Part[], ReadonlySet<string>> = (parts) =>\n new Set(\n pipe(\n parts,\n Arr.groupBy(labelOf),\n Rec.filter((same) => same.length > SHARED),\n Rec.keys,\n ),\n );\n\nconst sourceOf: From<ReadonlyMap<number, string>, From<Part, Source>> = (instruments) => (part) => {\n if (isDrumPart(part)) {\n return { kind: \"kit\" };\n }\n const program = programOf(part);\n return { kind: \"instrument\", instrument: instruments.get(program) ?? \"\", program };\n};\n\nconst namesOf: From<readonly PlannedPart[], ReadonlySet<string>> = (planned) =>\n new Set(\n pipe(\n planned,\n Arr.map((done) => done.name),\n ),\n );\n\ninterface Naming {\n readonly instruments: Plan[\"instruments\"];\n readonly candidates: From<Part, readonly string[]>;\n readonly mixes: Timeline[\"mix\"][\"tracks\"];\n}\n\nconst UNMIXED: TrackMix = {\n level: { decibels: NONE, pan: NONE, muted: false },\n sends: [],\n envelopes: [],\n};\n\ntype Reducer<State, Item> = (state: State, item: Item) => State;\n\nconst NO_PARTS: readonly PlannedPart[] = [];\n\nconst nextPart: From<Naming, Reducer<readonly PlannedPart[], Part>> =\n (naming) => (planned, part) => {\n const name = uniqueAmong(namesOf(planned))(nameFrom(naming.candidates(part)));\n return Arr.append(planned, {\n part,\n name,\n source: sourceOf(naming.instruments)(part),\n lines: linesOf(groupsOf(part)),\n controls: controlsOf(part),\n mix: naming.mixes.get(part.track) ?? UNMIXED,\n });\n };\n\ntype BusNaming = Readonly<{ taken: ReadonlySet<string>; buses: Timeline[\"mix\"][\"buses\"] }>;\n\nconst busesOf: From<BusNaming, readonly PlannedBus[]> = ({ taken, buses }) => {\n const used = new Set(taken);\n const named: PlannedBus[] = [];\n for (const [index, bus] of buses.entries()) {\n const name = uniqueAmong(used)(\n nameFrom([...Option.toArray(bus.name), `bus ${String(index + NEXT)}`]),\n );\n used.add(name);\n named.push({ name, level: bus.level });\n }\n return named;\n};\n\nexport const planOf: From<Timeline, Plan> = (timeline) => {\n const instruments = instrumentsOf(timeline.parts);\n const candidates = candidatesOf(sharedLabelsOf(timeline.parts));\n const parts = Arr.reduce(\n timeline.parts,\n NO_PARTS,\n nextPart({ instruments, candidates, mixes: timeline.mix.tracks }),\n );\n return {\n parts,\n buses: busesOf({ taken: namesOf(parts), buses: timeline.mix.buses }),\n instruments,\n drumVoices: drumVoicesOf(timeline.parts),\n };\n};\n","import type { From } from \"#/shared/lib/from.ts\";\n\nconst MICROSECONDS_PER_MINUTE = 60_000_000;\n\nexport const bpmOf: From<number, number> = (microseconds) => MICROSECONDS_PER_MINUTE / microseconds;\n\nexport const microsecondsOf: From<number, number> = (bpm) =>\n Math.round(MICROSECONDS_PER_MINUTE / bpm);\n","import { Array as Arr, Order } from \"effect\";\nimport type { Option } from \"effect\";\n\nimport type { Controller, MixerParameter } from \"#/entities/song/@x/timeline.ts\";\n\nexport interface Timed {\n readonly tick: number;\n}\n\nexport interface TimelineNote extends Timed {\n readonly end: number;\n readonly midi: number;\n readonly velocity: number;\n readonly release: number;\n}\n\nexport interface TimelineControl extends Timed {\n readonly controller: Controller;\n readonly value: number;\n}\n\nexport interface Text extends Timed {\n readonly text: string;\n}\n\nexport interface Part {\n readonly track: number;\n readonly channel: number;\n readonly name: Option.Option<string>;\n readonly program: Option.Option<number>;\n readonly notes: readonly TimelineNote[];\n readonly controls: readonly TimelineControl[];\n readonly lyrics: readonly Text[];\n}\n\nexport interface Meter extends Timed {\n readonly numerator: number;\n readonly denominator: number;\n}\n\nexport interface TempoChange extends Timed {\n readonly microseconds: number;\n readonly target: Option.Option<number>;\n}\n\nexport interface Level {\n readonly decibels: number;\n readonly pan: number;\n readonly muted: boolean;\n}\n\nexport interface TrackSend {\n readonly bus: number;\n readonly amount: number;\n}\n\nexport type MixParameter = MixerParameter;\n\nexport interface MixPoint extends Timed {\n readonly value: number;\n}\n\nexport interface Envelope {\n readonly parameter: MixParameter;\n readonly points: readonly MixPoint[];\n}\n\nexport interface TrackMix {\n readonly level: Level;\n readonly sends: readonly TrackSend[];\n readonly envelopes: readonly Envelope[];\n}\n\nexport interface BusMix {\n readonly name: Option.Option<string>;\n readonly level: Level;\n}\n\nexport interface Mix {\n readonly tracks: ReadonlyMap<number, TrackMix>;\n readonly buses: readonly BusMix[];\n}\n\nexport const NO_MIX: Mix = { tracks: new Map(), buses: [] };\n\nexport interface Timeline {\n readonly title: Option.Option<string>;\n readonly end: number;\n readonly offGrid: number;\n readonly tempos: readonly TempoChange[];\n readonly meters: readonly Meter[];\n readonly markers: readonly Text[];\n readonly parts: readonly Part[];\n readonly mix: Mix;\n}\n\nconst byTick = Order.mapInput(Order.Number, (timed: Timed) => timed.tick);\n\nexport const sortedByTick = <Item extends Timed>(items: readonly Item[]): readonly Item[] =>\n Arr.sort(items, byTick);\n\nconst byTickThenPitch = Order.combine(\n Order.mapInput(Order.Number, (note: TimelineNote) => note.tick),\n Order.mapInput(Order.Number, (note: TimelineNote) => note.midi),\n);\n\nexport const sortedNotes = (notes: readonly TimelineNote[]): readonly TimelineNote[] =>\n Arr.sort(notes, byTickThenPitch);\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\nimport { Midi } from \"tonal\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\nimport { fractionOf } from \"#/shared/lib/ticks.ts\";\n\nconst NONE = 0;\nconst FULL = 127;\nconst SHARE_DECIMALS = 3;\nconst SEMITONE_DECIMALS = 12;\nconst LAST = 1;\n\nexport interface Cell {\n readonly head: string;\n readonly attributes: readonly string[];\n readonly length: number;\n}\n\nexport const durationText: From<number, string> = (length) => {\n if (length === NONE) {\n return \"0/1\";\n }\n return fractionOf(length);\n};\n\nexport const restCell: From<number, Cell> = (length) => ({ head: \"rest\", attributes: [], length });\n\nexport const restsOf: From<number, readonly Cell[]> = (length) => {\n if (length > NONE) {\n return [restCell(length)];\n }\n return [];\n};\n\nconst isRest: From<Cell, boolean> = (cell) => cell.head === \"rest\";\n\nconst mergeRests = (merged: readonly Cell[], cell: Cell): readonly Cell[] =>\n pipe(\n Arr.last(merged),\n Option.filter((previous) => isRest(previous) && isRest(cell)),\n Option.match({\n onNone: () => [...merged, cell],\n onSome: (previous) => [\n ...Arr.dropRight(merged, LAST),\n restCell(previous.length + cell.length),\n ],\n }),\n );\n\nconst NO_CELLS: readonly Cell[] = [];\n\nconst cellText: From<Cell, string> = (cell) =>\n Arr.join([cell.head, durationText(cell.length), ...cell.attributes], \" \");\n\nexport const cellsText: From<readonly Cell[], string> = (cells) =>\n pipe(Arr.reduce(cells, NO_CELLS, mergeRests), Arr.map(cellText), Arr.join(\", \"));\n\nexport const quoted: From<string, string> = (text) =>\n `\"${pipe(\n text,\n Str.replaceAll(\"\\\\\", String.raw`\\\\`),\n Str.replaceAll('\"', String.raw`\\\"`),\n Str.replaceAll(\"\\n\", String.raw`\\n`),\n Str.replaceAll(\"\\r\", String.raw`\\r`),\n Str.replaceAll(\"\\t\", String.raw`\\t`),\n )}\"`;\n\nexport const shareText: From<number, string> = (value) =>\n String(Number((value / FULL).toFixed(SHARE_DECIMALS)));\n\nexport const semitoneText: From<number, string> = (value) => {\n const text = String(Number(value.toFixed(SEMITONE_DECIMALS)));\n if (value > NONE) {\n return `+${text}st`;\n }\n return `${text}st`;\n};\n\nexport const pitchText: From<number, string> = (midi) =>\n Midi.midiToNoteName(midi, { sharps: true });\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\nimport { TICKS_PER_WHOLE, fractionOf } from \"#/shared/lib/ticks.ts\";\n\nimport type { Meter, TempoChange, Text, Timeline } from \"./events.ts\";\nimport { bpmOf, microsecondsOf } from \"./tempo-units.ts\";\n\nconst NONE = 0;\nconst NEXT = 1;\nconst QUARTER = 4;\nconst DEFAULT_METER = { numerator: QUARTER, denominator: QUARTER };\nconst DEFAULT_MICROSECONDS = 500_000;\nconst MAX_DECIMALS = 9;\n\nexport interface LaidTempo {\n readonly offset: number;\n readonly length: number;\n readonly microseconds: number;\n readonly target: Option.Option<number>;\n}\n\nexport interface Span {\n readonly start: number;\n readonly length: number;\n}\n\nexport interface LaidBar extends Span {\n readonly meter: string;\n readonly tempo: readonly LaidTempo[];\n readonly marks: readonly string[];\n}\n\ninterface Signature {\n readonly numerator: number;\n readonly denominator: number;\n}\n\nexport const endOfSpan: From<Span, number> = (span) => span.start + span.length;\n\nconst latestAt =\n (tick: number) =>\n <Item extends { readonly tick: number }>(items: readonly Item[]): Option.Option<Item> =>\n pipe(\n items,\n Arr.filter((item) => item.tick <= tick),\n Arr.last,\n );\n\nconst lengthOf: From<Signature, number> = (signature) =>\n (TICKS_PER_WHOLE * signature.numerator) / signature.denominator;\n\nconst meterText =\n (signature: Signature): From<number, string> =>\n (length) => {\n const beats = (length * signature.denominator) / TICKS_PER_WHOLE;\n if (Number.isInteger(beats)) {\n return `${String(beats)}/${String(signature.denominator)}`;\n }\n return fractionOf(length);\n };\n\ninterface Ramp {\n readonly start: TempoChange;\n readonly end: number;\n readonly target: number;\n}\n\nconst rampAt =\n (tempos: readonly TempoChange[]): From<number, Option.Option<Ramp>> =>\n (tick) =>\n pipe(\n latestAt(tick)(tempos),\n Option.flatMap((start) =>\n pipe(\n start.target,\n Option.flatMap((target) =>\n pipe(\n Arr.findFirst(tempos, (tempo) => tempo.tick > start.tick),\n Option.map((next) => ({ start, end: next.tick, target })),\n ),\n ),\n ),\n ),\n );\n\nconst interpolated =\n (ramp: Ramp): From<number, number> =>\n (tick) => {\n const from = bpmOf(ramp.start.microseconds);\n const to = bpmOf(ramp.target);\n const share = (tick - ramp.start.tick) / (ramp.end - ramp.start.tick);\n return microsecondsOf(from + (to - from) * share);\n };\n\nconst rampedAt =\n (tempos: readonly TempoChange[]) =>\n (tick: number, at: number): Option.Option<number> =>\n pipe(\n rampAt(tempos)(tick),\n Option.map((ramp) => interpolated(ramp)(at)),\n );\n\nconst steadyAt =\n (tempos: readonly TempoChange[]): From<number, number> =>\n (tick) =>\n pipe(\n latestAt(tick)(tempos),\n Option.match({\n onNone: () => DEFAULT_MICROSECONDS,\n onSome: (tempo) => tempo.microseconds,\n }),\n );\n\nconst tempoAt =\n (tempos: readonly TempoChange[]): From<number, number> =>\n (tick) =>\n Option.getOrElse(rampedAt(tempos)(tick, tick), () => steadyAt(tempos)(tick));\n\nconst tempoStepsOf =\n (tempos: readonly TempoChange[]): From<Span, readonly LaidTempo[]> =>\n (bar) => {\n const end = endOfSpan(bar);\n const points = [\n bar.start,\n ...pipe(\n tempos,\n Arr.filter((tempo) => tempo.tick > bar.start && tempo.tick < end),\n Arr.map((tempo) => tempo.tick),\n Arr.dedupe,\n ),\n ];\n return pipe(\n points,\n Arr.map((tick, index) => {\n const stepEnd = Option.getOrElse(Arr.get(points, index + NEXT), () => end);\n return {\n offset: tick - bar.start,\n length: stepEnd - tick,\n microseconds: tempoAt(tempos)(tick),\n target: rampedAt(tempos)(tick, stepEnd),\n };\n }),\n );\n };\n\nconst marksOf =\n (markers: readonly Text[]): From<Span, readonly string[]> =>\n (bar) =>\n pipe(\n markers,\n Arr.filter((marker) => marker.tick >= bar.start && marker.tick < endOfSpan(bar)),\n Arr.map((marker) => marker.text),\n );\n\nconst spanAt =\n (meters: readonly Meter[]): From<number, Span & { readonly signature: Signature }> =>\n (start) => {\n const signature = Option.getOrElse(latestAt(start)(meters), () => DEFAULT_METER);\n const full = start + lengthOf(signature);\n const end = pipe(\n Arr.findFirst(meters, (meter) => meter.tick > start),\n Option.match({ onNone: () => full, onSome: (meter) => Math.min(meter.tick, full) }),\n );\n return { start, length: end - start, signature };\n };\n\nexport const barsOf: From<Timeline, readonly LaidBar[]> = (timeline) =>\n Arr.unfold({ start: NONE, first: true }, (cursor) => {\n if (!cursor.first && cursor.start >= timeline.end) {\n return Option.none();\n }\n const span = spanAt(timeline.meters)(cursor.start);\n const bar: LaidBar = {\n start: span.start,\n length: span.length,\n meter: meterText(span.signature)(span.length),\n tempo: tempoStepsOf(timeline.tempos)(span),\n marks: marksOf(timeline.markers)(span),\n };\n return Option.some([bar, { start: endOfSpan(span), first: false }] as const);\n });\n\nexport const bpmText: From<number, string> = (microseconds) => {\n const exact = bpmOf(microseconds);\n const text = pipe(\n Arr.range(NONE, MAX_DECIMALS),\n Arr.map((decimals) => String(Number(exact.toFixed(decimals)))),\n Arr.findFirst((candidate) => microsecondsOf(Number(candidate)) === microseconds),\n Option.getOrElse(() => String(exact)),\n );\n return `${text}bpm`;\n};\n","import { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport { cellsText, pitchText, restsOf, semitoneText } from \"./cells.ts\";\nimport type { Cell } from \"./cells.ts\";\nimport type { TimelineControl } from \"./events.ts\";\nimport { endOfSpan } from \"./layout.ts\";\nimport type { Span } from \"./layout.ts\";\nimport { controllerKeyOf } from \"./plan.ts\";\nimport type { PlannedPart } from \"./plan.ts\";\n\nconst NEXT = 1;\n\nconst valueText: From<TimelineControl, string> = (control) => {\n if (control.controller.kind === \"bend\") {\n return semitoneText(control.value);\n }\n return String(control.value);\n};\n\nconst headOf =\n (planned: PlannedPart): From<TimelineControl, string> =>\n ({ controller }) => {\n if (controller.kind === \"pressure\") {\n return Option.match(controller.midi, {\n onNone: () => `${planned.name}.pressure`,\n onSome: (midi) => `${planned.name}.pressure ${pitchText(midi)}`,\n });\n }\n return `${planned.name}.${controllerKeyOf({ controller })}`;\n };\n\nconst cellsOf =\n (bar: Span): From<readonly TimelineControl[], readonly Cell[]> =>\n (controls) => {\n const lead = pipe(\n Arr.head(controls),\n Option.map((first) => first.tick - bar.start),\n Option.toArray,\n Arr.flatMap(restsOf),\n );\n const steps = pipe(\n controls,\n Arr.map((control, index) => ({\n head: valueText(control),\n attributes: [],\n length:\n pipe(\n Arr.get(controls, index + NEXT),\n Option.match({ onNone: () => endOfSpan(bar), onSome: (next) => next.tick }),\n ) - control.tick,\n })),\n );\n return [...lead, ...steps];\n };\n\nexport const controlLinesOf =\n (bar: Span): From<PlannedPart, readonly string[]> =>\n (planned) =>\n pipe(\n planned.controls,\n Arr.filter((control) => control.tick >= bar.start && control.tick < endOfSpan(bar)),\n Arr.groupBy((control: TimelineControl) => controllerKeyOf(control)),\n Rec.values,\n Arr.map((controls) =>\n pipe(\n Arr.head(controls),\n Option.map((first) => `${headOf(planned)(first)}: ${cellsText(cellsOf(bar)(controls))}`),\n ),\n ),\n Arr.getSomes,\n );\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type { Envelope, Level, MixParameter, MixPoint, TrackMix } from \"./events.ts\";\nimport { endOfSpan } from \"./layout.ts\";\nimport type { Span } from \"./layout.ts\";\nimport type { PlannedBus, PlannedPart } from \"./plan.ts\";\n\nconst DECIMALS = 1;\nconst PERCENT = 100;\nconst NONE = 0;\nconst NEXT = 1;\n\nconst amountText = (value: number, unit: string): string => {\n const text = Number(value.toFixed(DECIMALS));\n if (text > NONE) {\n return `+${String(text)}${unit}`;\n }\n return `${String(text)}${unit}`;\n};\n\nconst UNITS: Readonly<Record<MixParameter, From<number, string>>> = {\n volume: (decibels) => amountText(decibels, \"dB\"),\n pan: (pan) => amountText(pan * PERCENT, \"%\"),\n};\n\nconst levelWords: From<Level, readonly string[]> = (level) => [\n ...pipe(\n Option.some(level.decibels),\n Option.filter((decibels) => UNITS.volume(decibels) !== UNITS.volume(NONE)),\n Option.map((decibels) => `volume ${UNITS.volume(decibels)}`),\n Option.toArray,\n ),\n ...pipe(\n Option.some(level.pan),\n Option.filter((pan) => UNITS.pan(pan) !== UNITS.pan(NONE)),\n Option.map((pan) => `pan ${UNITS.pan(pan)}`),\n Option.toArray,\n ),\n ...pipe(\n Option.some(\"mute\"),\n Option.filter(() => level.muted),\n Option.toArray,\n ),\n];\n\nexport type Mixing = Readonly<{ mix: TrackMix; buses: readonly PlannedBus[] }>;\n\nexport const trackMixWords: From<Mixing, readonly string[]> = ({ mix, buses }) => [\n ...levelWords(mix.level),\n ...pipe(\n mix.sends,\n Arr.filter((send) => send.amount > NONE),\n Arr.flatMap((send) =>\n pipe(\n Arr.get(buses, send.bus),\n Option.map((bus) => `send ${bus.name} ${amountText(send.amount * PERCENT, \"%\")}`),\n Option.toArray,\n ),\n ),\n ),\n];\n\nexport const busLineOf: From<PlannedBus, string> = (bus) =>\n Arr.join([\"bus\", bus.name, ...levelWords(bus.level)], \" \");\n\nconst valueAt =\n (points: readonly MixPoint[]): From<number, number> =>\n (tick) => {\n const before = pipe(\n points,\n Arr.filter((point) => point.tick <= tick),\n Arr.last,\n );\n const after = pipe(\n points,\n Arr.findFirst((point) => point.tick > tick),\n );\n return Option.match(before, {\n onNone: () => Option.match(after, { onNone: () => NONE, onSome: (point) => point.value }),\n onSome: (left) =>\n Option.match(after, {\n onNone: () => left.value,\n onSome: (right) =>\n left.value +\n ((right.value - left.value) * (tick - left.tick)) / (right.tick - left.tick),\n }),\n });\n };\n\nconst rampOf =\n (bar: Span, name: string): From<Envelope, Option.Option<string>> =>\n (envelope) => {\n const at = valueAt(envelope.points);\n const unit = UNITS[envelope.parameter];\n const from = unit(at(bar.start));\n const to = unit(at(endOfSpan(bar)));\n return pipe(\n Option.some(`automate ${name}.${envelope.parameter} ${from} -> ${to} over 1bar`),\n Option.filter(() => from !== to),\n );\n };\n\nexport const automationLinesOf =\n (bar: Span): From<PlannedPart, readonly string[]> =>\n (planned) =>\n pipe(\n planned.mix.envelopes,\n Arr.filter((envelope) => Arr.length(envelope.points) > NEXT),\n Arr.map(rampOf(bar, planned.name)),\n Arr.getSomes,\n );\n","import { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport { cellsText, pitchText, quoted, restsOf, shareText } from \"./cells.ts\";\nimport type { Cell } from \"./cells.ts\";\nimport type { Group, Line } from \"./groups.ts\";\nimport { endOfSpan } from \"./layout.ts\";\nimport type { Span } from \"./layout.ts\";\nimport type { Plan, PlannedPart } from \"./plan.ts\";\n\nconst FULL = 127;\nconst DEFAULT_RELEASE = 64;\nconst SINGLE = 1;\n\ninterface Segment {\n readonly group: Group;\n readonly start: number;\n readonly end: number;\n}\n\ninterface VoiceText {\n readonly text: string;\n readonly continues: boolean;\n}\n\nconst touches =\n (bar: Span): From<Group, boolean> =>\n (group) => {\n if (group.end === group.start) {\n return group.start >= bar.start && group.start < endOfSpan(bar);\n }\n return group.start < endOfSpan(bar) && group.end > bar.start;\n };\n\nconst segmentOf =\n (bar: Span): From<Group, Segment> =>\n (group) => ({\n group,\n start: Math.max(group.start, bar.start),\n end: Math.min(group.end, endOfSpan(bar)),\n });\n\nconst pitchesText: From<readonly number[], string> = (midis) => {\n if (midis.length === SINGLE) {\n return Arr.join(pipe(midis, Arr.map(pitchText)), \"\");\n }\n return `[${Arr.join(pipe(midis, Arr.map(pitchText)), \" \")}]`;\n};\n\nconst headOf =\n (voices: Option.Option<ReadonlyMap<number, string>>): From<Group, string> =>\n (group) =>\n Option.match(voices, {\n onNone: () => pitchesText(group.midis),\n onSome: (map) =>\n pipe(\n Arr.head(group.midis),\n Option.flatMap((midi) => Option.fromNullishOr(map.get(midi))),\n Option.getOrElse(() => \"\"),\n ),\n });\n\nconst when = (condition: boolean, text: string): readonly string[] => {\n if (condition) {\n return [text];\n }\n return [];\n};\n\nconst attributesOf: From<Segment, readonly string[]> = ({ group, start, end }) => {\n const last = end === group.end;\n return [\n ...when(group.velocity !== FULL, `vel ${shareText(group.velocity)}`),\n ...when(last && group.release !== DEFAULT_RELEASE, `off ${shareText(group.release)}`),\n ...when(!last, \"tie\"),\n ...pipe(\n group.lyric,\n Option.filter(() => start === group.start),\n Option.map((text) => `lyric ${quoted(text)}`),\n Option.toArray,\n ),\n ];\n};\n\nconst cellsOf = (\n segments: readonly Segment[],\n bar: Span,\n head: From<Group, string>,\n): readonly Cell[] => {\n const placed = Arr.reduce(\n segments,\n { cells: [] as readonly Cell[], cursor: bar.start },\n ({ cells, cursor }, segment) => ({\n cells: [\n ...cells,\n ...restsOf(segment.start - cursor),\n {\n head: head(segment.group),\n attributes: attributesOf(segment),\n length: segment.end - segment.start,\n },\n ],\n cursor: segment.end,\n }),\n );\n return [...placed.cells, ...restsOf(endOfSpan(bar) - placed.cursor)];\n};\n\nconst lineTextOf =\n (\n planned: PlannedPart,\n voices: Option.Option<ReadonlyMap<number, string>>,\n bar: Span,\n ): From<Line, Option.Option<VoiceText>> =>\n (line) => {\n const segments = pipe(line, Arr.filter(touches(bar)), Arr.map(segmentOf(bar)));\n return pipe(\n Arr.head(segments),\n Option.map((first) => ({\n text: `${planned.name}: ${cellsText(cellsOf(segments, bar, headOf(voices)))}`,\n continues: first.start > first.group.start,\n })),\n );\n };\n\nconst continuedFirst = Order.mapInput(Order.Boolean, (voice: VoiceText) => !voice.continues);\n\nexport interface VoiceContext {\n readonly plan: Plan;\n readonly bar: Span;\n}\n\nexport const voiceLinesOf: From<VoiceContext, From<PlannedPart, readonly string[]>> =\n ({ plan, bar }) =>\n (planned) => {\n const voices = pipe(\n Option.some(plan.drumVoices),\n Option.filter(() => planned.source.kind === \"kit\"),\n );\n const texts = pipe(planned.lines, Arr.map(lineTextOf(planned, voices, bar)), Arr.getSomes);\n return pipe(\n Arr.sort(texts, continuedFirst),\n Arr.map((voice) => voice.text),\n );\n };\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\nimport { fractionOf } from \"#/shared/lib/ticks.ts\";\n\nimport { quoted } from \"./cells.ts\";\nimport { controlLinesOf } from \"./control-lines.ts\";\nimport type { Timeline } from \"./events.ts\";\nimport { barsOf, bpmText } from \"./layout.ts\";\nimport type { LaidBar, LaidTempo } from \"./layout.ts\";\nimport { automationLinesOf, busLineOf, trackMixWords } from \"./mix-lines.ts\";\nimport { planOf } from \"./plan.ts\";\nimport type { Plan, PlannedPart } from \"./plan.ts\";\nimport { voiceLinesOf } from \"./voice-lines.ts\";\n\nconst SINGLE = 1;\nconst INDENT = \" \";\n\nexport interface Written {\n readonly text: string;\n readonly plan: Plan;\n readonly bars: readonly LaidBar[];\n}\n\ninterface Previous {\n readonly meter: Option.Option<string>;\n readonly microseconds: Option.Option<number>;\n}\n\nconst START: Previous = { meter: Option.none(), microseconds: Option.none() };\n\nconst isRamp: From<LaidTempo, boolean> = (step) => Option.isSome(step.target);\n\nconst stepText: From<LaidTempo, string> = (step) => {\n const ramp = Option.match(step.target, {\n onNone: () => \"\",\n onSome: (target) => ` -> ${bpmText(target)}`,\n });\n return `${bpmText(step.microseconds)}${ramp} ${fractionOf(step.length)}`;\n};\n\nconst isSteady: From<LaidBar, boolean> = (bar) =>\n bar.tempo.length <= SINGLE && !pipe(bar.tempo, Arr.some(isRamp));\n\nconst tempoLineOf: From<LaidBar, Option.Option<string>> = (bar) => {\n if (isSteady(bar)) {\n return Option.none();\n }\n const steps = pipe(bar.tempo, Arr.map(stepText));\n return Option.some(`tempo: ${Arr.join(steps, \", \")}`);\n};\n\nconst differs =\n <Value>(previous: Option.Option<Value>): From<Value, boolean> =>\n (current) =>\n Option.match(previous, { onNone: () => true, onSome: (value) => value !== current });\n\nconst headerTempoOf =\n (previous: Previous): From<LaidBar, readonly string[]> =>\n (bar) =>\n pipe(\n Arr.head(bar.tempo),\n Option.filter(() => isSteady(bar)),\n Option.map((step) => step.microseconds),\n Option.filter(differs(previous.microseconds)),\n Option.map((microseconds) => `tempo ${bpmText(microseconds)}`),\n Option.toArray,\n );\n\nconst barHeadOf =\n (previous: Previous): From<LaidBar, string> =>\n (bar) => {\n const meter = pipe(\n Option.some(bar.meter),\n Option.filter(differs(previous.meter)),\n Option.map((current) => `meter ${current}`),\n Option.toArray,\n );\n const mark = pipe(\n Option.some(bar.marks),\n Option.filter(Arr.isReadonlyArrayNonEmpty),\n Option.map((marks) => `mark ${quoted(Arr.join(marks, \" / \"))}`),\n Option.toArray,\n );\n return Arr.join([\"bar\", ...meter, ...headerTempoOf(previous)(bar), ...mark, \"{\"], \" \");\n };\n\nconst barBodyOf: From<Plan, From<LaidBar, readonly string[]>> = (plan) => (bar) => [\n ...Option.toArray(tempoLineOf(bar)),\n ...pipe(\n plan.parts,\n Arr.flatMap((planned) => [\n ...voiceLinesOf({ plan, bar })(planned),\n ...controlLinesOf(bar)(planned),\n ...automationLinesOf(bar)(planned),\n ]),\n ),\n];\n\ninterface Walk {\n readonly lines: readonly string[];\n readonly previous: Previous;\n}\n\nconst afterBar: From<LaidBar, Previous> = (bar) => ({\n meter: Option.some(bar.meter),\n microseconds: pipe(\n Arr.last(bar.tempo),\n Option.map((step) => Option.getOrElse(step.target, () => step.microseconds)),\n ),\n});\n\nconst walkStep: From<Plan, (walk: Walk, bar: LaidBar) => Walk> =\n (plan) =>\n ({ lines, previous }, bar) => ({\n lines: [\n ...lines,\n \"\",\n barHeadOf(previous)(bar),\n ...pipe(\n barBodyOf(plan)(bar),\n Arr.map((line) => `${INDENT}${line}`),\n ),\n \"}\",\n ],\n previous: afterBar(bar),\n });\n\nconst instrumentLinesOf: From<Plan, readonly string[]> = (plan) =>\n pipe(\n Arr.fromIterable(plan.instruments),\n Arr.map(([program, name]) => `instrument ${name} plugin gm program ${String(program)}`),\n );\n\nconst kitLinesOf: From<Plan, readonly string[]> = (plan) => {\n if (plan.drumVoices.size < SINGLE) {\n return [];\n }\n const voices = pipe(\n Arr.fromIterable(plan.drumVoices.values()),\n Arr.map((name) => `${INDENT}${name} ${quoted(`gm-drums/${name}.flac`)}`),\n );\n return [\"kit gm-drums {\", ...voices, \"}\"];\n};\n\nconst sourceWordsOf: From<PlannedPart, readonly string[]> = (planned) => {\n if (planned.source.kind === \"kit\") {\n return [\"kit gm-drums role drums\"];\n }\n return [`instrument ${planned.source.instrument}`];\n};\n\nconst trackLineOf =\n (plan: Plan): From<PlannedPart, string> =>\n (planned) =>\n Arr.join(\n [\n \"track\",\n planned.name,\n ...sourceWordsOf(planned),\n ...trackMixWords({ mix: planned.mix, buses: plan.buses }),\n ],\n \" \",\n );\n\ninterface Heading {\n readonly plan: Plan;\n readonly title: string;\n}\n\nconst headerOf: From<Heading, readonly string[]> = ({ plan, title }) => [\n `song ${quoted(title)}`,\n \"\",\n 'plugin gm from \"./gm.ts\" { program: number = 0 }',\n \"\",\n ...instrumentLinesOf(plan),\n ...kitLinesOf(plan),\n \"\",\n ...pipe(plan.buses, Arr.map(busLineOf)),\n ...pipe(plan.parts, Arr.map(trackLineOf(plan))),\n];\n\nexport interface WriteInput {\n readonly timeline: Timeline;\n readonly title: string;\n}\n\nexport const writeFumx: From<WriteInput, Written> = ({ timeline, title }) => {\n const plan = planOf(timeline);\n const bars = barsOf(timeline);\n const walked = Arr.reduce(\n bars,\n { lines: headerOf({ plan, title }), previous: START },\n walkStep(plan),\n );\n return { text: `${Arr.join(walked.lines, \"\\n\")}\\n`, plan, bars };\n};\n"],"mappings":";;;;;;AAAA,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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IAAI,CAAC,CAAC;AAChD;AAOA,MAAa,aAAwC,EAAE,UAAU,YAAY;CAC3E,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,SAASA,MAAI,OACjB,MACA;EAAE,OAAO,SAAS;GAAE;GAAM;EAAM,CAAC;EAAG,UAAU;CAAM,GACpD,SAAS,IAAI,CACf;CACA,OAAO;EAAE,MAAM,GAAGA,MAAI,KAAK,OAAO,OAAO,IAAI,EAAE;EAAK;EAAM;CAAK;AACjE"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,121 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/fumx",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Everything for .fumx songs: read a song as a typed value, analyze its keys and chords, import it from TypeScript with Vite, edit it with a language server, convert MIDI and Ableton Live Sets with a check against the original, and lint musical rules such as notes outside the key, part ranges and parallel fifths from vite.config.ts.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fumx",
|
|
7
|
+
"langium",
|
|
8
|
+
"language-server",
|
|
9
|
+
"lint",
|
|
10
|
+
"midi",
|
|
11
|
+
"music",
|
|
12
|
+
"music-theory",
|
|
13
|
+
"parser",
|
|
14
|
+
"tanstack-intent",
|
|
15
|
+
"vite-plugin",
|
|
16
|
+
"voicing"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/masseater/ecosystems/tree/main/libs/fumx#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/masseater/ecosystems/issues"
|
|
21
|
+
},
|
|
5
22
|
"license": "MIT",
|
|
6
23
|
"repository": {
|
|
7
24
|
"type": "git",
|
|
8
25
|
"url": "git+https://github.com/masseater/ecosystems.git",
|
|
9
26
|
"directory": "libs/fumx"
|
|
10
27
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
"bin": {
|
|
29
|
+
"fumx": "./dist/fumx.mjs"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"dist",
|
|
34
|
+
"skills/lint-songs",
|
|
35
|
+
"skills/read-fumx",
|
|
36
|
+
"skills/use-fumx-tools",
|
|
37
|
+
"skills/use-lint-presets"
|
|
38
|
+
],
|
|
39
|
+
"type": "module",
|
|
40
|
+
"sideEffects": [
|
|
41
|
+
"./dist/mapper.mjs"
|
|
42
|
+
],
|
|
43
|
+
"imports": {
|
|
44
|
+
"#/*": "./src/*",
|
|
45
|
+
"#generated/*": "./generated/*"
|
|
46
|
+
},
|
|
47
|
+
"exports": {
|
|
48
|
+
".": "./dist/index.mjs",
|
|
49
|
+
"./analysis": "./dist/analysis.mjs",
|
|
50
|
+
"./convert-als": "./dist/convert-als.mjs",
|
|
51
|
+
"./convert-midi": "./dist/convert-midi.mjs",
|
|
52
|
+
"./lint": "./dist/lint.mjs",
|
|
53
|
+
"./presets": "./dist/presets.mjs",
|
|
54
|
+
"./habits": "./dist/habits.mjs",
|
|
55
|
+
"./vite": "./dist/vite.mjs",
|
|
56
|
+
"./mapper": "./dist/mapper.mjs",
|
|
57
|
+
"./package.json": "./package.json"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public",
|
|
61
|
+
"provenance": true
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@r_masseater/masseater-utils": ">=0.17.0",
|
|
65
|
+
"ableton-als": "^0.5.1",
|
|
66
|
+
"fast-xml-parser": "^5.12.1",
|
|
67
|
+
"langium": "^4.4.2",
|
|
68
|
+
"midi-file": "^1.2.4",
|
|
69
|
+
"tonal": "^6.19.0",
|
|
70
|
+
"vscode-languageserver": "^11.0.2"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@effect/platform-node": "4.2.0",
|
|
74
|
+
"@effect/platform-node-shared": "4.2.0",
|
|
75
|
+
"@effect/vitest": "4.2.0",
|
|
76
|
+
"@masseater.dev/lint-host": "0.0.0",
|
|
77
|
+
"@r_masseater/fumx": "0.1.2",
|
|
78
|
+
"@types/node": "26.6.11",
|
|
79
|
+
"effect": "4.2.0",
|
|
80
|
+
"langium-cli": "4.4.1",
|
|
81
|
+
"ts-content-mapper": "0.1.1",
|
|
82
|
+
"tsrs": "7.1.0-beta.tsrs7",
|
|
83
|
+
"verovio": "6.4.1",
|
|
84
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@8.4.0",
|
|
85
|
+
"vite-plus": "1.9.0"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"@effect/platform-node": "^4.1.0",
|
|
89
|
+
"@effect/platform-node-shared": ">=4.1.5",
|
|
90
|
+
"effect": "^4.1.0",
|
|
91
|
+
"ts-content-mapper": ">=0.1.1",
|
|
92
|
+
"vite": "*",
|
|
93
|
+
"vite-plus": "^1.8.0"
|
|
94
|
+
},
|
|
95
|
+
"peerDependenciesMeta": {
|
|
96
|
+
"@effect/platform-node-shared": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"ts-content-mapper": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"vite": {
|
|
103
|
+
"optional": true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"typescript": {
|
|
107
|
+
"contentMapper": {
|
|
108
|
+
"compilerOptions": [],
|
|
109
|
+
"dynamicConfig": false,
|
|
110
|
+
"exec": [
|
|
111
|
+
"node",
|
|
112
|
+
"--input-type=module",
|
|
113
|
+
"-e",
|
|
114
|
+
"import \"@r_masseater/fumx/mapper\""
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"engines": {
|
|
119
|
+
"node": ">=26.13.1"
|
|
14
120
|
}
|
|
15
121
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lint-songs
|
|
3
|
+
description: >
|
|
4
|
+
Use when setting up fumx lint in vite.config.ts, running it on .fumx songs,
|
|
5
|
+
writing a music rule in TypeScript with defineRule, or silencing a finding
|
|
6
|
+
with a fumx-ignore comment.
|
|
7
|
+
metadata:
|
|
8
|
+
type: core
|
|
9
|
+
library: "@r_masseater/fumx"
|
|
10
|
+
library_version: 0.1.2
|
|
11
|
+
sources:
|
|
12
|
+
- src/app/lint.ts
|
|
13
|
+
- src/features/check-songs/model/types.ts
|
|
14
|
+
- src/features/check-songs/model/suppressions.ts
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# lint-songs
|
|
18
|
+
|
|
19
|
+
`fumx lint` lints `.fumx` songs. Each rule sees the song as data and reports findings by file line and column.
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import "@r_masseater/fumx/vite";
|
|
25
|
+
import { recommended } from "@r_masseater/fumx/presets";
|
|
26
|
+
import { defineConfig } from "vite-plus";
|
|
27
|
+
|
|
28
|
+
export default defineConfig({ fumx: { lint: { extends: [recommended()] } } });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Run `vp exec fumx lint`. It lints every `.fumx` file git tracks, or the paths given. It exits non-zero only when a rule set to `"error"` reports.
|
|
32
|
+
|
|
33
|
+
## Config
|
|
34
|
+
|
|
35
|
+
| Key | Holds |
|
|
36
|
+
| --------- | ------------------------------------------------------------------------- |
|
|
37
|
+
| `extends` | Configs applied first; later entries and the config's own keys win |
|
|
38
|
+
| `plugins` | `{ name: plugin }`; a plugin's rules become `name/rule` and run as errors |
|
|
39
|
+
| `rules` | `"off"`, `"warn"`, `"error"` or `[severity, options]` per `plugin/rule` |
|
|
40
|
+
| `ignores` | Globs of files to skip |
|
|
41
|
+
|
|
42
|
+
Naming a plugin in `rules` that `plugins` does not register fails the run.
|
|
43
|
+
|
|
44
|
+
## Write a rule
|
|
45
|
+
|
|
46
|
+
`check(context)` gets `song` (the parsed `Song`), `soundings` (notes of unmuted tracks with `track`, `role`, `midi`, `start`, `end`, `bar`, `line`, `column`), `options` and `report({ line, column, message, detail })`. Times are ticks. `end` already accounts for the note's gate. Keys and chords come from `@r_masseater/fumx/analysis`.
|
|
47
|
+
|
|
48
|
+
Report with the sounding's `line` and `column` so the finding points at the note in the file.
|
|
49
|
+
|
|
50
|
+
## Ignore a finding
|
|
51
|
+
|
|
52
|
+
`// fumx-ignore rule-a, rule-b` on the line, `// fumx-ignore-next-line` on the line above, `// fumx-ignore-file` anywhere, or `// fumx-disable rule-a` ... `// fumx-enable rule-a` around a passage. Without rule names it covers every rule. Write the reason after `--`, for example `// fumx-disable pop/melody-leap -- the chorus jumps on purpose`.
|
|
53
|
+
|
|
54
|
+
This skill describes [`src/app/lint.ts`](../../src/app/lint.ts), [`src/features/check-songs/model/types.ts`](../../src/features/check-songs/model/types.ts) and [`src/features/check-songs/model/suppressions.ts`](../../src/features/check-songs/model/suppressions.ts).
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: read-fumx
|
|
3
|
+
description: >
|
|
4
|
+
Use when code must read a .fumx song into data with @r_masseater/fumx:
|
|
5
|
+
readSong and its read callback, the valid and invalid results, the Song
|
|
6
|
+
value's notes, hits, controls and bars, ticks and fractionOf, and writing a
|
|
7
|
+
lint rule over the result.
|
|
8
|
+
metadata:
|
|
9
|
+
type: core
|
|
10
|
+
library: "@r_masseater/fumx"
|
|
11
|
+
library_version: 0.1.2
|
|
12
|
+
sources:
|
|
13
|
+
- src/app/index.ts
|
|
14
|
+
- src/app/analysis.ts
|
|
15
|
+
- src/entities/song
|
|
16
|
+
- src/features/read-song/model/read-song.ts
|
|
17
|
+
- src/features/analyze-song
|
|
18
|
+
- README.md
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# read-fumx
|
|
22
|
+
|
|
23
|
+
`readSong` turns `.fumx` text into a `Song`. Every note, hit and controller event has a track, a bar and an absolute `start` and `length` in ticks, so a rule about music is a filter over plain data.
|
|
24
|
+
|
|
25
|
+
## Read a song
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { readSong } from "@r_masseater/fumx";
|
|
29
|
+
import { Effect, FileSystem } from "effect";
|
|
30
|
+
|
|
31
|
+
const program = Effect.gen(function* () {
|
|
32
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
33
|
+
return yield* readSong({
|
|
34
|
+
path: "/songs/demo.fumx",
|
|
35
|
+
read: (path) => fileSystem.readFileString(path),
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`read` is called for the entry file and for every file it imports. Its error type flows into the result.
|
|
41
|
+
|
|
42
|
+
`source.status` is `"valid"` with `song`, or `"invalid"` with `issues` (`path`, `line`, `column`, `start`, `end`, `message`). Both carry an `outline` of where names are declared. Messages are in Japanese.
|
|
43
|
+
|
|
44
|
+
## The song value
|
|
45
|
+
|
|
46
|
+
| Field | Holds |
|
|
47
|
+
| ------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
48
|
+
| `notes` | Pitched notes: `midi`, `velocity` (0 to 1), `releaseVelocity`, `gate`, `lyric`, `bend` |
|
|
49
|
+
| `hits` | Drum hits: kit `voice`, `velocity`, `releaseVelocity`, `bend` |
|
|
50
|
+
| `controls` | Controller events: `controller.kind` is `cc` (with `number`), `pressure`, `bend` or `program` |
|
|
51
|
+
| `bars` | Each bar's `start`, `length`, `meter`, `tempo`, `tempoSteps`, `section` and `mark` |
|
|
52
|
+
| `tracks`, `instruments`, `kits` | The declarations in the header. A track with `into` is a layer of another track |
|
|
53
|
+
| `mix`, `tailSeconds` | The `master` line: a mix plugin that replaces the built-in mixdown, and the tail after the end |
|
|
54
|
+
|
|
55
|
+
Ties are already joined: a note tied over a bar line is one note.
|
|
56
|
+
|
|
57
|
+
Notes and hits carry `args`, the values a `with { … }` attribute passes to plugins, and `nudgeSeconds`. Times and shares written as decimals (`nudge 0.4ms`, `pan -35%`) are read as the double that the decimal names, so `seconds` is exact rather than `milliseconds * 0.001`. `vel` stays between 0 and 1; `amp` multiplies the level linearly and may go above 1.
|
|
58
|
+
|
|
59
|
+
Times are ticks. `TICKS_PER_WHOLE` ticks make a whole note, and `fractionOf(ticks)` prints `"3/8"`. Compare with ticks, not with fractions.
|
|
60
|
+
|
|
61
|
+
## Write a rule
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import type { Song } from "@r_masseater/fumx";
|
|
65
|
+
|
|
66
|
+
declare const song: Song;
|
|
67
|
+
|
|
68
|
+
const outOfRange = song.notes.filter(
|
|
69
|
+
(note) => note.track === "bass" && (note.midi < 28 || note.midi > 55),
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Report a finding with the note's `sourceLine` and `sourceColumn`, the position of the note in the file. `line` is the index of the voice line inside its bar, not a file line.
|
|
74
|
+
|
|
75
|
+
## Keys and chords
|
|
76
|
+
|
|
77
|
+
The file does not write keys or chords. `@r_masseater/fumx/analysis` estimates them from the notes:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { analyze, keyIn, soundingsOf } from "@r_masseater/fumx/analysis";
|
|
81
|
+
|
|
82
|
+
const report = analyze(song);
|
|
83
|
+
const verseKey = keyIn(song)({ fromBar: 1, toBar: 8 });
|
|
84
|
+
const heard = soundingsOf(song);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`analyze` returns the key of the whole song, the key of every four bars, the chord on each beat and bars that repeat. `soundingsOf` lists the notes of unmuted tracks with their track `role`, source `line` and `column`, and an `end` that the note's `gate` shortens. For ready-made rules, use `fumx lint` with `@r_masseater/fumx/lint` and `@r_masseater/fumx/presets`.
|
|
88
|
+
|
|
89
|
+
This skill describes [`src/app/index.ts`](../../src/app/index.ts), [`src/app/analysis.ts`](../../src/app/analysis.ts), [`src/entities/song`](../../src/entities/song), [`src/features/read-song/model/read-song.ts`](../../src/features/read-song/model/read-song.ts), [`src/features/analyze-song`](../../src/features/analyze-song) and [`README.md`](../../README.md).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: use-fumx-tools
|
|
3
|
+
description: >
|
|
4
|
+
Use when a .fumx song must be imported from TypeScript, checked or converted:
|
|
5
|
+
the fumx Vite plugin, the TypeScript content mapper, fumx report for keys,
|
|
6
|
+
chords and repeated bars, fumx convert for turning a MIDI file or an Ableton
|
|
7
|
+
Live Set into .fumx with a check against the original, and fumx
|
|
8
|
+
language-server.
|
|
9
|
+
metadata:
|
|
10
|
+
type: core
|
|
11
|
+
library: "@r_masseater/fumx"
|
|
12
|
+
library_version: 0.1.2
|
|
13
|
+
sources:
|
|
14
|
+
- src
|
|
15
|
+
- bin
|
|
16
|
+
- README.md
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# use-fumx-tools
|
|
20
|
+
|
|
21
|
+
`.fumx` is a text format for music. This package turns it into something TypeScript, an editor and an agent can use.
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
vp add @r_masseater/fumx effect vite-plus
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Import a song from TypeScript
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { fumx } from "@r_masseater/fumx/vite";
|
|
33
|
+
import { defineConfig } from "vite-plus";
|
|
34
|
+
|
|
35
|
+
export default defineConfig({ plugins: [fumx()] });
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then `import { song } from "./song.fumx"` gives a typed value. Add the content mapper to `tsconfig.json` so the TypeScript server resolves it:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{ "contentMappers": [{ "package": "@r_masseater/fumx", "extensions": [".fumx"] }] }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Check what was written
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
vp exec fumx report song.fumx
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
It prints the keys, chords and repeated bars as JSON. Read it to confirm that the song you wrote has the harmony and the structure you meant, since you cannot listen to it.
|
|
51
|
+
|
|
52
|
+
## Convert a MIDI file or a Live Set
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
vp exec fumx convert song.mid
|
|
56
|
+
vp exec fumx convert song.als
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The command writes `song.fumx`, reads it back, and compares it with the events of the original. It fails if even one event differs. Do not hand edit the output to make it pass.
|
|
60
|
+
|
|
61
|
+
## Common mistakes
|
|
62
|
+
|
|
63
|
+
### Importing `.fumx` without the content mapper
|
|
64
|
+
|
|
65
|
+
Wrong: add only the Vite plugin. The build works, but the editor reports that the module has no declaration.
|
|
66
|
+
|
|
67
|
+
Correct: add the plugin and the `contentMappers` entry, and set `allowArbitraryExtensions`.
|
|
68
|
+
|
|
69
|
+
This skill describes [`src`](../../src), [`bin`](../../bin) and [`README.md`](../../README.md).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: use-lint-presets
|
|
3
|
+
description: >
|
|
4
|
+
Use when choosing which @r_masseater/fumx/presets presets a project extends,
|
|
5
|
+
setting their options, explaining a pop/, harmony/, classical/, progressions/
|
|
6
|
+
or bach/ finding in plain words, or adding a preset for another style of
|
|
7
|
+
writing music.
|
|
8
|
+
metadata:
|
|
9
|
+
type: core
|
|
10
|
+
library: "@r_masseater/fumx"
|
|
11
|
+
library_version: 0.1.2
|
|
12
|
+
requires:
|
|
13
|
+
- lint-songs
|
|
14
|
+
sources:
|
|
15
|
+
- src/app/presets.ts
|
|
16
|
+
- src/app/presets/features/check-pop/model/preset.ts
|
|
17
|
+
- src/app/presets/features/check-harmony/model/preset.ts
|
|
18
|
+
- src/app/presets/features/check-classical/model/preset.ts
|
|
19
|
+
- src/app/presets/features/check-progressions/model/preset.ts
|
|
20
|
+
- src/app/presets/features/check-style/model/preset.ts
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
# use-lint-presets
|
|
24
|
+
|
|
25
|
+
Each preset returns a `fumx lint` config for one concern. List the ones you want in `extends` under `fumx.lint`.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import "@r_masseater/fumx/vite";
|
|
29
|
+
import { classical, harmony, pop } from "@r_masseater/fumx/presets";
|
|
30
|
+
import { defineConfig } from "vite-plus";
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
fumx: {
|
|
34
|
+
lint: {
|
|
35
|
+
extends: [
|
|
36
|
+
pop({ ranges: { lead: ["A3", "E5"], bass: ["E1", "G3"] } }),
|
|
37
|
+
harmony(),
|
|
38
|
+
classical(),
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 前提
|
|
46
|
+
|
|
47
|
+
- <skill:@r_masseater/fumx#lint-songs>
|
|
48
|
+
|
|
49
|
+
## Presets
|
|
50
|
+
|
|
51
|
+
| Preset | What it checks |
|
|
52
|
+
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| `pop({ ranges, maxLeap, breathSeconds })` | Key, part range, melody leaps and breath. `ranges` maps a track name or role to `[low, high]` pitch names. |
|
|
54
|
+
| `harmony()` | Semitone clashes, low interval limits and crowded low mids (A2-B3). It also flags harmony above the melody and chord voices that leap. |
|
|
55
|
+
| `classical()` | Parallel fifths and octaves between melody and bass. It also flags dissonances on strong beats that do not step down. |
|
|
56
|
+
| `progressions()` | Names famous progressions where they start. `PROGRESSIONS` lists them. |
|
|
57
|
+
| `bach()` | Warns on chord changes Bach rarely makes in his chorales. The detail names the chords he usually picks. |
|
|
58
|
+
| `recommended(popOptions)` | `pop` and `harmony`. |
|
|
59
|
+
|
|
60
|
+
`stylePluginOf(table)` turns any `StyleTable` of chord transition counts into the same rule as `bach()` for another style.
|
|
61
|
+
|
|
62
|
+
Rules read the track `role`. A track without a role is only checked by rules that look at every pitched part. Those are `out-of-key`, `semitone-clash`, `low-interval-limit` and `crowded-low-mids`.
|
|
63
|
+
|
|
64
|
+
## Explain a finding
|
|
65
|
+
|
|
66
|
+
Every report has a `detail` with the fix. When the person does not know music theory, start with what they would hear. Examples are a rumble, a wrong-sounding note, or a line that cannot be sung in one breath. Give the theory name after that.
|
|
67
|
+
|
|
68
|
+
## Add a style
|
|
69
|
+
|
|
70
|
+
Put a new style in `src/app/presets/features/check-<style>/` with its own plugin and preset function. Export both from `src/app/presets.ts`. Do not add options to an existing preset to change its style.
|
|
71
|
+
|
|
72
|
+
This skill describes [`src/app/presets.ts`](../../src/app/presets.ts), [`src/app/presets/features/check-pop/model/preset.ts`](../../src/app/presets/features/check-pop/model/preset.ts), [`src/app/presets/features/check-harmony/model/preset.ts`](../../src/app/presets/features/check-harmony/model/preset.ts), [`src/app/presets/features/check-classical/model/preset.ts`](../../src/app/presets/features/check-classical/model/preset.ts), [`src/app/presets/features/check-progressions/model/preset.ts`](../../src/app/presets/features/check-progressions/model/preset.ts) and [`src/app/presets/features/check-style/model/preset.ts`](../../src/app/presets/features/check-style/model/preset.ts).
|