@dsebastien/music-notation 0.7.0 → 0.8.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 +28 -2
- package/dist/blocks/note-set-field.d.ts +3 -1
- package/dist/blocks/progression.d.ts +6 -0
- package/dist/blocks/renderers.d.ts +10 -1
- package/dist/blocks/scales-for.d.ts +16 -0
- package/dist/chord/capo.d.ts +26 -0
- package/dist/chord/guitar.d.ts +20 -0
- package/dist/chord/transitions.d.ts +15 -7
- package/dist/chords/chart-diagrams.d.ts +46 -0
- package/dist/chords/chart.d.ts +16 -0
- package/dist/chords/chordpro.d.ts +17 -1
- package/dist/chords/defines.d.ts +38 -0
- package/dist/circle/circle.d.ts +21 -0
- package/dist/cli.js +2 -2
- package/dist/convert/text-tab.d.ts +4 -2
- package/dist/fretboard/fretboard.d.ts +11 -0
- package/dist/fretboard/positions.d.ts +12 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +5946 -1923
- package/dist/index.js.map +39 -22
- package/dist/keyboard/keyboard.d.ts +2 -0
- package/dist/keyboard/piano-chord.d.ts +44 -0
- package/dist/keyboard/voice-leading.d.ts +6 -0
- package/dist/music-notation.css +339 -0
- package/dist/music-notation.publish.min.js +362 -21
- package/dist/music-notation.tab.min.js +343 -4
- package/dist/playback/controls.d.ts +10 -1
- package/dist/playback/follow.d.ts +45 -0
- package/dist/playback/player.d.ts +13 -1
- package/dist/playback/strum-bar.d.ts +5 -0
- package/dist/publish/index.js +5271 -1852
- package/dist/publish/index.js.map +38 -21
- package/dist/strum/pattern.d.ts +49 -0
- package/dist/strum/play.d.ts +106 -0
- package/dist/strum/render.d.ts +17 -0
- package/dist/strum/voicing.d.ts +10 -0
- package/dist/tab/index.js +334 -78
- package/dist/tab/index.js.map +7 -7
- package/dist/theory/chord-symbol.d.ts +2 -0
- package/dist/theory/find.d.ts +82 -0
- package/dist/theory/keys.d.ts +79 -0
- package/dist/theory/note-set.d.ts +2 -0
- package/dist/theory/numerals.d.ts +40 -0
- package/dist/theory/pitch.d.ts +4 -1
- package/dist/theory/transpose.d.ts +16 -4
- package/dist/voicings/index.js +58 -14
- package/dist/voicings/index.js.map +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type Stroke = 'down' | 'up' | 'mute' | 'rest';
|
|
2
|
+
export type Subdivision = '8ths' | '16ths' | 'triplets';
|
|
3
|
+
export interface StrumSlot {
|
|
4
|
+
stroke: Stroke;
|
|
5
|
+
/** Played louder (`D>`). */
|
|
6
|
+
accent: boolean;
|
|
7
|
+
/** Played softly (`(U)`). */
|
|
8
|
+
ghost: boolean;
|
|
9
|
+
/** A chord that starts on this slot (as written, a symbol), or null. */
|
|
10
|
+
chord: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface StrumPattern {
|
|
13
|
+
slots: StrumSlot[];
|
|
14
|
+
/** The time signature: beats a bar and the note that counts as a beat (4/4, 3/4, 6/8). */
|
|
15
|
+
beatsPerBar: number;
|
|
16
|
+
beatUnit: number;
|
|
17
|
+
subdivision: Subdivision;
|
|
18
|
+
/** Slots in one beat (2 for 8ths in 4/4, 1 for 8ths in 6/8). */
|
|
19
|
+
slotsPerBeat: number;
|
|
20
|
+
slotsPerBar: number;
|
|
21
|
+
bars: number;
|
|
22
|
+
/** The chord for the whole pattern (`chord:`), until a change. */
|
|
23
|
+
chord: string | null;
|
|
24
|
+
/** Beats a minute (`tempo:`), null when not written. */
|
|
25
|
+
tempo: number | null;
|
|
26
|
+
/** Open strings for playback (`tuning:`), as written; null for standard guitar. */
|
|
27
|
+
tuning: string | null;
|
|
28
|
+
title: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** Bounds that keep a pattern quick to draw and to hear. */
|
|
31
|
+
export declare const MAX_STRUM_BARS = 16;
|
|
32
|
+
export declare const DEFAULT_TEMPO = 90;
|
|
33
|
+
export declare const MIN_TEMPO = 20;
|
|
34
|
+
export declare const MAX_TEMPO = 240;
|
|
35
|
+
/** "4/4", "6/8", "C" (common time), "cut" (2/2). Throws a message for the user. */
|
|
36
|
+
export declare function parseTime(text: string): {
|
|
37
|
+
beatsPerBar: number;
|
|
38
|
+
beatUnit: number;
|
|
39
|
+
};
|
|
40
|
+
/** "8ths", "eighths", "8"; "16ths", "sixteenths", "16"; "triplets". Throws a message. */
|
|
41
|
+
export declare function parseSubdivision(text: string): Subdivision;
|
|
42
|
+
/** Slots in one beat of the time signature. Throws when the subdivision can't divide the beat. */
|
|
43
|
+
export declare function slotsPerBeatOf(subdivision: Subdivision, beatUnit: number): number;
|
|
44
|
+
/** Parses a ```strum block. Throws an Error whose message says what to write instead. */
|
|
45
|
+
export declare function parseStrum(source: string): StrumPattern;
|
|
46
|
+
/** The pattern written back, one symbol a slot, bars separated by `|`: `[G]D - D U - U D U`. */
|
|
47
|
+
export declare function formatStrum(pattern: StrumPattern): string;
|
|
48
|
+
/** What each slot is counted as: 1 & 2 &, 1 e & a, 1 & a (triplets), 1 2 3 4 5 6 (6/8). */
|
|
49
|
+
export declare function countOf(slot: number, slotsPerBeat: number, slotsPerBar: number): string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { VoicingLookup } from '../voicings/index.js';
|
|
2
|
+
import { type NoteEvent, type NotePlayer, type PlayHandle, type Sound } from '../playback/player.js';
|
|
3
|
+
import { type StrumPattern, type Stroke } from './pattern.js';
|
|
4
|
+
/** A pattern ready to play: each slot's strum and the notes it sounds. */
|
|
5
|
+
export interface StrumScore {
|
|
6
|
+
slots: {
|
|
7
|
+
stroke: Stroke;
|
|
8
|
+
accent: boolean;
|
|
9
|
+
ghost: boolean;
|
|
10
|
+
pitches: number[];
|
|
11
|
+
}[];
|
|
12
|
+
slotsPerBeat: number;
|
|
13
|
+
beatsPerBar: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Each slot's notes: the chord that starts there, else the one before it. Strums before the first
|
|
17
|
+
* change take `chord:` when written, else the chord the pattern ends on (as when it repeats).
|
|
18
|
+
*/
|
|
19
|
+
export declare function scoreOf(pattern: StrumPattern, voicing: (chord: string | null) => number[]): StrumScore;
|
|
20
|
+
export interface StrumEventOptions {
|
|
21
|
+
/** Beats a minute (the time signature's beat: a quarter in 4/4, an eighth in 6/8). */
|
|
22
|
+
bpm?: number;
|
|
23
|
+
/** A bar of clicks first. */
|
|
24
|
+
countIn?: boolean;
|
|
25
|
+
/** How long the last strum rings after the pattern, in seconds (0 when it loops). */
|
|
26
|
+
tail?: number;
|
|
27
|
+
}
|
|
28
|
+
/** MIDI velocities: a normal strum, an accent, a ghost strum, a muted one. */
|
|
29
|
+
export declare const STRUM_VELOCITY: {
|
|
30
|
+
normal: number;
|
|
31
|
+
accent: number;
|
|
32
|
+
ghost: number;
|
|
33
|
+
mute: number;
|
|
34
|
+
};
|
|
35
|
+
/** Beats a minute within bounds; the default when it isn't a number. */
|
|
36
|
+
export declare const tempoOf: (bpm: number | null | undefined) => number;
|
|
37
|
+
/** When a slot's strum is played in a pass: from its start, for one slot. */
|
|
38
|
+
export interface StrumTiming {
|
|
39
|
+
slot: number;
|
|
40
|
+
/** Seconds from the start of the pass. */
|
|
41
|
+
time: number;
|
|
42
|
+
duration: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The notes of one pass of a pattern (with the count-in first when asked), its length in seconds
|
|
46
|
+
* (count-in plus the pattern's bars, without the last strum's ring), the time the next pass starts
|
|
47
|
+
* when it loops, and when each strum is played (to light it).
|
|
48
|
+
*/
|
|
49
|
+
export declare function strumEvents(score: StrumScore, options?: StrumEventOptions): {
|
|
50
|
+
events: NoteEvent[];
|
|
51
|
+
length: number;
|
|
52
|
+
strums: StrumTiming[];
|
|
53
|
+
};
|
|
54
|
+
/** What a strum player reads at each pass, so the bar's changes apply from the next pass. */
|
|
55
|
+
export interface StrumSettings {
|
|
56
|
+
bpm: number;
|
|
57
|
+
countIn: boolean;
|
|
58
|
+
loop: boolean;
|
|
59
|
+
sound: Sound;
|
|
60
|
+
volume: number;
|
|
61
|
+
}
|
|
62
|
+
/** Lights the strums of one pass as they sound (see `followNotes`). */
|
|
63
|
+
export interface StrumFollower {
|
|
64
|
+
/** The pass's notes started sounding now. */
|
|
65
|
+
heard(): void;
|
|
66
|
+
stop(): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Plays a score through `player`, pass after pass while `settings().loop` is on. Each next pass
|
|
70
|
+
* is started on a timer at the exact end of the previous one, counted from the first pass's start
|
|
71
|
+
* (so delays don't add up), and is scheduled by the player like the first: no gap, no drift. With
|
|
72
|
+
* a player that says when its notes start (`reportsStart`, or seen calling `onStart`), the
|
|
73
|
+
* passes are counted from that moment, so a first play that waits for a soundfont isn't cut by the
|
|
74
|
+
* second pass; a player not known to report yet is counted from the play call until its first
|
|
75
|
+
* start report, if that comes before the second pass. `follow` gets each pass's strums, to light
|
|
76
|
+
* them from the moment they sound.
|
|
77
|
+
*/
|
|
78
|
+
export declare function runStrum(score: StrumScore, player: () => NotePlayer, settings: () => StrumSettings, timers: Pick<Window, 'setTimeout' | 'clearTimeout'>, onEnd?: () => void, follow?: (strums: StrumTiming[], player: NotePlayer) => StrumFollower): PlayHandle;
|
|
79
|
+
export interface PlayStrumOptions {
|
|
80
|
+
/** Beats a minute: the pattern's `tempo:`, else 90. */
|
|
81
|
+
bpm?: number;
|
|
82
|
+
/** A chord symbol (or words), or the notes to strum, lowest string first. */
|
|
83
|
+
chord?: string | readonly number[];
|
|
84
|
+
/** Open strings (MIDI, lowest first) or a tuning name (`standard`, `drop d`, `ukulele`…). */
|
|
85
|
+
tuning?: readonly number[] | string;
|
|
86
|
+
/** A bar of clicks first; false by default. */
|
|
87
|
+
countIn?: boolean;
|
|
88
|
+
loop?: boolean;
|
|
89
|
+
/** The light synthesizer of `window` by default. */
|
|
90
|
+
player?: NotePlayer;
|
|
91
|
+
/** The window to play in (popouts have their own); the global one by default. */
|
|
92
|
+
window?: Window;
|
|
93
|
+
sound?: Sound;
|
|
94
|
+
/** 0 to 1, 0.8 by default. */
|
|
95
|
+
volume?: number;
|
|
96
|
+
/** Called once the pattern is over (not after stop). */
|
|
97
|
+
onEnd?: () => void;
|
|
98
|
+
/** Finds guitar voicings for chords (see `/voicings`); generated voicings otherwise. */
|
|
99
|
+
voicings?: VoicingLookup;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Plays a strumming pattern (a ```strum block's text, or a parsed pattern). The chord changes
|
|
103
|
+
* written in the pattern win over `chord`, which wins over the pattern's `chord:`. Throws the
|
|
104
|
+
* block's message when the text has a mistake.
|
|
105
|
+
*/
|
|
106
|
+
export declare function playStrum(pattern: string | StrumPattern, options?: PlayStrumOptions): PlayHandle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RenderOptions } from '../blocks/renderers.js';
|
|
2
|
+
import { type StrumPattern } from './pattern.js';
|
|
3
|
+
export interface StrumOptions {
|
|
4
|
+
title?: string;
|
|
5
|
+
/** The notes each chord sounds (lowest string first), for playback; see `strumVoicing`. */
|
|
6
|
+
voicing?: (chord: string | null) => number[];
|
|
7
|
+
/** Beats a minute playback starts at (the pattern's own tempo wins). */
|
|
8
|
+
bpm?: number;
|
|
9
|
+
}
|
|
10
|
+
/** The pattern's drawing, with what playback needs on its elements. */
|
|
11
|
+
export declare function renderStrum(doc: Document, pattern: StrumPattern, options?: StrumOptions): SVGElement;
|
|
12
|
+
/**
|
|
13
|
+
* A ```strum block: the pattern drawn, with each chord's notes for playback (the `voicings`
|
|
14
|
+
* option's on a standard guitar, else generated ones, for the block's `tuning:`). Throws a
|
|
15
|
+
* message for the user.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderStrumBlock(doc: Document, source: string, options: RenderOptions): SVGElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VoicingLookup } from '../voicings/index.js';
|
|
2
|
+
/** Without a chord, patterns strum E minor (open strings 022000) on a standard guitar. */
|
|
3
|
+
export declare const DEFAULT_STRUM_CHORD = "Em";
|
|
4
|
+
/**
|
|
5
|
+
* The notes a strum of `chord` sounds, in string order (lowest string first, as a down strum
|
|
6
|
+
* hits them). The voicing lookup's first voicing on a standard guitar when given, else the
|
|
7
|
+
* easiest generated voicing, else the chord's notes stacked from the low string. Without a chord:
|
|
8
|
+
* E minor on a standard guitar, the open strings on other tunings.
|
|
9
|
+
*/
|
|
10
|
+
export declare function strumVoicing(chord: string | null, tuning?: readonly number[], voicings?: VoicingLookup): number[];
|