@dsebastien/music-notation 0.24.0 → 0.26.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.
- package/README.md +3 -2
- package/dist/chord/simplify.d.ts +56 -0
- package/dist/chords/chart.d.ts +55 -3
- package/dist/chords/chordpro.d.ts +4 -0
- package/dist/chords/easier.d.ts +39 -0
- package/dist/i18n/en/index.d.ts +10 -0
- package/dist/i18n/en/parse.d.ts +2 -0
- package/dist/i18n/en/play.d.ts +8 -0
- package/dist/i18n/fr/parse.d.ts +2 -0
- package/dist/i18n/fr/play.d.ts +8 -0
- package/dist/i18n/language.d.ts +11 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +739 -35
- package/dist/index.js.map +20 -16
- package/dist/music-notation.publish.min.js +35 -35
- package/dist/music-notation.tab.min.js +7 -7
- package/dist/playback/controls.d.ts +32 -1
- package/dist/playback/effects.d.ts +142 -0
- package/dist/playback/guitar-tone.d.ts +10 -2
- package/dist/playback/player.d.ts +14 -0
- package/dist/playback/progression-bar.d.ts +6 -1
- package/dist/playback/sound-menu.d.ts +21 -0
- package/dist/publish/index.js +727 -31
- package/dist/publish/index.js.map +19 -15
- package/dist/tab/index.d.ts +7 -0
- package/dist/tab/index.js +488 -1
- package/dist/tab/index.js.map +11 -9
- package/dist/tab/room.d.ts +45 -0
- package/dist/voicings/index.js +21 -1
- package/dist/voicings/index.js.map +6 -6
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import type { Hand } from '../render/layout.js';
|
|
|
3
3
|
import { type NotePlayer, type PlayKind, type Sound } from './player.js';
|
|
4
4
|
import { type Engine } from './engine.js';
|
|
5
5
|
import { type GuitarTone } from './guitar-tone.js';
|
|
6
|
+
import { type AmpOptions, type PlayEffects } from './effects.js';
|
|
6
7
|
export interface PlayOptions {
|
|
7
8
|
/**
|
|
8
9
|
* The language of the bars' texts and of the diagrams they redraw (#136): `'en'` or `'fr'`.
|
|
@@ -33,6 +34,27 @@ export interface PlayOptions {
|
|
|
33
34
|
* changed in the app is heard at the next Play. A block's `guitar:` line comes first.
|
|
34
35
|
*/
|
|
35
36
|
guitar?: GuitarTone | (() => GuitarTone | null | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* The room's level (#103), 0 (none) to 1: every block plays in a small room, light by default
|
|
39
|
+
* (0.125, the room 18 dB under the notes). A function is read at each play, so a setting changed in the app is heard at the
|
|
40
|
+
* next Play. The level is the page's: the last play sets it for everything that sounds.
|
|
41
|
+
*/
|
|
42
|
+
reverb?: number | (() => number | null | undefined);
|
|
43
|
+
/**
|
|
44
|
+
* How long the room rings (#103), in seconds, 0.2 (a small room) to 3 (a hall); 1.2 by
|
|
45
|
+
* default. A function is read at each play. Like the level, it is the page's.
|
|
46
|
+
*/
|
|
47
|
+
room?: number | (() => number | null | undefined);
|
|
48
|
+
/**
|
|
49
|
+
* No room and no ceiling (#103): the notes go straight to the output, as they did before the
|
|
50
|
+
* room, for a host that adds its own effects. A function is read at each play.
|
|
51
|
+
*/
|
|
52
|
+
dry?: boolean | (() => boolean | null | undefined);
|
|
53
|
+
/**
|
|
54
|
+
* An amplifier for the electric guitars (`clean`, `overdrive`): `drive` 0 to 1, `cabinet` a
|
|
55
|
+
* speaker's sound. None by default. A function is read at each play.
|
|
56
|
+
*/
|
|
57
|
+
amp?: AmpOptions | (() => AmpOptions | null | undefined);
|
|
36
58
|
/**
|
|
37
59
|
* 0 to 1, 0.8 by default. The bars have no volume (#58): it is the app's setting. A function
|
|
38
60
|
* is read at each play (and each pass of a loop), so a setting changed in the app applies at
|
|
@@ -112,7 +134,16 @@ export declare function playerFor(win: Window, options: PlayOptions, el?: Elemen
|
|
|
112
134
|
* guitar, so an app that names none gets exactly the player it gave.
|
|
113
135
|
*/
|
|
114
136
|
export declare function toned(player: NotePlayer, options: PlayOptions, el?: Element | null): NotePlayer;
|
|
115
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* The effects a host asks for (#103): its room level (to the thousandth: the default is 0.125)
|
|
139
|
+
* and length, `dry`, an amplifier; null when it names none, so the players use their defaults and
|
|
140
|
+
* an app that names nothing gets its own player.
|
|
141
|
+
*/
|
|
142
|
+
export declare function effectsOf(options: PlayOptions): PlayEffects | null;
|
|
143
|
+
/**
|
|
144
|
+
* The guitar that plays for an element: the one its reader chose in a bar's Sound menu, else its
|
|
145
|
+
* block's `guitar:` line, else the app's or page's.
|
|
146
|
+
*/
|
|
116
147
|
export declare function guitarFor(options: PlayOptions, el?: Element | null): GuitarTone | null;
|
|
117
148
|
/** The diagram's own playback data, set by its renderer. */
|
|
118
149
|
export interface DiagramData {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What comes after the instruments (#103): a small room and a ceiling on the way to the speakers,
|
|
3
|
+
* and for the electric guitars an optional amplifier (a drive and a speaker cabinet). Built from
|
|
4
|
+
* Web Audio nodes and a generated impulse response: no file, a few KB of code.
|
|
5
|
+
*
|
|
6
|
+
* One chain per audio context: every play of that context goes through the same room, so a page
|
|
7
|
+
* sounds like one place. A host that adds its own effects asks for `dry` and gets the output as
|
|
8
|
+
* it was.
|
|
9
|
+
*/
|
|
10
|
+
/** The effects of a play: the app's or the page's choice (`PlayOptions`), given to the players. */
|
|
11
|
+
export interface PlayEffects {
|
|
12
|
+
/** The room's level, 0 (none) to 1; the light room by default. */
|
|
13
|
+
reverb?: number;
|
|
14
|
+
/** How long the room rings, in seconds (0.2 to 3): a small room to a hall. */
|
|
15
|
+
room?: number;
|
|
16
|
+
/** No room and no ceiling: the notes go straight to the output, for hosts with their own. */
|
|
17
|
+
dry?: boolean;
|
|
18
|
+
/** An amplifier for the electric guitars (clean, overdrive); none by default. */
|
|
19
|
+
amp?: AmpOptions;
|
|
20
|
+
}
|
|
21
|
+
/** The amplifier of an electric guitar. */
|
|
22
|
+
export interface AmpOptions {
|
|
23
|
+
/** How hard the amplifier is driven, 0 (clean) to 1. */
|
|
24
|
+
drive?: number;
|
|
25
|
+
/** A speaker cabinet's sound: less deep bass and less fizz, more mids. */
|
|
26
|
+
cabinet?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The room's level when nothing says another: a light room, 18 dB under the notes. The level is
|
|
30
|
+
* how loud the room is against what plays in it, where a guitar sounds (`ROOM_BAND`): 0.125 is
|
|
31
|
+
* 18 dB under, 0.35 is 9 dB under, 1 as loud as the notes.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_REVERB = 0.125;
|
|
34
|
+
/**
|
|
35
|
+
* How long the room rings (seconds to fall by 60 dB). A guitar's notes ring for seconds
|
|
36
|
+
* themselves: a room shorter than about a second hides under them and is not heard.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ROOM_SECONDS = 1.2;
|
|
39
|
+
/** The shortest and the longest room (seconds). */
|
|
40
|
+
export declare const ROOM_RANGE: readonly [0.2, 3];
|
|
41
|
+
/** A room's length from an option: within the range, the default when it isn't a number. */
|
|
42
|
+
export declare function roomSeconds(value: unknown): number;
|
|
43
|
+
/** A room level from an option: 0 to 1, the default when it isn't a number. */
|
|
44
|
+
export declare function reverbLevel(value: unknown): number;
|
|
45
|
+
/**
|
|
46
|
+
* A page's effects (`play: { reverb, room, dry, amp }` in `window.musicNotationOptions`): `reverb`
|
|
47
|
+
* a number from 0 to 1, `room` its length in seconds, `dry: true`, `amp: { drive, cabinet }`. A
|
|
48
|
+
* function in place of a value is called. Null when the page names none.
|
|
49
|
+
*/
|
|
50
|
+
export declare function pageEffects(options: unknown): PlayEffects | null;
|
|
51
|
+
/** What a room sounds like, besides its length. */
|
|
52
|
+
export interface RoomShape {
|
|
53
|
+
/** Where the tail's highs end when it starts (Hz). */
|
|
54
|
+
bright: number;
|
|
55
|
+
/** Where they end when it has rung out (Hz). */
|
|
56
|
+
dark: number;
|
|
57
|
+
/** How long the tail takes to come up (seconds). */
|
|
58
|
+
rise: number;
|
|
59
|
+
/** 0: the same on both sides (in the middle, with the notes); 1: nothing in common. */
|
|
60
|
+
width: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The library's room.
|
|
64
|
+
*
|
|
65
|
+
* Brightness: a room is darker than what plays in it. As bright as the guitar (9 kHz, a gentle
|
|
66
|
+
* slope), the tail was heard as noise: every attack came back as a hiss until the next strum.
|
|
67
|
+
*
|
|
68
|
+
* Rise: a real room starts with a few echoes and gets dense later; a tail of noise at full level
|
|
69
|
+
* from its first instant put a burst of noise right after each attack. Not long: at 50 ms the
|
|
70
|
+
* tail's loudest moment came 60 ms after the note, a small echo.
|
|
71
|
+
*
|
|
72
|
+
* Width: with nothing in common between the two sides, the room was a cloud of noise around the
|
|
73
|
+
* head, apart from the guitar in the middle (and the hardest sound there is for the codec of
|
|
74
|
+
* wireless headphones). Half in common: the room is around the guitar.
|
|
75
|
+
*/
|
|
76
|
+
export declare const ROOM_SHAPE: Readonly<RoomShape>;
|
|
77
|
+
/**
|
|
78
|
+
* Where a guitar sounds (Hz): the room is as loud there as what goes into it. With an energy of 1
|
|
79
|
+
* over all frequencies, a dark room had all of it in this band: 11 dB more than its number said
|
|
80
|
+
* (the default was 8.6 dB under a recorded strum, not the 18 dB meant).
|
|
81
|
+
*/
|
|
82
|
+
export declare const ROOM_BAND: readonly [300, 3000];
|
|
83
|
+
/** Under this (Hz) the two sides are the same: lows that differ between the ears feel wrong. */
|
|
84
|
+
export declare const ROOM_WIDE_FROM = 400;
|
|
85
|
+
/**
|
|
86
|
+
* The impulse response of a room, left and right: after 12 ms (the notes themselves come first),
|
|
87
|
+
* a diffuse tail that comes up, falls by 60 dB in `seconds` and gets darker as it falls (walls
|
|
88
|
+
* take the highs first; the brightness is in Hz, so the room sounds the same at every sample
|
|
89
|
+
* rate). `shape` changes the library's room (`ROOM_SHAPE`), for a host that tunes its own. The
|
|
90
|
+
* two sides differ above `ROOM_WIDE_FROM`, so the room has width. A sound of the guitar's band
|
|
91
|
+
* (`ROOM_BAND`) through it comes out as loud as it went in: the level is the gain after it.
|
|
92
|
+
*/
|
|
93
|
+
export declare function roomImpulse(sampleRate: number, seconds?: number, shape?: Partial<RoomShape>): [Float32Array, Float32Array];
|
|
94
|
+
/** Where the ceiling starts to bend, and the highest level its curve is drawn for. */
|
|
95
|
+
export declare const CEILING: {
|
|
96
|
+
readonly knee: 0.9;
|
|
97
|
+
readonly range: 2;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The ceiling, the last thing before the speakers: a level under the knee comes out as it is, a
|
|
101
|
+
* higher one bends toward 1 and never passes it. An accented six-string strum of the recorded
|
|
102
|
+
* guitars peaks at 1.115 and was cut flat by the speakers; plays that add up go higher. It is
|
|
103
|
+
* not late and has no memory: nothing to pump. (A browser's compressor was here first, as a
|
|
104
|
+
* limiter. It is 6 ms late, starts turned down, cannot give up its make-up gain, and its gain
|
|
105
|
+
* moved by 1 to 5 dB for a quarter to half of the time when a loud room pushed it: it is gone.)
|
|
106
|
+
* The curve is for an input divided by `CEILING.range` (a wave shaper reads -1 to 1).
|
|
107
|
+
*/
|
|
108
|
+
export declare function ceilingCurve(points?: number): Float32Array;
|
|
109
|
+
/** The room's sound below this (Hz) is left out: a room's low end is mud under a guitar. */
|
|
110
|
+
export declare const ROOM_LOW_CUT = 180;
|
|
111
|
+
/**
|
|
112
|
+
* Where a player sends its notes: the context's chain (the room at the level asked, then the
|
|
113
|
+
* ceiling), or the output itself for `dry` and for a context that can't build the chain. The
|
|
114
|
+
* room's level and length are the context's: the last play that names them sets them for what
|
|
115
|
+
* sounds. `speakers` is the context's output, for a caller that keeps it under another name
|
|
116
|
+
* (alphaTab's context, see `src/tab/room.ts`).
|
|
117
|
+
*/
|
|
118
|
+
export declare function outputFor(ctx: BaseAudioContext, effects?: PlayEffects, speakers?: AudioNode): AudioNode;
|
|
119
|
+
/** How hard the amplifier's curve bends at a drive of 0 to 1. */
|
|
120
|
+
export declare const driveAmount: (drive: number) => number;
|
|
121
|
+
/** The curve of a driven amplifier: a soft ceiling, steeper with more drive. */
|
|
122
|
+
export declare function driveCurve(drive: number, points?: number): Float32Array;
|
|
123
|
+
/** The level of a strummed guitar the drive is matched for (a wave's peak). */
|
|
124
|
+
export declare const DRIVE_REFERENCE = 0.2;
|
|
125
|
+
/**
|
|
126
|
+
* The gain after the drive that keeps a strum as loud as it went in: a wave at the reference
|
|
127
|
+
* level through the curve, its level in over its level out. The curve raises quiet sound by its
|
|
128
|
+
* slope (up to 15 times): a fixed gain made a driven strum 10 to 12 dB louder.
|
|
129
|
+
*/
|
|
130
|
+
export declare function driveLevel(drive: number, reference?: number): number;
|
|
131
|
+
/** The cabinet's filters raise a guitar's level by about this (dB): taken back after them. */
|
|
132
|
+
export declare const CABINET_TRIM_DB = -2;
|
|
133
|
+
/**
|
|
134
|
+
* An electric guitar's amplifier between a play and the chain: a drive (the deep bass left out,
|
|
135
|
+
* then a wave shaper, level matched so more drive is not simply louder) and a cabinet (no deep
|
|
136
|
+
* bass, a peak in the mids, no fizz, level matched too). Null when the options ask for neither,
|
|
137
|
+
* or the context can't build it.
|
|
138
|
+
*/
|
|
139
|
+
export declare function ampFor(ctx: BaseAudioContext, amp: AmpOptions | undefined): {
|
|
140
|
+
input: AudioNode;
|
|
141
|
+
output: AudioNode;
|
|
142
|
+
} | null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Which guitar plays the diagrams (#103): a steel-string acoustic (the default), a nylon-string
|
|
3
3
|
* classical guitar, a clean electric or an overdriven electric. The reader's side chooses (a
|
|
4
|
-
* page's or an app's `guitar`); a block may say `guitar
|
|
5
|
-
* piano stays a piano, and tabs and
|
|
4
|
+
* page's or an app's `guitar`); a block may say `guitar:`; the reader may choose another one in a
|
|
5
|
+
* play bar's Sound menu. It changes the guitar sound only: a piano stays a piano, and tabs and
|
|
6
|
+
* scores keep the instruments their tracks name.
|
|
6
7
|
*/
|
|
7
8
|
/** The guitars, the default first. */
|
|
8
9
|
export declare const GUITAR_TONES: readonly ["steel", "nylon", "clean", "overdrive"];
|
|
@@ -23,5 +24,12 @@ export declare function blockGuitar(source: string, chart?: boolean): {
|
|
|
23
24
|
};
|
|
24
25
|
/** The guitar of the block an element is in (`data-mn-guitar`, set from its `guitar:` line). */
|
|
25
26
|
export declare function guitarWish(el: Element | null | undefined): GuitarTone | null;
|
|
27
|
+
/** The guitar a reader chose on a play bar of the block an element is in; null without one. */
|
|
28
|
+
export declare function guitarChoice(el: Element | null | undefined): GuitarTone | null;
|
|
29
|
+
/**
|
|
30
|
+
* Keeps the guitar a reader chose on a play bar: on the block an element is in, so every bar and
|
|
31
|
+
* diagram of the block plays it, else on the element itself. It lasts as long as the drawing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function chooseGuitar(el: Element, guitar: GuitarTone): void;
|
|
26
34
|
/** A page's guitar (`play: { guitar }` in `window.musicNotationOptions`), when it names one. */
|
|
27
35
|
export declare function pageGuitar(options: unknown): GuitarTone | undefined;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Apps can pass another NotePlayer (a soundfont one) for realistic sound.
|
|
5
5
|
*/
|
|
6
6
|
import { type GuitarTone } from './guitar-tone.js';
|
|
7
|
+
import { type PlayEffects } from './effects.js';
|
|
7
8
|
export type Sound = 'guitar' | 'piano';
|
|
8
9
|
export interface NoteEvent {
|
|
9
10
|
midi: number;
|
|
@@ -41,6 +42,11 @@ export interface NotePlayer {
|
|
|
41
42
|
* that doesn't know it plays its own guitar.
|
|
42
43
|
*/
|
|
43
44
|
guitar?: GuitarTone;
|
|
45
|
+
/**
|
|
46
|
+
* The room, the ceiling and the amplifier after the notes (#103): the light room by
|
|
47
|
+
* default. A player that doesn't know them plays as it always did.
|
|
48
|
+
*/
|
|
49
|
+
effects?: PlayEffects;
|
|
44
50
|
}): PlayHandle;
|
|
45
51
|
/**
|
|
46
52
|
* True when `play` calls `onStart`: the bar then waits for it before it lights notes.
|
|
@@ -133,6 +139,14 @@ export declare function contextFor(win: Window & {
|
|
|
133
139
|
export declare const RELEASE: Readonly<Record<Sound, number>>;
|
|
134
140
|
/** The release of a note of `duration` seconds. */
|
|
135
141
|
export declare const releaseOf: (sound: Sound, duration: number) => number;
|
|
142
|
+
/**
|
|
143
|
+
* Sends a play's notes on (#103): through an electric guitar's amplifier when one is asked for
|
|
144
|
+
* (`clean` and `overdrive` only), then to the context's room and ceiling, or straight to the
|
|
145
|
+
* output for `dry`. Returns what lets the play go once its sound is over: its node leaves the
|
|
146
|
+
* chain, and its amplifier too (an amplifier left connected stayed in the chain for good, one
|
|
147
|
+
* more with each play).
|
|
148
|
+
*/
|
|
149
|
+
export declare function sendOut(ctx: BaseAudioContext, from: AudioNode, guitar: GuitarTone | null, effects: PlayEffects | undefined): () => void;
|
|
136
150
|
/**
|
|
137
151
|
* The light synthesizer: computed sound, a few KB, no download. No two notes sound quite the
|
|
138
152
|
* same: each guitar note takes one of a few plucks of its string (brightness, pick position,
|
|
@@ -6,4 +6,9 @@ export declare function barsFromDrawing(drawing: Element): {
|
|
|
6
6
|
bars: ProgressionBar[];
|
|
7
7
|
marks: Element[][];
|
|
8
8
|
};
|
|
9
|
-
export declare function progressionBarFor(doc: Document, win: Window, drawing: Element, options: PlayOptions, diagrams?: DiagramGroup | null
|
|
9
|
+
export declare function progressionBarFor(doc: Document, win: Window, drawing: Element, options: PlayOptions, diagrams?: DiagramGroup | null,
|
|
10
|
+
/**
|
|
11
|
+
* Gives the group of the drawing's diagrams again, after the chart was drawn again (#45): the
|
|
12
|
+
* caller frees the old one.
|
|
13
|
+
*/
|
|
14
|
+
regroup?: () => DiagramGroup | null): () => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Sound menu of the play bars (#103): the four guitars, then the piano. A guitar chosen here
|
|
3
|
+
* comes before the block's `guitar:` line and the app's or page's guitar, for the block the bar
|
|
4
|
+
* is in, until it is drawn again. Nothing is stored.
|
|
5
|
+
*/
|
|
6
|
+
import type { Translator } from '../i18n/translate.js';
|
|
7
|
+
import { type PlayOptions } from './controls.js';
|
|
8
|
+
import { type GuitarTone } from './guitar-tone.js';
|
|
9
|
+
import type { Sound } from './player.js';
|
|
10
|
+
/** An entry of the menu: a guitar, or the piano. */
|
|
11
|
+
export type SoundChoice = GuitarTone | 'piano';
|
|
12
|
+
export interface SoundMenu {
|
|
13
|
+
el: HTMLSelectElement;
|
|
14
|
+
/** Shows what plays now: the piano, or the guitar in effect (an app's setting may have changed). */
|
|
15
|
+
show(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The menu of a bar that plays `played` (the drawing, or each diagram's wrapper). `sound` is the
|
|
19
|
+
* bar's sound now; `set` gives it the instrument chosen.
|
|
20
|
+
*/
|
|
21
|
+
export declare function soundMenu(doc: Document, tr: Translator, options: PlayOptions, played: () => Element[], sound: () => Sound, set: (sound: Sound) => void): SoundMenu;
|