@dsebastien/music-notation 0.10.1 → 0.12.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.
@@ -18,6 +18,41 @@ export declare function parseHand(text: string): Hand;
18
18
  export declare function layoutDefaults(value: unknown): LayoutDefaults;
19
19
  /** Width a title needs (14px semi-bold), so a narrow diagram doesn't clip it. Errs on the wide side. */
20
20
  export declare function titleWidth(title?: string): number;
21
+ /** Most lines a diagram's title takes (#74); a longer title squeezes its last line. */
22
+ export declare const MAX_TITLE_LINES = 3;
23
+ /** Distance between two lines of a title. */
24
+ export declare const TITLE_LINE = 17;
25
+ export interface TitleLine {
26
+ text: string;
27
+ /** Set when the line is wider than the diagram even alone: squeeze it to this length. */
28
+ textLength: number | null;
29
+ }
30
+ /**
31
+ * The width of a line of a title at 14px semibold, closer than `titleWidth` (spaces and punctuation
32
+ * are narrow), with the same 8 of padding; for line breaks (#74).
33
+ */
34
+ export declare function titleLineWidth(text: string): number;
35
+ /**
36
+ * A title's lines on a diagram `width` units wide (#74): the title never widens the diagram. It
37
+ * stays on one line when it fits (`titleLineWidth`); else it wraps into lines that fit, at most
38
+ * `MAX_TITLE_LINES`, breaking first after a comma or before a parenthesis, then at spaces; a word
39
+ * wider than the diagram, or the rest of a title that needs more lines, is squeezed (`textLength`,
40
+ * the padding left out).
41
+ */
42
+ export declare function titleLines(title: string, width: number): TitleLine[];
43
+ /**
44
+ * Draws a diagram's title centered at `x`, its first baseline at `y` (#74): one `<text class=
45
+ * "mn-title">`, a `<tspan>` per line when it wraps (lines after the first start with a space, so
46
+ * the text reads as the title). Sets `data-mn-title-lines` on `root` for `alignTitleLines`.
47
+ */
48
+ export declare function drawTitle(doc: Document, root: Element, lines: TitleLine[], x: number, y: number): Element;
49
+ /**
50
+ * Gives every diagram of a set the room of the set's longest title (#74), so their necks line up
51
+ * in a row: a diagram whose title takes fewer lines moves down by the missing lines (its content
52
+ * in a `<g class="mn-title-pad">`, its viewBox and height grown). Diagrams without
53
+ * `data-mn-title-lines` (no title) count as one line when another one has a title.
54
+ */
55
+ export declare function alignTitleLines(diagrams: Iterable<Element>): void;
21
56
  export interface NeckLayout {
22
57
  orientation: Orientation;
23
58
  hand: Hand;
@@ -36,6 +36,8 @@ export interface StrumEventOptions {
36
36
  tail?: number;
37
37
  /** Varies the small differences between strums from pass to pass (the pass's number). */
38
38
  seed?: number;
39
+ /** The most time between a strum's strings, in seconds: 0.012 by default (0 a block). */
40
+ spread?: number;
39
41
  }
40
42
  /**
41
43
  * MIDI velocities: a down strum (`normal`), an up strum, an accent, a ghost strum, a muted one
@@ -106,6 +108,17 @@ export interface StrumFollower {
106
108
  heard(): void;
107
109
  stop(): void;
108
110
  }
111
+ /** One pass of a piece played in time: its notes, its length in seconds, and what to light. */
112
+ export interface Pass {
113
+ events: NoteEvent[];
114
+ /** Seconds until the next pass starts when it loops (the last note's ring not counted). */
115
+ length: number;
116
+ strums: StrumTiming[];
117
+ /** When each bar starts and how long it lasts (`slot` is the bar's index), when known. */
118
+ bars?: StrumTiming[];
119
+ }
120
+ /** What each pass is made from: the settings read at that pass, the first pass or not, its number. */
121
+ export type PassMaker = (settings: StrumSettings, first: boolean, id: number) => Pass;
109
122
  /**
110
123
  * Plays a score through `player`, pass after pass while `settings().loop` is on. Each next pass
111
124
  * is started on a timer at the exact end of the previous one, counted from the first pass's start
@@ -117,6 +130,11 @@ export interface StrumFollower {
117
130
  * them from the moment they sound.
118
131
  */
119
132
  export declare function runStrum(score: StrumScore, player: () => NotePlayer, settings: () => StrumSettings, timers: Pick<Window, 'setTimeout' | 'clearTimeout'>, onEnd?: () => void, follow?: (strums: StrumTiming[], player: NotePlayer) => StrumFollower): PlayHandle;
133
+ /**
134
+ * Plays the passes `make` returns, as `runStrum` plays a strumming pattern's (see there): the
135
+ * timing of progressions (#46) and picking patterns (#51) too.
136
+ */
137
+ export declare function runPasses(make: PassMaker, player: () => NotePlayer, settings: () => StrumSettings, timers: Pick<Window, 'setTimeout' | 'clearTimeout'>, onEnd?: () => void, follow?: (strums: StrumTiming[], player: NotePlayer, pass: Pass) => StrumFollower): PlayHandle;
120
138
  export interface PlayStrumOptions {
121
139
  /** Beats a minute: the pattern's `tempo:`, else 90 (60 dotted quarters in compound time). */
122
140
  bpm?: number;
@@ -108,6 +108,11 @@ export interface TabResult {
108
108
  }>;
109
109
  /** The alphaTab API, for exports and playback. */
110
110
  api: AT.AlphaTabApi | null;
111
+ /**
112
+ * The speed set on the player bar (0.25 to 1.5; 1 without a bar). alphaTab's `playbackSpeed`
113
+ * takes it only once the player starts (the first Play), so an app reads it here.
114
+ */
115
+ speed(): number;
111
116
  destroy(): void;
112
117
  }
113
118
  /**
package/dist/tab/index.js CHANGED
@@ -1721,6 +1721,7 @@ function playerBar(doc, api, alphaTab, assets) {
1721
1721
  });
1722
1722
  return {
1723
1723
  bar,
1724
+ speed: () => state.speed,
1724
1725
  failed: (message) => {
1725
1726
  cantStart?.();
1726
1727
  play.disabled = true;
@@ -1783,6 +1784,7 @@ function renderTab(language, source, host, options) {
1783
1784
  const el = html(doc, "div", `mn-block mn-block-${language} mn-tab`);
1784
1785
  host.appendChild(el);
1785
1786
  let api = null;
1787
+ let speedOf = () => 1;
1786
1788
  let gone = false;
1787
1789
  let settled = false;
1788
1790
  let settle = () => {};
@@ -1854,6 +1856,7 @@ function renderTab(language, source, host, options) {
1854
1856
  return;
1855
1857
  if (options.player !== false) {
1856
1858
  bar = playerBar(doc, current, at, assets);
1859
+ speedOf = bar.speed;
1857
1860
  el.appendChild(bar.bar);
1858
1861
  if (options.views !== false && tablature)
1859
1862
  bar.bar.appendChild(viewControl(doc, own, (staves) => {
@@ -1910,6 +1913,7 @@ function renderTab(language, source, host, options) {
1910
1913
  get api() {
1911
1914
  return api;
1912
1915
  },
1916
+ speed: () => speedOf(),
1913
1917
  destroy() {
1914
1918
  gone = true;
1915
1919
  try {
@@ -2086,5 +2090,5 @@ export {
2086
2090
  textTabToAlphaTex
2087
2091
  };
2088
2092
 
2089
- //# debugId=7EA581924096D5C364756E2164756E21
2093
+ //# debugId=2EE54AC69188D00D64756E2164756E21
2090
2094
  //# sourceMappingURL=index.js.map