@leafo/lml 0.2.0 → 0.3.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 +31 -17
- package/dist/auto-chords.d.ts +33 -8
- package/dist/auto-chords.d.ts.map +1 -1
- package/dist/auto-chords.js +19 -1
- package/dist/auto-chords.js.map +1 -1
- package/dist/grammar.d.ts.map +1 -1
- package/dist/grammar.js +374 -246
- package/dist/grammar.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/music.d.ts +501 -5
- package/dist/music.d.ts.map +1 -1
- package/dist/music.js +495 -52
- package/dist/music.js.map +1 -1
- package/dist/note-utils.d.ts +13 -0
- package/dist/note-utils.d.ts.map +1 -0
- package/dist/note-utils.js +62 -0
- package/dist/note-utils.js.map +1 -0
- package/dist/noteUtils.d.ts +1 -0
- package/dist/noteUtils.d.ts.map +1 -1
- package/dist/noteUtils.js +8 -2
- package/dist/noteUtils.js.map +1 -1
- package/dist/parser.d.ts +135 -2
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +137 -36
- package/dist/parser.js.map +1 -1
- package/dist/song.d.ts +197 -1
- package/dist/song.d.ts.map +1 -1
- package/dist/song.js +213 -13
- package/dist/song.js.map +1 -1
- package/package.json +5 -2
package/dist/parser.js
CHANGED
|
@@ -3,67 +3,150 @@ import * as peg from "./grammar.js";
|
|
|
3
3
|
import { parseNote, KeySignature, OFFSETS, OCTAVE_SIZE } from "./music.js";
|
|
4
4
|
import { MultiTrackSong, SongNote } from "./song.js";
|
|
5
5
|
import { AutoChords } from "./auto-chords.js";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Internal tick resolution for timing calculations.
|
|
8
|
+
* 48 ticks per beat allows exact representation of common subdivisions
|
|
9
|
+
* including triplets, sixtuplets, and standard note values.
|
|
10
|
+
* Divisible by 1, 2, 3, 4, 6, 8, 12, 16, 24, 48.
|
|
11
|
+
*/
|
|
8
12
|
const TICKS_PER_BEAT = 48;
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
14
|
+
* Calculates the duration multiplier for dotted notes.
|
|
15
|
+
* Each dot adds half of the previous value to the note duration.
|
|
16
|
+
* @param dots - Number of dots (1, 2, 3, etc.)
|
|
17
|
+
* @returns Duration multiplier (1 dot = 1.5x, 2 dots = 1.75x, 3 dots = 1.875x)
|
|
18
|
+
* @example
|
|
19
|
+
* dottedMultiplier(1) // 1.5
|
|
20
|
+
* dottedMultiplier(2) // 1.75
|
|
21
|
+
* dottedMultiplier(3) // 1.875
|
|
22
|
+
*/
|
|
23
|
+
function dottedMultiplier(dots) {
|
|
24
|
+
return (Math.pow(2, dots + 1) - 1) / Math.pow(2, dots);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Finds the octave that places a note closest to a reference pitch.
|
|
28
|
+
* Used for relative note entry where the octave is inferred from context.
|
|
29
|
+
* @param noteLetter - Note name without octave (e.g., "C", "F#", "Bb")
|
|
30
|
+
* @param referencePitch - MIDI pitch number to stay close to
|
|
31
|
+
* @returns Full note name with octave (e.g., "C4", "F#5")
|
|
32
|
+
* @throws Error if noteLetter is not a valid note name
|
|
33
|
+
* @example
|
|
34
|
+
* findClosestOctave("G", 60) // "G4" (closest G to middle C)
|
|
35
|
+
* findClosestOctave("C", 67) // "C5" (closest C to G4)
|
|
12
36
|
*/
|
|
13
37
|
function findClosestOctave(noteLetter, referencePitch) {
|
|
14
38
|
const match = noteLetter.match(/^([A-G])(#|b)?$/);
|
|
15
39
|
if (!match) {
|
|
16
40
|
throw new Error(`Invalid note letter: ${noteLetter}`);
|
|
17
41
|
}
|
|
18
|
-
const [, letter
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const refOctave = Math.floor(referencePitch / OCTAVE_SIZE);
|
|
28
|
-
// Calculate pitches for octaves around the reference
|
|
29
|
-
let bestPitch = refOctave * OCTAVE_SIZE + noteOffset;
|
|
42
|
+
const [, letter] = match;
|
|
43
|
+
if (OFFSETS[letter] === undefined) {
|
|
44
|
+
throw new Error(`Invalid note letter: ${letter}`);
|
|
45
|
+
}
|
|
46
|
+
// Find the reference note's octave (MIDI: C4 = 60)
|
|
47
|
+
const refOctave = Math.floor(referencePitch / OCTAVE_SIZE) - 1;
|
|
48
|
+
// Calculate pitches for octaves around the reference using parseNote for spelling rules.
|
|
49
|
+
let bestOctave = refOctave;
|
|
50
|
+
let bestPitch = parseNote(`${noteLetter}${refOctave}`);
|
|
30
51
|
let bestDistance = Math.abs(bestPitch - referencePitch);
|
|
31
|
-
|
|
32
|
-
const pitchBelow = (
|
|
52
|
+
const belowOctave = refOctave - 1;
|
|
53
|
+
const pitchBelow = parseNote(`${noteLetter}${belowOctave}`);
|
|
33
54
|
const distBelow = Math.abs(pitchBelow - referencePitch);
|
|
34
55
|
if (distBelow < bestDistance) {
|
|
56
|
+
bestOctave = belowOctave;
|
|
35
57
|
bestPitch = pitchBelow;
|
|
36
58
|
bestDistance = distBelow;
|
|
37
59
|
}
|
|
38
|
-
|
|
39
|
-
const pitchAbove = (
|
|
60
|
+
const aboveOctave = refOctave + 1;
|
|
61
|
+
const pitchAbove = parseNote(`${noteLetter}${aboveOctave}`);
|
|
40
62
|
const distAbove = Math.abs(pitchAbove - referencePitch);
|
|
41
63
|
if (distAbove < bestDistance) {
|
|
42
|
-
|
|
64
|
+
bestOctave = aboveOctave;
|
|
43
65
|
}
|
|
44
|
-
|
|
45
|
-
return `${noteLetter}${finalOctave}`;
|
|
66
|
+
return `${noteLetter}${bestOctave}`;
|
|
46
67
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
68
|
+
/**
|
|
69
|
+
* Parser and compiler for the LML (Leafo Music Language) notation format.
|
|
70
|
+
* Converts text-based music notation into a MultiTrackSong with note and timing data.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Quick load from string
|
|
74
|
+
* const song = SongParser.load("c d e f g")
|
|
75
|
+
*
|
|
76
|
+
* // Two-step parse and compile
|
|
77
|
+
* const parser = new SongParser()
|
|
78
|
+
* const ast = parser.parse("c d e | f g a")
|
|
79
|
+
* const song = parser.compile(ast)
|
|
80
|
+
*/
|
|
56
81
|
class SongParser {
|
|
82
|
+
/**
|
|
83
|
+
* Convenience method to parse and compile a song in one step.
|
|
84
|
+
* @param songText - LML notation string to parse
|
|
85
|
+
* @param opts - Optional parser configuration
|
|
86
|
+
* @returns Compiled MultiTrackSong
|
|
87
|
+
* @example
|
|
88
|
+
* const song = SongParser.load("c d e | f g a")
|
|
89
|
+
*/
|
|
57
90
|
static load(songText, opts) {
|
|
58
91
|
const parser = new SongParser();
|
|
59
92
|
const ast = parser.parse(songText);
|
|
60
93
|
return parser.compile(ast, opts);
|
|
61
94
|
}
|
|
62
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Parses a single note string into its component parts.
|
|
97
|
+
* @param noteStr - Note string to parse (e.g., "c5", "c+5*2", "c5.")
|
|
98
|
+
* @returns ParsedNote object, or null if parsing fails
|
|
99
|
+
* @example
|
|
100
|
+
* SongParser.parseNote("c5") // { name: "C", octave: "5" }
|
|
101
|
+
* SongParser.parseNote("c+5*2") // { name: "C", accidental: "+", octave: "5", duration: 2 }
|
|
102
|
+
* SongParser.parseNote("c5.") // { name: "C", octave: "5", dots: 1 }
|
|
103
|
+
* SongParser.parseNote("c5@2") // { name: "C", octave: "5", start: 2 }
|
|
104
|
+
*/
|
|
105
|
+
static parseNote(noteStr) {
|
|
106
|
+
try {
|
|
107
|
+
const result = peg.parse(noteStr, { startRule: 'note' });
|
|
108
|
+
const [, noteName, opts] = result;
|
|
109
|
+
const parsed = {
|
|
110
|
+
name: noteName[0], // Just the letter (already uppercase from grammar)
|
|
111
|
+
octave: noteName.slice(1) || undefined,
|
|
112
|
+
accidental: opts.sharp ? '+' : opts.flat ? '-' : opts.natural ? '=' : undefined,
|
|
113
|
+
duration: opts.duration,
|
|
114
|
+
start: opts.start,
|
|
115
|
+
};
|
|
116
|
+
if (opts.dots)
|
|
117
|
+
parsed.dots = opts.dots;
|
|
118
|
+
return parsed;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Parses LML notation text into an abstract syntax tree.
|
|
126
|
+
* @param songText - LML notation string to parse
|
|
127
|
+
* @returns Array of AST nodes representing the parsed song
|
|
128
|
+
* @throws SyntaxError if the input contains invalid syntax
|
|
129
|
+
* @example
|
|
130
|
+
* const parser = new SongParser()
|
|
131
|
+
* const ast = parser.parse("C4 D4 E4")
|
|
132
|
+
* // ast = [["note", "C", {...}], ["note", "D", {...}], ["note", "E", {...}]]
|
|
133
|
+
*/
|
|
63
134
|
parse(songText) {
|
|
64
|
-
return peg.parse(songText);
|
|
135
|
+
return peg.parse(songText, { grammarSource: "input" });
|
|
65
136
|
}
|
|
66
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Compiles an AST into a MultiTrackSong with note data.
|
|
139
|
+
* Processes all commands, resolves relative octaves, applies key signatures,
|
|
140
|
+
* and optionally generates auto-chords.
|
|
141
|
+
* @param ast - Abstract syntax tree from parse()
|
|
142
|
+
* @param opts - Optional compiler configuration
|
|
143
|
+
* @returns Compiled song with tracks, notes, and metadata
|
|
144
|
+
* @example
|
|
145
|
+
* const parser = new SongParser()
|
|
146
|
+
* const ast = parser.parse("$G | C D E | F G A |")
|
|
147
|
+
* const song = parser.compile(ast)
|
|
148
|
+
* // song.metadata.keySignature = 1 (G major)
|
|
149
|
+
*/
|
|
67
150
|
compile(ast, opts) {
|
|
68
151
|
// Extract frontmatter from AST
|
|
69
152
|
const frontmatter = {};
|
|
@@ -111,6 +194,12 @@ class SongParser {
|
|
|
111
194
|
}
|
|
112
195
|
return song;
|
|
113
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Recursively processes AST commands and updates song state.
|
|
199
|
+
* @param commands - Array of AST nodes to process
|
|
200
|
+
* @param state - Current compiler state (modified in place)
|
|
201
|
+
* @param song - Song being built (notes added to tracks)
|
|
202
|
+
*/
|
|
114
203
|
compileCommands(commands, state, song) {
|
|
115
204
|
for (const command of commands) {
|
|
116
205
|
const t = command[0];
|
|
@@ -195,6 +284,9 @@ class SongParser {
|
|
|
195
284
|
if (noteOpts.duration) {
|
|
196
285
|
durationTicks *= noteOpts.duration;
|
|
197
286
|
}
|
|
287
|
+
if (noteOpts.dots) {
|
|
288
|
+
durationTicks *= dottedMultiplier(noteOpts.dots);
|
|
289
|
+
}
|
|
198
290
|
if (noteOpts.sharp) {
|
|
199
291
|
hasAccidental = true;
|
|
200
292
|
noteName = noteName.substring(0, 1) + "#" + noteName.substring(1);
|
|
@@ -245,12 +337,20 @@ class SongParser {
|
|
|
245
337
|
if (restTiming.duration) {
|
|
246
338
|
durationTicks *= restTiming.duration;
|
|
247
339
|
}
|
|
340
|
+
if (restTiming.dots) {
|
|
341
|
+
durationTicks *= dottedMultiplier(restTiming.dots);
|
|
342
|
+
}
|
|
248
343
|
}
|
|
249
344
|
state.position += Math.round(durationTicks);
|
|
250
345
|
break;
|
|
251
346
|
}
|
|
252
347
|
case "keySignature": {
|
|
253
|
-
|
|
348
|
+
const [, count, sourceLocation] = command;
|
|
349
|
+
state.keySignature = new KeySignature(count);
|
|
350
|
+
if (!song.keySignatures) {
|
|
351
|
+
song.keySignatures = [];
|
|
352
|
+
}
|
|
353
|
+
song.keySignatures.push([state.position / TICKS_PER_BEAT, count, sourceLocation]);
|
|
254
354
|
break;
|
|
255
355
|
}
|
|
256
356
|
case "timeSignature": {
|
|
@@ -298,6 +398,7 @@ class SongParser {
|
|
|
298
398
|
}
|
|
299
399
|
}
|
|
300
400
|
}
|
|
401
|
+
/** The PEG.js parser module for direct access to grammar */
|
|
301
402
|
SongParser.peg = peg;
|
|
302
403
|
export default SongParser;
|
|
303
404
|
//# sourceMappingURL=parser.js.map
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAY,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAA;AAEhE,2DAA2D;AAC3D,4DAA4D;AAC5D,MAAM,cAAc,GAAG,EAAE,CAAA;AAEzB;;;GAGG;AACH,SAAS,iBAAiB,CAAC,UAAkB,EAAE,cAAsB;IACnE,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IACjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,GAAG,KAAK,CAAA;IACpC,IAAI,UAAU,GAAG,OAAO,CAAC,MAAM,CAAW,CAAA;IAE1C,IAAI,UAAU,KAAK,GAAG;QAAE,UAAU,IAAI,CAAC,CAAA;IACvC,IAAI,UAAU,KAAK,GAAG;QAAE,UAAU,IAAI,CAAC,CAAA;IAEvC,oDAAoD;IACpD,UAAU,GAAG,CAAC,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,WAAW,CAAC,GAAG,WAAW,CAAA;IAErE,mCAAmC;IACnC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,cAA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AAK,CAAC,QAAQ,GAAG,cAAc,EAAE,KAAK,CAAC,CAAC,CAAA;oBAChE,CAAC;oBAED,MAAK;gBACP,CAAC;gBACD,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO,CAAA;oBACxB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;wBAClB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;oBACnB,CAAC;oBACD,qCAAqC;oBACrC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,cAAc,EAAE,IAAI,CAAC,CAAC,CAAA;oBAC1D,MAAK;gBACP,CAAC;gBACD,KAAK,aAAa,CAAC,CAAC,CAAC;oBACnB,4CAA4C;oBAC5C,MAAK;gBACP,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,OAAO,CAAC,IAAI,CAAC,uCAAuC,EAAE,OAAO,CAAC,CAAA;gBAChE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;;AApWD,4DAA4D;AACrD,cAAG,GAAG,GAAG,CAAA;eAFG,UAAU"}
|
package/dist/song.d.ts
CHANGED
|
@@ -1,59 +1,255 @@
|
|
|
1
|
+
import { type ChordShapeName } from "./music.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a single musical note with pitch, timing, and duration.
|
|
4
|
+
* @example
|
|
5
|
+
* const note = new SongNote("C4", 0, 1) // Middle C at beat 0, duration 1 beat
|
|
6
|
+
* const note2 = new SongNote("D#5", 4, 0.5) // D#5 at beat 4, half beat duration
|
|
7
|
+
*/
|
|
1
8
|
export declare class SongNote {
|
|
9
|
+
/** Unique identifier for this note instance */
|
|
2
10
|
id: symbol;
|
|
11
|
+
/** Note name with octave (e.g., "C4", "D#5", "Bb3") */
|
|
3
12
|
note: string;
|
|
13
|
+
/** Start position in beats */
|
|
4
14
|
start: number;
|
|
15
|
+
/** Duration in beats */
|
|
5
16
|
duration: number;
|
|
17
|
+
/** Source location in LML text as [startOffset, endOffset], used for editor features */
|
|
6
18
|
sourceLocation?: [number, number];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new SongNote.
|
|
21
|
+
* @param note - Note name with octave (e.g., "C4", "D#5")
|
|
22
|
+
* @param start - Start position in beats
|
|
23
|
+
* @param duration - Duration in beats
|
|
24
|
+
* @param sourceLocation - Optional source location in LML text [startOffset, endOffset]
|
|
25
|
+
*/
|
|
7
26
|
constructor(note: string, start: number, duration: number, sourceLocation?: [number, number]);
|
|
27
|
+
/**
|
|
28
|
+
* Creates a copy of this note.
|
|
29
|
+
* @returns A new SongNote with the same properties
|
|
30
|
+
*/
|
|
8
31
|
clone(): SongNote;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if this note overlaps with a time range.
|
|
34
|
+
* @param min - Start of the range in beats
|
|
35
|
+
* @param max - End of the range in beats
|
|
36
|
+
* @returns True if the note overlaps with the range
|
|
37
|
+
*/
|
|
9
38
|
inRange(min: number, max: number): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new note transposed by a number of semitones.
|
|
41
|
+
* @param semitones - Number of semitones to transpose (positive = up, negative = down)
|
|
42
|
+
* @returns A new SongNote with the transposed pitch
|
|
43
|
+
* @example
|
|
44
|
+
* const c4 = new SongNote("C4", 0, 1)
|
|
45
|
+
* const d4 = c4.transpose(2) // D4
|
|
46
|
+
* const b3 = c4.transpose(-1) // B3
|
|
47
|
+
*/
|
|
10
48
|
transpose(semitones: number): SongNote;
|
|
49
|
+
/** Returns the start position in beats. */
|
|
11
50
|
getStart(): number;
|
|
51
|
+
/** Returns the end position in beats (start + duration). */
|
|
12
52
|
getStop(): number;
|
|
53
|
+
/** Returns the end position for rendering purposes. */
|
|
13
54
|
getRenderStop(): number;
|
|
55
|
+
/** Returns a string representation of the note. */
|
|
14
56
|
toString(): string;
|
|
15
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Metadata associated with a parsed song.
|
|
60
|
+
*/
|
|
16
61
|
export interface SongMetadata {
|
|
62
|
+
/** Key signature as number of accidentals (positive = sharps, negative = flats) */
|
|
17
63
|
keySignature?: number;
|
|
64
|
+
/** Number of beats per measure */
|
|
18
65
|
beatsPerMeasure?: number;
|
|
66
|
+
/** Frontmatter key-value pairs from the LML source */
|
|
19
67
|
frontmatter?: Record<string, string>;
|
|
20
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* A list of notes representing a song or track, with associated metadata.
|
|
71
|
+
* Extends Array<SongNote> to allow direct indexing and array methods.
|
|
72
|
+
* @example
|
|
73
|
+
* const song = SongNoteList.newSong([
|
|
74
|
+
* ["C4", 0, 1],
|
|
75
|
+
* ["E4", 1, 1],
|
|
76
|
+
* ["G4", 2, 1],
|
|
77
|
+
* ])
|
|
78
|
+
* song.transpose(2) // Transpose up a whole step
|
|
79
|
+
*/
|
|
21
80
|
export declare class SongNoteList extends Array<SongNote> {
|
|
81
|
+
/** Bucket size in beats for spatial indexing optimization */
|
|
22
82
|
static bucketSize: number;
|
|
83
|
+
/** Song metadata including key signature and time signature */
|
|
23
84
|
metadata?: SongMetadata;
|
|
24
|
-
|
|
85
|
+
/** Auto chord markers as [beat_position, [root, chord_shape]][] */
|
|
86
|
+
autoChords?: [number, [string, ChordShapeName]][];
|
|
87
|
+
/** Clef changes as [beat_position, clef_name][] */
|
|
25
88
|
clefs?: [number, string][];
|
|
89
|
+
/** String annotations as [beat_position, text][] */
|
|
26
90
|
strings?: [number, string][];
|
|
91
|
+
/** Time signature changes as [beat_position, beats_per_measure][] */
|
|
27
92
|
timeSignatures?: [number, number][];
|
|
93
|
+
/** Key signature changes as [beat_position, accidental_count, source_location][] */
|
|
94
|
+
keySignatures?: [number, number, [number, number]][];
|
|
95
|
+
/** Optional track name */
|
|
28
96
|
trackName?: string;
|
|
97
|
+
/** Cached spatial index buckets for fast note lookup */
|
|
29
98
|
private buckets?;
|
|
30
99
|
constructor();
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new SongNoteList from an array of note tuples.
|
|
102
|
+
* @param noteTuples - Array of [note, start, duration] tuples
|
|
103
|
+
* @returns A new SongNoteList containing the notes
|
|
104
|
+
* @example
|
|
105
|
+
* const song = SongNoteList.newSong([
|
|
106
|
+
* ["C4", 0, 1],
|
|
107
|
+
* ["D4", 1, 1],
|
|
108
|
+
* ])
|
|
109
|
+
*/
|
|
31
110
|
static newSong(noteTuples: [string, number, number][]): SongNoteList;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a deep copy of this song (notes are cloned).
|
|
113
|
+
* @returns A new SongNoteList with cloned notes
|
|
114
|
+
*/
|
|
32
115
|
clone(): SongNoteList;
|
|
116
|
+
/**
|
|
117
|
+
* Clears the spatial index cache. Call this after modifying notes.
|
|
118
|
+
*/
|
|
33
119
|
clearCache(): void;
|
|
120
|
+
/**
|
|
121
|
+
* Creates a new song with all notes and key signatures transposed.
|
|
122
|
+
* Uses circle of fifths for key signature transposition.
|
|
123
|
+
* Returns `this` if amount is 0.
|
|
124
|
+
* @param amount - Number of semitones to transpose (positive = up, negative = down)
|
|
125
|
+
* @returns A new SongNoteList with transposed notes, or `this` if amount is 0
|
|
126
|
+
* @example
|
|
127
|
+
* const song = parser.compile(parser.parse("ks0 c d e"))
|
|
128
|
+
* const transposed = song.transpose(1) // Transposes to Db major
|
|
129
|
+
* // transposed.metadata.keySignature === -5
|
|
130
|
+
*/
|
|
34
131
|
transpose(amount?: number): SongNoteList;
|
|
132
|
+
/**
|
|
133
|
+
* Transposes notes from this song into the target song.
|
|
134
|
+
* Override in subclasses for custom note handling (e.g., multi-track).
|
|
135
|
+
* @param target - The song to add transposed notes to
|
|
136
|
+
* @param amount - Number of semitones to transpose
|
|
137
|
+
*/
|
|
138
|
+
protected transposeNotesInto(target: SongNoteList, amount: number): void;
|
|
139
|
+
/**
|
|
140
|
+
* Finds all notes that overlap with a time range.
|
|
141
|
+
* @param start - Start of the range in beats
|
|
142
|
+
* @param stop - End of the range in beats
|
|
143
|
+
* @returns Array of notes that overlap with the range
|
|
144
|
+
*/
|
|
35
145
|
notesInRange(start: number, stop: number): SongNote[];
|
|
146
|
+
/**
|
|
147
|
+
* Finds indices of notes whose source location overlaps with a text selection.
|
|
148
|
+
* Used for editor features like transposition of selected notes.
|
|
149
|
+
* @param start - Start offset in source text
|
|
150
|
+
* @param end - End offset in source text
|
|
151
|
+
* @returns Set of note indices that overlap with the selection
|
|
152
|
+
*/
|
|
36
153
|
findNotesForSelection(start: number, end: number): Set<number>;
|
|
154
|
+
/**
|
|
155
|
+
* Finds key signatures whose source location overlaps with a text selection.
|
|
156
|
+
* Used for editor features like transposition of selected key signatures.
|
|
157
|
+
* @param start - Start offset in source text
|
|
158
|
+
* @param end - End offset in source text
|
|
159
|
+
* @returns Array of key signature entries that overlap with the selection
|
|
160
|
+
*/
|
|
161
|
+
findKeySignaturesForSelection(start: number, end: number): [number, number, [number, number]][];
|
|
162
|
+
/**
|
|
163
|
+
* Returns the end position of the last note in beats.
|
|
164
|
+
* @returns End position in beats, or 0 if empty
|
|
165
|
+
*/
|
|
37
166
|
getStopInBeats(): number;
|
|
167
|
+
/**
|
|
168
|
+
* Returns the start position of the first note in beats.
|
|
169
|
+
* @returns Start position in beats, or 0 if empty
|
|
170
|
+
*/
|
|
38
171
|
getStartInBeats(): number;
|
|
172
|
+
/**
|
|
173
|
+
* Calculates measure boundaries based on time signatures.
|
|
174
|
+
* @returns Array of measure objects with start position and beat count
|
|
175
|
+
*/
|
|
39
176
|
getMeasures(): {
|
|
40
177
|
start: number;
|
|
41
178
|
beats: number;
|
|
42
179
|
}[];
|
|
180
|
+
/**
|
|
181
|
+
* Returns the pitch range of all notes in the song.
|
|
182
|
+
* @returns Tuple of [lowest, highest] note names, or undefined if empty
|
|
183
|
+
*/
|
|
43
184
|
noteRange(): [string, string] | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Determines the best staff type for displaying this song.
|
|
187
|
+
* @returns "treble", "bass", or "grand" based on note range and clef settings
|
|
188
|
+
*/
|
|
44
189
|
fittingStaff(): "treble" | "bass" | "grand";
|
|
190
|
+
/** Calculates the bucket range for a time span. */
|
|
45
191
|
private getBucketRange;
|
|
192
|
+
/** Builds the spatial index buckets for fast note lookup. */
|
|
46
193
|
private buildBuckets;
|
|
194
|
+
/** Gets the buckets to scan when matching notes near a beat. */
|
|
47
195
|
private adjacentBuckets;
|
|
196
|
+
/** Gets or builds the spatial index buckets. */
|
|
48
197
|
private getBuckets;
|
|
198
|
+
/**
|
|
199
|
+
* Finds the note closest to a beat position using spatial indexing.
|
|
200
|
+
* Faster than matchNote for large songs.
|
|
201
|
+
* @param findNote - Note name to search for (e.g., "C4")
|
|
202
|
+
* @param beat - Beat position to search near
|
|
203
|
+
* @param wrapRight - Optional right boundary for wrap-around search
|
|
204
|
+
* @param wrapLeft - Optional left boundary for wrap-around search
|
|
205
|
+
* @returns Index of the matching note, or null if not found
|
|
206
|
+
*/
|
|
49
207
|
matchNoteFast(findNote: string, beat: number, wrapRight?: number, wrapLeft?: number): number | null;
|
|
208
|
+
/**
|
|
209
|
+
* Finds the note closest to a beat position using linear search.
|
|
210
|
+
* Use matchNoteFast for better performance on large songs.
|
|
211
|
+
* @param findNote - Note name to search for (e.g., "C4")
|
|
212
|
+
* @param beat - Beat position to search near
|
|
213
|
+
* @returns Index of the matching note, or null if not found
|
|
214
|
+
*/
|
|
50
215
|
matchNote(findNote: string, beat: number): number | null;
|
|
51
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* A song containing multiple tracks, where each track is a SongNoteList.
|
|
219
|
+
* Notes are stored both in the main list and in their respective tracks.
|
|
220
|
+
* @example
|
|
221
|
+
* const song = new MultiTrackSong()
|
|
222
|
+
* song.pushWithTrack(new SongNote("C4", 0, 1), 0) // Track 0
|
|
223
|
+
* song.pushWithTrack(new SongNote("E4", 0, 1), 1) // Track 1
|
|
224
|
+
*/
|
|
52
225
|
export declare class MultiTrackSong extends SongNoteList {
|
|
226
|
+
/** Array of individual tracks */
|
|
53
227
|
tracks: SongNoteList[];
|
|
54
228
|
constructor();
|
|
229
|
+
/**
|
|
230
|
+
* Adds a note to both the main song and a specific track.
|
|
231
|
+
* @param note - The note to add
|
|
232
|
+
* @param trackIdx - The track index to add the note to
|
|
233
|
+
* @returns The added note
|
|
234
|
+
*/
|
|
55
235
|
pushWithTrack(note: SongNote, trackIdx: number): SongNote;
|
|
236
|
+
/**
|
|
237
|
+
* Finds an unused track index for auto-generated content like chords.
|
|
238
|
+
* @returns The next available track index
|
|
239
|
+
*/
|
|
56
240
|
findEmptyTrackIdx(): number;
|
|
241
|
+
/**
|
|
242
|
+
* Gets a track by index, creating it if it doesn't exist.
|
|
243
|
+
* @param idx - The track index
|
|
244
|
+
* @returns The SongNoteList for the track
|
|
245
|
+
*/
|
|
57
246
|
getTrack(idx: number): SongNoteList;
|
|
247
|
+
/**
|
|
248
|
+
* Transposes notes from this song into the target song, handling tracks.
|
|
249
|
+
* Notes are transposed per-track and added to both the track and main list.
|
|
250
|
+
* @param target - The MultiTrackSong to add transposed notes to
|
|
251
|
+
* @param amount - Number of semitones to transpose
|
|
252
|
+
*/
|
|
253
|
+
protected transposeNotesInto(target: SongNoteList, amount: number): void;
|
|
58
254
|
}
|
|
59
255
|
//# sourceMappingURL=song.d.ts.map
|
package/dist/song.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"song.d.ts","sourceRoot":"","sources":["../src/song.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"song.d.ts","sourceRoot":"","sources":["../src/song.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8D,KAAK,cAAc,EAAE,MAAM,YAAY,CAAA;AAE5G;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAA;IACV,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,wBAAwB;IACxB,QAAQ,EAAE,MAAM,C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