@nodelyra/not-angka 0.0.0-stage → 0.1.0

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.
Files changed (251) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/THIRD_PARTY.md +24 -0
  4. package/dist/esm/cursor/activeChord.d.ts +12 -0
  5. package/dist/esm/cursor/activeChord.js +36 -0
  6. package/dist/esm/cursor/beatDot.d.ts +30 -0
  7. package/dist/esm/cursor/beatDot.js +49 -0
  8. package/dist/esm/cursor/drawnTop.d.ts +9 -0
  9. package/dist/esm/cursor/drawnTop.js +16 -0
  10. package/dist/esm/cursor/pageBoxes.d.ts +28 -0
  11. package/dist/esm/cursor/pageBoxes.js +75 -0
  12. package/dist/esm/cursor/playbackCursor.d.ts +25 -0
  13. package/dist/esm/cursor/playbackCursor.js +42 -0
  14. package/dist/esm/cursor/playingStyle.d.ts +16 -0
  15. package/dist/esm/cursor/playingStyle.js +34 -0
  16. package/dist/esm/cursor/playingTones.d.ts +8 -0
  17. package/dist/esm/cursor/playingTones.js +16 -0
  18. package/dist/esm/cursor/target.d.ts +47 -0
  19. package/dist/esm/cursor/target.js +63 -0
  20. package/dist/esm/export/pageText.d.ts +8 -0
  21. package/dist/esm/export/pageText.js +80 -0
  22. package/dist/esm/export/svgExport.d.ts +46 -0
  23. package/dist/esm/export/svgExport.js +88 -0
  24. package/dist/esm/geometry/metrics.d.ts +42 -0
  25. package/dist/esm/geometry/metrics.js +52 -0
  26. package/dist/esm/geometry/pageSetup.d.ts +61 -0
  27. package/dist/esm/geometry/pageSetup.js +85 -0
  28. package/dist/esm/geometry/paper.d.ts +16 -0
  29. package/dist/esm/geometry/paper.js +16 -0
  30. package/dist/esm/index.d.ts +35 -0
  31. package/dist/esm/index.js +23 -0
  32. package/dist/esm/layout/LayoutEngine.d.ts +64 -0
  33. package/dist/esm/layout/LayoutEngine.js +92 -0
  34. package/dist/esm/layout/arcs.d.ts +20 -0
  35. package/dist/esm/layout/arcs.js +53 -0
  36. package/dist/esm/layout/barlineShapes.d.ts +52 -0
  37. package/dist/esm/layout/barlineShapes.js +71 -0
  38. package/dist/esm/layout/directions.d.ts +48 -0
  39. package/dist/esm/layout/directions.js +122 -0
  40. package/dist/esm/layout/elementBoxes.d.ts +17 -0
  41. package/dist/esm/layout/elementBoxes.js +72 -0
  42. package/dist/esm/layout/floating.d.ts +29 -0
  43. package/dist/esm/layout/floating.js +39 -0
  44. package/dist/esm/layout/keyMarks.d.ts +26 -0
  45. package/dist/esm/layout/keyMarks.js +30 -0
  46. package/dist/esm/layout/lyricAlign.d.ts +6 -0
  47. package/dist/esm/layout/lyricAlign.js +15 -0
  48. package/dist/esm/layout/lyricWords.d.ts +13 -0
  49. package/dist/esm/layout/lyricWords.js +27 -0
  50. package/dist/esm/layout/lyricsLayout.d.ts +55 -0
  51. package/dist/esm/layout/lyricsLayout.js +122 -0
  52. package/dist/esm/layout/markings.d.ts +97 -0
  53. package/dist/esm/layout/markings.js +150 -0
  54. package/dist/esm/layout/measurePlan.d.ts +74 -0
  55. package/dist/esm/layout/measurePlan.js +232 -0
  56. package/dist/esm/layout/measureSegments.d.ts +24 -0
  57. package/dist/esm/layout/measureSegments.js +64 -0
  58. package/dist/esm/layout/notationMetrics.d.ts +110 -0
  59. package/dist/esm/layout/notationMetrics.js +122 -0
  60. package/dist/esm/layout/systemBreaking.d.ts +59 -0
  61. package/dist/esm/layout/systemBreaking.js +137 -0
  62. package/dist/esm/layout/systemLayout.d.ts +138 -0
  63. package/dist/esm/layout/systemLayout.js +266 -0
  64. package/dist/esm/layout/tupletSpacing.d.ts +9 -0
  65. package/dist/esm/layout/tupletSpacing.js +33 -0
  66. package/dist/esm/layout/tuplets.d.ts +30 -0
  67. package/dist/esm/layout/tuplets.js +39 -0
  68. package/dist/esm/model/hiddenParts.d.ts +23 -0
  69. package/dist/esm/model/hiddenParts.js +39 -0
  70. package/dist/esm/model/locate.d.ts +18 -0
  71. package/dist/esm/model/locate.js +31 -0
  72. package/dist/esm/model/lowVoices.d.ts +9 -0
  73. package/dist/esm/model/lowVoices.js +20 -0
  74. package/dist/esm/model/partColors.d.ts +13 -0
  75. package/dist/esm/model/partColors.js +10 -0
  76. package/dist/esm/model/partSpan.d.ts +25 -0
  77. package/dist/esm/model/partSpan.js +49 -0
  78. package/dist/esm/model/rowPresence.d.ts +14 -0
  79. package/dist/esm/model/rowPresence.js +19 -0
  80. package/dist/esm/model/sharedLyrics.d.ts +23 -0
  81. package/dist/esm/model/sharedLyrics.js +68 -0
  82. package/dist/esm/model/textBars.d.ts +12 -0
  83. package/dist/esm/model/textBars.js +21 -0
  84. package/dist/esm/model/tickRanges.d.ts +22 -0
  85. package/dist/esm/model/tickRanges.js +34 -0
  86. package/dist/esm/model/unisons.d.ts +69 -0
  87. package/dist/esm/model/unisons.js +181 -0
  88. package/dist/esm/notation/chords.d.ts +12 -0
  89. package/dist/esm/notation/chords.js +29 -0
  90. package/dist/esm/notation/elision.d.ts +24 -0
  91. package/dist/esm/notation/elision.js +47 -0
  92. package/dist/esm/notation/keys.d.ts +50 -0
  93. package/dist/esm/notation/keys.js +59 -0
  94. package/dist/esm/notation/lyricAlign.d.ts +7 -0
  95. package/dist/esm/notation/lyricAlign.js +15 -0
  96. package/dist/esm/notation/navigation.d.ts +3 -0
  97. package/dist/esm/notation/navigation.js +5 -0
  98. package/dist/esm/notation/pitch.d.ts +39 -0
  99. package/dist/esm/notation/pitch.js +74 -0
  100. package/dist/esm/notation/pitchName.d.ts +2 -0
  101. package/dist/esm/notation/pitchName.js +3 -0
  102. package/dist/esm/notation/profile.d.ts +35 -0
  103. package/dist/esm/notation/profile.js +16 -0
  104. package/dist/esm/notation/rhythm.d.ts +59 -0
  105. package/dist/esm/notation/rhythm.js +116 -0
  106. package/dist/esm/notation/time.d.ts +98 -0
  107. package/dist/esm/notation/time.js +85 -0
  108. package/dist/esm/performance/compilePerformance.d.ts +7 -0
  109. package/dist/esm/performance/compilePerformance.js +8 -0
  110. package/dist/esm/performance/dynamics.d.ts +6 -0
  111. package/dist/esm/performance/dynamics.js +78 -0
  112. package/dist/esm/performance/model.d.ts +56 -0
  113. package/dist/esm/performance/model.js +1 -0
  114. package/dist/esm/performance/playOrder.d.ts +16 -0
  115. package/dist/esm/performance/playOrder.js +64 -0
  116. package/dist/esm/performance/readScore.d.ts +4 -0
  117. package/dist/esm/performance/readScore.js +58 -0
  118. package/dist/esm/performance/timeline.d.ts +10 -0
  119. package/dist/esm/performance/timeline.js +144 -0
  120. package/dist/esm/playback/audioOutput.d.ts +46 -0
  121. package/dist/esm/playback/audioOutput.js +106 -0
  122. package/dist/esm/playback/clock.d.ts +16 -0
  123. package/dist/esm/playback/clock.js +44 -0
  124. package/dist/esm/playback/createPlayerStore.d.ts +79 -0
  125. package/dist/esm/playback/createPlayerStore.js +135 -0
  126. package/dist/esm/playback/cues.d.ts +34 -0
  127. package/dist/esm/playback/cues.js +52 -0
  128. package/dist/esm/playback/errors.d.ts +6 -0
  129. package/dist/esm/playback/errors.js +6 -0
  130. package/dist/esm/playback/metronome.d.ts +13 -0
  131. package/dist/esm/playback/metronome.js +15 -0
  132. package/dist/esm/playback/mix.d.ts +9 -0
  133. package/dist/esm/playback/mix.js +8 -0
  134. package/dist/esm/playback/pass.d.ts +27 -0
  135. package/dist/esm/playback/pass.js +36 -0
  136. package/dist/esm/playback/schedule.d.ts +7 -0
  137. package/dist/esm/playback/schedule.js +12 -0
  138. package/dist/esm/playback/session.d.ts +46 -0
  139. package/dist/esm/playback/session.js +107 -0
  140. package/dist/esm/playback/source.d.ts +6 -0
  141. package/dist/esm/playback/source.js +1 -0
  142. package/dist/esm/playback/start.d.ts +28 -0
  143. package/dist/esm/playback/start.js +38 -0
  144. package/dist/esm/playback/timing.d.ts +14 -0
  145. package/dist/esm/playback/timing.js +11 -0
  146. package/dist/esm/playback/types.d.ts +60 -0
  147. package/dist/esm/playback/types.js +1 -0
  148. package/dist/esm/playback/volume.d.ts +12 -0
  149. package/dist/esm/playback/volume.js +8 -0
  150. package/dist/esm/player/ControlBar.d.ts +22 -0
  151. package/dist/esm/player/ControlBar.js +77 -0
  152. package/dist/esm/player/CursorPainter.d.ts +17 -0
  153. package/dist/esm/player/CursorPainter.js +53 -0
  154. package/dist/esm/player/InfoLine.d.ts +6 -0
  155. package/dist/esm/player/InfoLine.js +23 -0
  156. package/dist/esm/player/PageView.d.ts +10 -0
  157. package/dist/esm/player/PageView.js +16 -0
  158. package/dist/esm/player/actions.d.ts +24 -0
  159. package/dist/esm/player/actions.js +26 -0
  160. package/dist/esm/player/balanceSystems.d.ts +8 -0
  161. package/dist/esm/player/balanceSystems.js +18 -0
  162. package/dist/esm/player/createExcerptPlayer.d.ts +33 -0
  163. package/dist/esm/player/createExcerptPlayer.js +169 -0
  164. package/dist/esm/player/createScorePlayer.d.ts +24 -0
  165. package/dist/esm/player/createScorePlayer.js +118 -0
  166. package/dist/esm/player/dom.d.ts +6 -0
  167. package/dist/esm/player/dom.js +15 -0
  168. package/dist/esm/player/embeddedFonts.d.ts +1 -0
  169. package/dist/esm/player/embeddedFonts.js +3 -0
  170. package/dist/esm/player/exclusivePlayback.d.ts +10 -0
  171. package/dist/esm/player/exclusivePlayback.js +13 -0
  172. package/dist/esm/player/followCursor.d.ts +5 -0
  173. package/dist/esm/player/followCursor.js +16 -0
  174. package/dist/esm/player/icons.d.ts +7 -0
  175. package/dist/esm/player/icons.js +9 -0
  176. package/dist/esm/player/injectFonts.d.ts +8 -0
  177. package/dist/esm/player/injectFonts.js +19 -0
  178. package/dist/esm/player/loadExcerpt.d.ts +21 -0
  179. package/dist/esm/player/loadExcerpt.js +123 -0
  180. package/dist/esm/player/loadScore.d.ts +12 -0
  181. package/dist/esm/player/loadScore.js +12 -0
  182. package/dist/esm/player/mountExcerpts.d.ts +30 -0
  183. package/dist/esm/player/mountExcerpts.js +109 -0
  184. package/dist/esm/player/playhead.d.ts +12 -0
  185. package/dist/esm/player/playhead.js +14 -0
  186. package/dist/esm/player/shadowStyles.d.ts +5 -0
  187. package/dist/esm/player/shadowStyles.js +23 -0
  188. package/dist/esm/player/staticSvg.d.ts +7 -0
  189. package/dist/esm/player/staticSvg.js +10 -0
  190. package/dist/esm/player/styles.d.ts +28 -0
  191. package/dist/esm/player/styles.js +98 -0
  192. package/dist/esm/player/theme.d.ts +8 -0
  193. package/dist/esm/player/theme.js +13 -0
  194. package/dist/esm/player/types.d.ts +76 -0
  195. package/dist/esm/player/types.js +12 -0
  196. package/dist/esm/rendering/SystemRenderer.d.ts +6 -0
  197. package/dist/esm/rendering/SystemRenderer.js +58 -0
  198. package/dist/esm/rendering/accidentalRenderer.d.ts +4 -0
  199. package/dist/esm/rendering/accidentalRenderer.js +41 -0
  200. package/dist/esm/rendering/arcRenderer.d.ts +9 -0
  201. package/dist/esm/rendering/arcRenderer.js +32 -0
  202. package/dist/esm/rendering/barlineRenderer.d.ts +8 -0
  203. package/dist/esm/rendering/barlineRenderer.js +59 -0
  204. package/dist/esm/rendering/directionRenderer.d.ts +4 -0
  205. package/dist/esm/rendering/directionRenderer.js +50 -0
  206. package/dist/esm/rendering/durationLineRenderer.d.ts +9 -0
  207. package/dist/esm/rendering/durationLineRenderer.js +27 -0
  208. package/dist/esm/rendering/dynamicGlyphs.d.ts +25 -0
  209. package/dist/esm/rendering/dynamicGlyphs.js +56 -0
  210. package/dist/esm/rendering/frameRenderer.d.ts +17 -0
  211. package/dist/esm/rendering/frameRenderer.js +252 -0
  212. package/dist/esm/rendering/keyMarkRenderer.d.ts +8 -0
  213. package/dist/esm/rendering/keyMarkRenderer.js +57 -0
  214. package/dist/esm/rendering/lyricsRenderer.d.ts +4 -0
  215. package/dist/esm/rendering/lyricsRenderer.js +44 -0
  216. package/dist/esm/rendering/primitives.d.ts +64 -0
  217. package/dist/esm/rendering/primitives.js +1 -0
  218. package/dist/esm/rendering/sliceRenderer.d.ts +19 -0
  219. package/dist/esm/rendering/sliceRenderer.js +79 -0
  220. package/dist/esm/rendering/textBarRenderer.d.ts +8 -0
  221. package/dist/esm/rendering/textBarRenderer.js +28 -0
  222. package/dist/esm/rendering/tupletRenderer.d.ts +7 -0
  223. package/dist/esm/rendering/tupletRenderer.js +42 -0
  224. package/dist/esm/schema/normalize.d.ts +14 -0
  225. package/dist/esm/schema/normalize.js +123 -0
  226. package/dist/esm/schema/pageMeta.d.ts +11 -0
  227. package/dist/esm/schema/pageMeta.js +1 -0
  228. package/dist/esm/schema/scoreJson.d.ts +59 -0
  229. package/dist/esm/schema/scoreJson.js +1 -0
  230. package/dist/esm/schema/scoreView.d.ts +16 -0
  231. package/dist/esm/schema/scoreView.js +24 -0
  232. package/dist/esm/schema/types.d.ts +339 -0
  233. package/dist/esm/schema/types.js +1 -0
  234. package/dist/esm/text/creditLines.d.ts +12 -0
  235. package/dist/esm/text/creditLines.js +11 -0
  236. package/dist/esm/text/fonts.d.ts +50 -0
  237. package/dist/esm/text/fonts.js +98 -0
  238. package/dist/esm/text/headerFooter.d.ts +13 -0
  239. package/dist/esm/text/headerFooter.js +21 -0
  240. package/dist/esm/text/textLines.d.ts +7 -0
  241. package/dist/esm/text/textLines.js +13 -0
  242. package/dist/index.cjs +65 -0
  243. package/dist/index.cjs.map +1 -0
  244. package/dist/nodelyra-player.global.js +65 -0
  245. package/dist/nodelyra-player.global.js.map +1 -0
  246. package/dist/nodelyra-player.lite.global.js +63 -0
  247. package/dist/nodelyra-player.lite.global.js.map +1 -0
  248. package/examples/blog-excerpt.html +54 -0
  249. package/examples/twinkle.html +23 -0
  250. package/examples/twinkle.json +91 -0
  251. package/package.json +70 -4
@@ -0,0 +1,181 @@
1
+ import { plays } from "./partSpan.js";
2
+ import { coversRange as covers } from "./tickRanges.js";
3
+ /** A group as stored, or as an older list of part ids (the whole bar). */
4
+ const asUnison = (group) => Array.isArray(group) ? { parts: group, from: 0, to: null } : group;
5
+ /** The unison groups of a bar. */
6
+ export const unisonsOf = (measure) => (measure?.unisons ?? []).map((g) => asUnison(g));
7
+ /** Whether a group covers the whole bar (its lower parts then hold no notes). */
8
+ export const coversWholeBar = (group) => group.from === 0 && group.to === null;
9
+ /** Whether a group covers the ticks `from`..`to` of its bar (`to` null = to the bar's end). */
10
+ export const coversRange = (group, from, to) => covers(group, { from, to });
11
+ /** Whether the part sings another part's notes over the whole bar (it holds none there). */
12
+ export const follows = (measure, partId) => unisonsOf(measure).some((g) => coversWholeBar(g) && g.parts.slice(1).includes(partId));
13
+ /** Whether the part's notes at `tick` are hidden: it sings in the row of a part above it there. */
14
+ export const hiddenAt = (measure, partId, tick) => unisonsOf(measure).some((g) => g.parts.slice(1).includes(partId) && g.from <= tick && (g.to === null || tick < g.to));
15
+ /** Whether the part is merged into the row above over all of ticks `from`..`to` of the bar. */
16
+ export const mergedOver = (measure, partId, from, to) => unisonsOf(measure).some((g) => g.parts.slice(1).includes(partId) && coversRange(g, from, to));
17
+ /**
18
+ * The parts a part leads over every one of these pieces of bars (the same parts each time), or
19
+ * undefined. Only then does the system draw the group as one row with the joined abbreviations.
20
+ */
21
+ export function groupLedThroughout(pieces, partId) {
22
+ const led = (piece) => unisonsOf(piece.measure).find((g) => g.parts[0] === partId && coversRange(g, piece.from, piece.to))?.parts;
23
+ const first = pieces.length > 0 ? led(pieces[0]) : undefined;
24
+ if (!first)
25
+ return undefined;
26
+ return pieces.every((piece) => led(piece)?.join("+") === first.join("+")) ? first : undefined;
27
+ }
28
+ /** "S." + "A." = "SA.": the abbreviations without their full stops, joined, with one at the end. */
29
+ export function joinedLabel(parts) {
30
+ const bare = parts.map((p) => p.abbreviation.trim().replace(/\.$/, ""));
31
+ const dotted = parts.some((p) => p.abbreviation.trim().endsWith("."));
32
+ const joined = bare.join("");
33
+ return joined && dotted ? `${joined}.` : joined;
34
+ }
35
+ /** Every joined label the score uses (for the room the widest label needs). */
36
+ export function joinedLabels(music) {
37
+ const byId = new Map(music.parts.map((p) => [p.id, p]));
38
+ const labels = new Set(music.measures.flatMap((m) => unisonsOf(m).map((group) => joinedLabel(group.parts.flatMap((id) => byId.get(id) ?? [])))));
39
+ return [...labels];
40
+ }
41
+ /** What a part sings in a bar: its own notes, or its lead part's when it follows one over the whole bar. */
42
+ export function sungEvents(music, partIndex, measureIndex) {
43
+ const part = music.parts[partIndex];
44
+ const lead = unisonsOf(music.measures[measureIndex]).find((g) => coversWholeBar(g) && g.parts.slice(1).includes(part.id))?.parts[0];
45
+ const source = music.parts.find((p) => p.id === lead) ?? part;
46
+ return source.measures[measureIndex]?.events ?? [];
47
+ }
48
+ /** Each event with its start, in ticks from the bar's start. */
49
+ export const withOnsets = (events) => {
50
+ let tick = 0;
51
+ return events.map((event) => {
52
+ const placed = { onset: tick, event };
53
+ tick += event.duration;
54
+ return placed;
55
+ });
56
+ };
57
+ /** Where events start, and where the last one ends. */
58
+ export const edgesOf = (events) => new Set([...withOnsets(events).map((e) => e.onset), events.reduce((sum, e) => sum + e.duration, 0)]);
59
+ /** The events that start inside ticks `from`..`to` (null = to the end). */
60
+ export const eventsWithin = (events, from, to) => withOnsets(events)
61
+ .filter(({ onset }) => onset >= from && (to === null || onset < to))
62
+ .map(({ event }) => event);
63
+ /** What makes two events sound the same and look the same in the row: everything but ids, beams and lyrics. */
64
+ const noteOf = (event) => JSON.stringify([
65
+ event.type,
66
+ event.type === "note" ? event.degree : 0,
67
+ event.octave,
68
+ event.accidental,
69
+ event.duration,
70
+ event.tie,
71
+ event.tuplet ? `${event.tuplet.of}:${event.tuplet.in}` : null,
72
+ ]);
73
+ /** An event's syllables as text, hyphens, extenders and joins (not their placement); trailing empty verses dropped. */
74
+ const lyricsOf = (event) => {
75
+ const lyrics = event.lyrics.map((l) => (l && l.text.trim() !== "" ? [l.text, l.hyphen, l.extender, !!l.join] : null));
76
+ while (lyrics.length > 0 && lyrics[lyrics.length - 1] === null)
77
+ lyrics.pop();
78
+ return JSON.stringify(lyrics);
79
+ };
80
+ const NO_LYRICS = JSON.stringify([]);
81
+ /** Whether two runs of events hold the same notes (lyrics aside). */
82
+ export const sameNotes = (a, b) => a.length === b.length && a.every((event, i) => noteOf(event) === noteOf(b[i]));
83
+ /** Whether another part's syllables fit the lead's: none, or the same. Merged, the row shows the lead's. */
84
+ const lyricsFit = (lead, other) => other.every((event, i) => lyricsOf(event) === NO_LYRICS || lyricsOf(event) === lyricsOf(lead[i]));
85
+ /** Each part's events inside ticks `from`..`to`, or null when a part has no note edge at both ends. */
86
+ function runsWithin(bars, from, to) {
87
+ const edges = to === null ? [from] : [from, to];
88
+ if (!bars.every((events) => edges.every((tick) => edgesOf(events).has(tick))))
89
+ return null;
90
+ return bars.map((events) => eventsWithin(events, from, to));
91
+ }
92
+ /**
93
+ * Whether parts can merge over ticks `from`..`to`: notes that start and end on the range's edges,
94
+ * the same notes inside it, and the other parts' lyrics there empty or the same as the lead's.
95
+ */
96
+ export function canSingTogether(bars, from, to) {
97
+ const runs = runsWithin(bars, from, to);
98
+ return runs !== null && runs.every((run) => sameNotes(runs[0], run) && lyricsFit(runs[0], run));
99
+ }
100
+ /** Whether parts merged over part of a bar still sing the same notes there (lyrics follow the lead). */
101
+ function sameNotesOver(bars, from, to) {
102
+ const runs = runsWithin(bars, from, to);
103
+ return runs !== null && runs.every((run) => sameNotes(runs[0], run));
104
+ }
105
+ /** Whether the part indices are neighbours in score order (one after the other). */
106
+ export const neighbouring = (indices) => indices.every((index, i) => i === 0 || index === indices[i - 1] + 1);
107
+ /** Whether a stored group still holds (see the module comment). */
108
+ function holds(music, group, measureIndex) {
109
+ const indices = group.parts.map((id) => music.parts.findIndex((p) => p.id === id));
110
+ if (group.parts.length < 2 || indices.some((i) => i < 0) || !neighbouring(indices))
111
+ return false;
112
+ const parts = indices.map((i) => music.parts[i]);
113
+ if (!parts.every((p) => plays(music, p, measureIndex)))
114
+ return false;
115
+ const bars = parts.map((p) => p.measures[measureIndex]?.events ?? []);
116
+ if (coversWholeBar(group))
117
+ return bars.slice(1).every((events) => events.length === 0);
118
+ return sameNotesOver(bars, group.from, group.to);
119
+ }
120
+ /**
121
+ * The score without unison groups that no longer hold (a part was typed or pasted into, removed or
122
+ * moved, or a note inside a part-bar group changed in one part only). Returns the same score when
123
+ * every group holds.
124
+ */
125
+ export function keepValidUnisons(music) {
126
+ let changed = false;
127
+ const measures = music.measures.map((measure, measureIndex) => {
128
+ const groups = unisonsOf(measure);
129
+ const kept = groups.filter((group) => holds(music, group, measureIndex));
130
+ if (kept.length === groups.length)
131
+ return measure;
132
+ changed = true;
133
+ return { ...measure, unisons: kept };
134
+ });
135
+ return changed ? { ...music, measures } : music;
136
+ }
137
+ /** A bar's events with the lead's syllables on the ones inside a part-bar group of `partId`. */
138
+ function withLeadLyrics(music, measureIndex, part) {
139
+ const events = part.measures[measureIndex]?.events ?? [];
140
+ let next = events;
141
+ for (const group of unisonsOf(music.measures[measureIndex])) {
142
+ if (coversWholeBar(group) || !group.parts.slice(1).includes(part.id))
143
+ continue;
144
+ const lead = music.parts.find((p) => p.id === group.parts[0])?.measures[measureIndex]?.events ?? [];
145
+ const runs = runsWithin([lead, next], group.from, group.to);
146
+ if (!runs || !sameNotes(runs[0], runs[1]))
147
+ continue;
148
+ // The lead's event at the same place, for each of this part's events inside the range.
149
+ const leadEvent = new Map(runs[1].map((event, i) => [event.id, runs[0][i]]));
150
+ next = next.map((event) => {
151
+ const source = leadEvent.get(event.id);
152
+ if (!source || event.type !== "note" || lyricsOf(event) === lyricsOf(source))
153
+ return event;
154
+ return { ...event, lyrics: source.lyrics };
155
+ });
156
+ }
157
+ return next;
158
+ }
159
+ /**
160
+ * The score with the lower parts of part-bar groups singing the lead's syllables there (the row
161
+ * shows the lead's), so writing lyrics in the merged row never splits it. Returns the same score
162
+ * when nothing changes.
163
+ */
164
+ export function syncUnisonLyrics(music) {
165
+ let changed = false;
166
+ const parts = music.parts.map((part) => {
167
+ let partChanged = false;
168
+ const measures = part.measures.map((measure, measureIndex) => {
169
+ const events = withLeadLyrics(music, measureIndex, part);
170
+ if (events === measure.events)
171
+ return measure;
172
+ partChanged = true;
173
+ return { events };
174
+ });
175
+ if (!partChanged)
176
+ return part;
177
+ changed = true;
178
+ return { ...part, measures };
179
+ });
180
+ return changed ? { ...music, parts } : music;
181
+ }
@@ -0,0 +1,12 @@
1
+ import type { Chord } from "../schema/types.js";
2
+ /** A chord as typed, without its position: what the chord editor reads and writes. */
3
+ export type ChordSpelling = Omit<Chord, "at">;
4
+ /**
5
+ * Read a typed chord symbol ("C", "Am", "G/B", "Bbm7b5", "F#7", "Csus4", "E7/G#"), or null when
6
+ * it is not one. Spaces around it are ignored; the root letter may be lower case.
7
+ */
8
+ export declare function parseChord(text: string): ChordSpelling | null;
9
+ /** How a chord is written above the music: "G/B", "Bbm7b5". */
10
+ export declare const chordText: (chord: ChordSpelling) => string;
11
+ /** The bar's chord at `at`, if any. */
12
+ export declare const chordAt: (chords: readonly Chord[] | undefined, at: number) => Chord | undefined;
@@ -0,0 +1,29 @@
1
+ const NOTE = "([A-Ga-g])([#b♯♭]?)";
2
+ /** Root, quality as written (no "/"), optional "/bass". Same quality rule as the backend. */
3
+ const CHORD_PATTERN = new RegExp(`^${NOTE}([A-Za-z0-9#+()\\-]{0,12})(?:/${NOTE})?$`);
4
+ const ACCIDENTALS = { "": null, "#": "sharp", "♯": "sharp", b: "flat", "♭": "flat" };
5
+ const ACCIDENTAL_TEXT = { sharp: "#", flat: "b" };
6
+ const noteOf = (letter, accidental) => ({
7
+ root: letter.toUpperCase(),
8
+ accidental: ACCIDENTALS[accidental],
9
+ });
10
+ /**
11
+ * Read a typed chord symbol ("C", "Am", "G/B", "Bbm7b5", "F#7", "Csus4", "E7/G#"), or null when
12
+ * it is not one. Spaces around it are ignored; the root letter may be lower case.
13
+ */
14
+ export function parseChord(text) {
15
+ const match = CHORD_PATTERN.exec(text.trim().replace(/\s+/g, ""));
16
+ if (!match)
17
+ return null;
18
+ const [, letter, accidental, quality, bassLetter, bassAccidental] = match;
19
+ return {
20
+ ...noteOf(letter, accidental),
21
+ quality,
22
+ bass: bassLetter ? noteOf(bassLetter, bassAccidental ?? "") : null,
23
+ };
24
+ }
25
+ const noteText = ({ root, accidental }) => `${root}${accidental ? ACCIDENTAL_TEXT[accidental] : ""}`;
26
+ /** How a chord is written above the music: "G/B", "Bbm7b5". */
27
+ export const chordText = (chord) => `${noteText(chord)}${chord.quality}${chord.bass ? `/${noteText(chord.bass)}` : ""}`;
28
+ /** The bar's chord at `at`, if any. */
29
+ export const chordAt = (chords, at) => chords?.find((c) => c.at === at);
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Elisions in lyric text: letters sung as one sound inside a syllable ("li‿a" = "lia" in one
3
+ * note) are written with an undertie between them, drawn as a small arc under those letters.
4
+ * The undertie is stored in the syllable text; "~" types one.
5
+ */
6
+ export declare const ELISION = "\u203F";
7
+ /** Typed text with each "~" written as the undertie. */
8
+ export declare const withElisions: (text: string) => string;
9
+ /** Letters joined by undertie(s): first and last index in the text without the marks. */
10
+ export type ElisionSpan = {
11
+ from: number;
12
+ to: number;
13
+ };
14
+ /** The syllable as it is drawn (no undertie marks) and the letter runs to draw an arc under. */
15
+ export declare function readElisions(text: string): {
16
+ plain: string;
17
+ spans: ElisionSpan[];
18
+ };
19
+ /** Text without undertie marks (what is drawn and measured). */
20
+ export declare const withoutElisions: (text: string) => string;
21
+ /** The gaps (between letter k and k + 1 of the plain text) that carry an undertie. */
22
+ export declare function elisionGaps(text: string): Set<number>;
23
+ /** The syllable with the undertie between letters `gap` and `gap + 1` added or taken away. */
24
+ export declare function toggleElisionGap(text: string, gap: number): string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Elisions in lyric text: letters sung as one sound inside a syllable ("li‿a" = "lia" in one
3
+ * note) are written with an undertie between them, drawn as a small arc under those letters.
4
+ * The undertie is stored in the syllable text; "~" types one.
5
+ */
6
+ export const ELISION = "‿";
7
+ /** Typed text with each "~" written as the undertie. */
8
+ export const withElisions = (text) => text.replaceAll("~", ELISION);
9
+ /** The syllable as it is drawn (no undertie marks) and the letter runs to draw an arc under. */
10
+ export function readElisions(text) {
11
+ let plain = "";
12
+ const spans = [];
13
+ for (const ch of text) {
14
+ if (ch !== ELISION) {
15
+ plain += ch;
16
+ continue;
17
+ }
18
+ if (!plain)
19
+ continue; // nothing before it to join
20
+ const last = spans.at(-1);
21
+ if (last && last.to === plain.length - 1)
22
+ last.to = plain.length; // "a‿e‿u": one arc
23
+ else
24
+ spans.push({ from: plain.length - 1, to: plain.length });
25
+ }
26
+ return { plain, spans: spans.filter((s) => s.to < plain.length) };
27
+ }
28
+ /** Text without undertie marks (what is drawn and measured). */
29
+ export const withoutElisions = (text) => text.replaceAll(ELISION, "");
30
+ /** The gaps (between letter k and k + 1 of the plain text) that carry an undertie. */
31
+ export function elisionGaps(text) {
32
+ const gaps = new Set();
33
+ for (const { from, to } of readElisions(text).spans)
34
+ for (let k = from; k < to; k++)
35
+ gaps.add(k);
36
+ return gaps;
37
+ }
38
+ /** The syllable with the undertie between letters `gap` and `gap + 1` added or taken away. */
39
+ export function toggleElisionGap(text, gap) {
40
+ const { plain } = readElisions(text);
41
+ const gaps = elisionGaps(text);
42
+ if (gaps.has(gap))
43
+ gaps.delete(gap);
44
+ else
45
+ gaps.add(gap);
46
+ return [...plain].map((ch, k) => (gaps.has(k) ? ch + ELISION : ch)).join("");
47
+ }
@@ -0,0 +1,50 @@
1
+ import type { ScoreMeasure } from "../schema/types.js";
2
+ import { type Spelling } from "./pitch.js";
3
+ /**
4
+ * Key changes (ADR 0010): a measure's `key` sets "1 =" from that bar on, until the next change,
5
+ * as `time` does for the meter. It may take over partway through the bar, at `key_at` (ADR 0017).
6
+ * Digits are always read in the key in force where they start.
7
+ */
8
+ /** What the key rules read of a measure. */
9
+ type KeyedMeasure = {
10
+ key?: string | null;
11
+ key_at?: number;
12
+ };
13
+ /** Every key a score may be in, in chromatic order (the backend's `KEYS`). */
14
+ export declare const KEYS: readonly string[];
15
+ /** Whether the score settings allow this key (the backend's `KEYS`). */
16
+ export declare const isKey: (key: string) => boolean;
17
+ /**
18
+ * The key in force in every measure from its change on (its end): a measure's own `key` holds
19
+ * until the next change. Before a change partway through a bar (`key_at`) the old key goes on.
20
+ */
21
+ export declare function keysOf(measures: readonly KeyedMeasure[], scoreKey: string): string[];
22
+ /** Where a measure's key change takes over: ticks from the bar's start (0 = the whole bar). */
23
+ export declare const keyChangeAt: (measure: KeyedMeasure) => number;
24
+ /**
25
+ * The key a note starting `tick` ticks into bar `index` is read in: the bar's new key from its
26
+ * `key_at` on, the key before the bar until then.
27
+ */
28
+ export declare function keyReader(measures: readonly KeyedMeasure[], scoreKey: string): (index: number, tick: number) => string;
29
+ /** A change of key written at a bar: the key before it, the key from it on, and where it takes over. */
30
+ export type KeyChange = {
31
+ from: string;
32
+ to: string;
33
+ at: number;
34
+ };
35
+ /**
36
+ * The key change at each measure, or null where the key goes on. A change at the start of the
37
+ * first bar is the score's key (the title block shows it), so it is not one; partway through the
38
+ * first bar it is.
39
+ */
40
+ export declare function keyChanges(measures: readonly KeyedMeasure[], scoreKey: string): (KeyChange | null)[];
41
+ /** The same sounding pitch written in another key (5 in D is 3 in F). */
42
+ export declare const respell: (note: Spelling, from: string, to: string) => Spelling;
43
+ /**
44
+ * The fields to change for a bar's key change to take over `at` ticks into the bar (0 = from its
45
+ * start). Partway through, the bar also goes on to the next line there (`split_at`), so the
46
+ * new key opens that line with "1 =" and its box (ADR 0017). Back at the start, a line break that
47
+ * went with the old place is taken away; any other split of the bar is left as it is.
48
+ */
49
+ export declare function keyStartPatch(measure: Pick<ScoreMeasure, "key_at" | "split_at">, at: number): Pick<ScoreMeasure, "key_at" | "split_at">;
50
+ export {};
@@ -0,0 +1,59 @@
1
+ import { fromMidi, KEY_PITCH_CLASS, toMidi } from "./pitch.js";
2
+ /** Every key a score may be in, in chromatic order (the backend's `KEYS`). */
3
+ export const KEYS = Object.keys(KEY_PITCH_CLASS);
4
+ /** Whether the score settings allow this key (the backend's `KEYS`). */
5
+ export const isKey = (key) => key in KEY_PITCH_CLASS;
6
+ /**
7
+ * The key in force in every measure from its change on (its end): a measure's own `key` holds
8
+ * until the next change. Before a change partway through a bar (`key_at`) the old key goes on.
9
+ */
10
+ export function keysOf(measures, scoreKey) {
11
+ let current = scoreKey;
12
+ return measures.map((m) => {
13
+ if (m.key && isKey(m.key))
14
+ current = m.key;
15
+ return current;
16
+ });
17
+ }
18
+ /** Where a measure's key change takes over: ticks from the bar's start (0 = the whole bar). */
19
+ export const keyChangeAt = (measure) => Math.max(0, measure.key_at ?? 0);
20
+ /**
21
+ * The key a note starting `tick` ticks into bar `index` is read in: the bar's new key from its
22
+ * `key_at` on, the key before the bar until then.
23
+ */
24
+ export function keyReader(measures, scoreKey) {
25
+ const keys = keysOf(measures, scoreKey);
26
+ return (index, tick) => {
27
+ const before = index === 0 ? scoreKey : (keys[index - 1] ?? scoreKey);
28
+ const measure = measures[index];
29
+ return measure && tick >= keyChangeAt(measure) ? (keys[index] ?? before) : before;
30
+ };
31
+ }
32
+ /**
33
+ * The key change at each measure, or null where the key goes on. A change at the start of the
34
+ * first bar is the score's key (the title block shows it), so it is not one; partway through the
35
+ * first bar it is.
36
+ */
37
+ export function keyChanges(measures, scoreKey) {
38
+ const keys = keysOf(measures, scoreKey);
39
+ return keys.map((to, i) => {
40
+ const from = i === 0 ? scoreKey : keys[i - 1];
41
+ const at = keyChangeAt(measures[i]);
42
+ return (i > 0 || at > 0) && to !== from ? { from, to, at } : null;
43
+ });
44
+ }
45
+ /** The same sounding pitch written in another key (5 in D is 3 in F). */
46
+ export const respell = (note, from, to) => fromMidi(toMidi(note, from), to);
47
+ /**
48
+ * The fields to change for a bar's key change to take over `at` ticks into the bar (0 = from its
49
+ * start). Partway through, the bar also goes on to the next line there (`split_at`), so the
50
+ * new key opens that line with "1 =" and its box (ADR 0017). Back at the start, a line break that
51
+ * went with the old place is taken away; any other split of the bar is left as it is.
52
+ */
53
+ export function keyStartPatch(measure, at) {
54
+ if (at > 0)
55
+ return { key_at: at, split_at: at };
56
+ const previous = keyChangeAt(measure);
57
+ const wentWithChange = previous > 0 && measure.split_at === previous;
58
+ return { key_at: 0, split_at: wentWithChange ? null : (measure.split_at ?? null) };
59
+ }
@@ -0,0 +1,7 @@
1
+ import type { Lyric, LyricAlign } from "../schema/types.js";
2
+ /** A syllable's alignment under its note; syllables saved without one are centred. */
3
+ export declare const lyricAlign: (lyric: Pick<Lyric, "align">) => LyricAlign;
4
+ /** The syllable with a new alignment. Centred is the default, so it is stored as no `align`. */
5
+ export declare function withLyricAlign(lyric: Lyric, align: LyricAlign): Lyric;
6
+ /** The alignment the given syllables share, or null when there are none or they differ. */
7
+ export declare function sharedLyricAlign(lyrics: readonly (Lyric | null)[]): LyricAlign | null;
@@ -0,0 +1,15 @@
1
+ /** A syllable's alignment under its note; syllables saved without one are centred. */
2
+ export const lyricAlign = (lyric) => lyric.align ?? "center";
3
+ /** The syllable with a new alignment. Centred is the default, so it is stored as no `align`. */
4
+ export function withLyricAlign(lyric, align) {
5
+ if (align !== "center")
6
+ return { ...lyric, align };
7
+ const centred = { ...lyric };
8
+ delete centred.align;
9
+ return centred;
10
+ }
11
+ /** The alignment the given syllables share, or null when there are none or they differ. */
12
+ export function sharedLyricAlign(lyrics) {
13
+ const aligns = new Set(lyrics.flatMap((l) => (l ? [lyricAlign(l)] : [])));
14
+ return aligns.size === 1 ? [...aligns][0] : null;
15
+ }
@@ -0,0 +1,3 @@
1
+ import type { Navigation } from "../schema/types.js";
2
+ /** What each jump mark says above its bar (musical terms, the same in every language). */
3
+ export declare const NAVIGATION_TEXT: Record<Navigation, string>;
@@ -0,0 +1,5 @@
1
+ /** What each jump mark says above its bar (musical terms, the same in every language). */
2
+ export const NAVIGATION_TEXT = {
3
+ fine: "Fine",
4
+ dc_al_fine: "D.C. al Fine",
5
+ };
@@ -0,0 +1,39 @@
1
+ import type { Accidental, Degree } from "../schema/types.js";
2
+ /**
3
+ * Numbered pitch <-> absolute pitch. A score stores the key-relative spelling the user writes
4
+ * (degree, octave, accidental); the sounding pitch is derived from the key here.
5
+ *
6
+ * This is a client-side mirror, not the authority: `backend/apps/notation/pitch.py` (`to_midi`)
7
+ * is authoritative for anything that affects persistence or playback, because the backend cannot
8
+ * trust client-computed pitch (root CLAUDE.md §2). This copy exists only so note entry stays
9
+ * instant and undoable without a round trip per keystroke (§7.2 "ordinary editor operations
10
+ * responsive"). `docs/fixtures/pitch-cases.json` is a shared parity fixture both sides' tests run
11
+ * the same cases through; keep `toMidi` in step with `to_midi` or that test fails here.
12
+ *
13
+ * `1` is the tonic in the octave starting at middle C (C4 = 60).
14
+ */
15
+ export type Spelling = {
16
+ degree: Degree;
17
+ octave: number;
18
+ accidental: Accidental | null;
19
+ };
20
+ /** Pitch class of every key the score settings allow (same list as the backend `KEYS`). */
21
+ export declare const KEY_PITCH_CLASS: Record<string, number>;
22
+ /** MIDI note number of middle C (C4). */
23
+ export declare const MIDDLE_C = 60;
24
+ /** MIDI note number of a written note in `key` (unknown keys are read as C). */
25
+ export declare function toMidi(note: Spelling, key: string): number;
26
+ /** How numbered notation writes a pitch: as spelled, or the usual way for the notes above. */
27
+ export declare function preferredSpelling(spelling: Spelling): Spelling;
28
+ /**
29
+ * The spelling with `accidental` that `written` is the preferred way of writing, or null: ♯1 is
30
+ * how a ♭2 is written, so `spelledWith(♯1, "flat")` is ♭2. Lets a toggle take a ♭ off a ♯1.
31
+ */
32
+ export declare function spelledWith(written: Spelling, accidental: Accidental): Spelling | null;
33
+ /**
34
+ * The spelling of a MIDI note in `key`: a scale note when it is one, otherwise the degree below
35
+ * raised by a sharp, written the preferred way (♭7, not ♯6). MIDI import may offer other flats.
36
+ */
37
+ export declare function fromMidi(midi: number, key: string): Spelling;
38
+ /** The scale degree (1..7) a MIDI note is in `key`, or null when it is not a scale note. */
39
+ export declare function scaleDegreeOf(midi: number, key: string): Degree | null;
@@ -0,0 +1,74 @@
1
+ /** Semitones above the tonic for degrees 1..7 of the major scale. */
2
+ const MAJOR_STEPS = [0, 2, 4, 5, 7, 9, 11];
3
+ const ACCIDENTAL_SHIFT = { sharp: 1, flat: -1 };
4
+ /** Pitch class of every key the score settings allow (same list as the backend `KEYS`). */
5
+ export const KEY_PITCH_CLASS = {
6
+ C: 0,
7
+ "C#": 1,
8
+ D: 2,
9
+ Eb: 3,
10
+ E: 4,
11
+ F: 5,
12
+ "F#": 6,
13
+ G: 7,
14
+ Ab: 8,
15
+ A: 9,
16
+ Bb: 10,
17
+ B: 11,
18
+ };
19
+ /** MIDI note number of middle C (C4). */
20
+ export const MIDDLE_C = 60;
21
+ /** MIDI note number of a written note in `key` (unknown keys are read as C). */
22
+ export function toMidi(note, key) {
23
+ const tonic = MIDDLE_C + (KEY_PITCH_CLASS[key] ?? 0);
24
+ const accidental = note.accidental ? ACCIDENTAL_SHIFT[note.accidental] : 0;
25
+ return tonic + MAJOR_STEPS[note.degree - 1] + accidental + 12 * note.octave;
26
+ }
27
+ /**
28
+ * Chromatic notes numbered notation writes the other way round (each the same pitch, in the same
29
+ * octave): ♭2 as ♯1, ♭5 as ♯4, ♭6 as ♯5, and ♯6 as ♭7. Between 2 and 3 either is fine.
30
+ */
31
+ const PREFERRED = {
32
+ "2:flat": { degree: 1, accidental: "sharp" },
33
+ "5:flat": { degree: 4, accidental: "sharp" },
34
+ "6:flat": { degree: 5, accidental: "sharp" },
35
+ "6:sharp": { degree: 7, accidental: "flat" },
36
+ };
37
+ /** How numbered notation writes a pitch: as spelled, or the usual way for the notes above. */
38
+ export function preferredSpelling(spelling) {
39
+ const preferred = spelling.accidental && PREFERRED[`${spelling.degree}:${spelling.accidental}`];
40
+ return preferred ? { ...preferred, octave: spelling.octave } : spelling;
41
+ }
42
+ /**
43
+ * The spelling with `accidental` that `written` is the preferred way of writing, or null: ♯1 is
44
+ * how a ♭2 is written, so `spelledWith(♯1, "flat")` is ♭2. Lets a toggle take a ♭ off a ♯1.
45
+ */
46
+ export function spelledWith(written, accidental) {
47
+ for (const [from, to] of Object.entries(PREFERRED)) {
48
+ const [degree, spelled] = from.split(":");
49
+ if (spelled === accidental && to.degree === written.degree && to.accidental === written.accidental)
50
+ return { degree: Number(degree), octave: written.octave, accidental };
51
+ }
52
+ return null;
53
+ }
54
+ /**
55
+ * The spelling of a MIDI note in `key`: a scale note when it is one, otherwise the degree below
56
+ * raised by a sharp, written the preferred way (♭7, not ♯6). MIDI import may offer other flats.
57
+ */
58
+ export function fromMidi(midi, key) {
59
+ const tonic = MIDDLE_C + (KEY_PITCH_CLASS[key] ?? 0);
60
+ const offset = midi - tonic;
61
+ const octave = Math.floor(offset / 12);
62
+ const step = offset - octave * 12;
63
+ const exact = MAJOR_STEPS.indexOf(step);
64
+ if (exact >= 0)
65
+ return { degree: (exact + 1), octave, accidental: null };
66
+ const below = MAJOR_STEPS.indexOf((step - 1));
67
+ return preferredSpelling({ degree: (below + 1), octave, accidental: "sharp" });
68
+ }
69
+ /** The scale degree (1..7) a MIDI note is in `key`, or null when it is not a scale note. */
70
+ export function scaleDegreeOf(midi, key) {
71
+ const step = (((midi - (KEY_PITCH_CLASS[key] ?? 0)) % 12) + 12) % 12;
72
+ const index = MAJOR_STEPS.indexOf(step);
73
+ return index >= 0 ? (index + 1) : null;
74
+ }
@@ -0,0 +1,2 @@
1
+ /** A MIDI note number as a pitch name with its octave (60 -> "C4"). */
2
+ export declare const pitchName: (midi: number) => string;
@@ -0,0 +1,3 @@
1
+ const NAMES = ["C", "C♯", "D", "E♭", "E", "F", "F♯", "G", "A♭", "A", "B♭", "B"];
2
+ /** A MIDI note number as a pitch name with its octave (60 -> "C4"). */
3
+ export const pitchName = (midi) => `${NAMES[((midi % 12) + 12) % 12]}${Math.floor(midi / 12) - 1}`;
@@ -0,0 +1,35 @@
1
+ import type { Accidental } from "../schema/types.js";
2
+ /**
3
+ * How a numbered-notation tradition draws musical meaning (root CLAUDE.md §5.5). The score keeps
4
+ * only meaning; layout and renderers read every convention from a profile, never from
5
+ * `if (notAngka)` branches. Only Not Angka exists today; Jianpu becomes a second object.
6
+ */
7
+ /**
8
+ * How an accidental is written: a stroke through the digit (Not Angka: `/` raises, `\` lowers)
9
+ * or a glyph before it (Jianpu style: ♯, ♭). A new way is a new kind with its own renderer.
10
+ */
11
+ export type AccidentalMark = {
12
+ kind: "stroke";
13
+ direction: "rising" | "falling";
14
+ } | {
15
+ kind: "glyph";
16
+ text: string;
17
+ };
18
+ export type NotationProfile = {
19
+ id: "not_angka";
20
+ /** What a rest is written as. */
21
+ restGlyph: string;
22
+ /** What fills a beat (or part of one) during which the previous note keeps sounding. */
23
+ continuationGlyph: string;
24
+ accidentals: Record<Accidental, AccidentalMark>;
25
+ /** Where duration lines (the numbered-notation beams) go relative to the digits. */
26
+ durationLines: "above" | "below";
27
+ /** Where ties and slurs curve. */
28
+ arcs: "above" | "below";
29
+ };
30
+ /**
31
+ * Indonesian Not Angka as in the reference score (Datanglah Tuhan): duration lines above the
32
+ * digits, a dot for a held beat, octave dots above/below, ties and slurs under the notes. A
33
+ * sharp is a slash through the digit, a flat a backslash.
34
+ */
35
+ export declare const NOT_ANGKA: NotationProfile;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Indonesian Not Angka as in the reference score (Datanglah Tuhan): duration lines above the
3
+ * digits, a dot for a held beat, octave dots above/below, ties and slurs under the notes. A
4
+ * sharp is a slash through the digit, a flat a backslash.
5
+ */
6
+ export const NOT_ANGKA = {
7
+ id: "not_angka",
8
+ restGlyph: "0",
9
+ continuationGlyph: ".",
10
+ accidentals: {
11
+ sharp: { kind: "stroke", direction: "rising" },
12
+ flat: { kind: "stroke", direction: "falling" },
13
+ },
14
+ durationLines: "above",
15
+ arcs: "below",
16
+ };