@webmusic/bridge 0.0.0-stage → 0.4.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +97 -2
- package/dist/THIRD_PARTY_NOTICES.txt +1605 -0
- package/dist/build-receipt.json +7 -0
- package/dist/chunk-XQXQSBVS.js +408 -0
- package/dist/chunk-XQXQSBVS.js.map +1 -0
- package/dist/component/global.cjs +19 -0
- package/dist/component/global.cjs.map +1 -0
- package/dist/component/global.d.ts +9 -0
- package/dist/component/global.js +1 -0
- package/dist/component/global.js.map +1 -0
- package/dist/component.cjs +3091 -0
- package/dist/component.cjs.map +1 -0
- package/dist/component.d.cts +860 -0
- package/dist/component.d.ts +860 -0
- package/dist/component.global.js +3541 -0
- package/dist/component.global.js.map +1 -0
- package/dist/component.js +2672 -0
- package/dist/component.js.map +1 -0
- package/dist/index.cjs +707 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +143 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +298 -0
- package/dist/index.js.map +1 -0
- package/package.json +91 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createWebMusicProjectPlugins,
|
|
3
|
+
registerAudioParticipant
|
|
4
|
+
} from "./chunk-XQXQSBVS.js";
|
|
5
|
+
|
|
6
|
+
// src/mapping.ts
|
|
7
|
+
import { Rational, TimeMap } from "@webmusic/score";
|
|
8
|
+
import { BeatGrid } from "@webmusic/audio";
|
|
9
|
+
var DEFAULT_MAX_MAPPED_BEATS = 1e6;
|
|
10
|
+
function beatGridFromTimeMap(map, options) {
|
|
11
|
+
const { durationQuarters, beatsPerQuarter = 1, maxBeats = DEFAULT_MAX_MAPPED_BEATS } = options;
|
|
12
|
+
if (!Number.isFinite(durationQuarters) || durationQuarters <= 0) {
|
|
13
|
+
throw new RangeError("durationQuarters must be finite and > 0");
|
|
14
|
+
}
|
|
15
|
+
if (!Number.isSafeInteger(beatsPerQuarter) || beatsPerQuarter < 1) {
|
|
16
|
+
throw new RangeError("beatsPerQuarter must be a positive safe integer");
|
|
17
|
+
}
|
|
18
|
+
if (!Number.isSafeInteger(maxBeats) || maxBeats < 2) {
|
|
19
|
+
throw new RangeError("maxBeats must be a safe integer >= 2");
|
|
20
|
+
}
|
|
21
|
+
const scaledDuration = durationQuarters * beatsPerQuarter;
|
|
22
|
+
const nearestInteger = Math.round(scaledDuration);
|
|
23
|
+
const ulpTolerance = Number.EPSILON * Math.max(1, Math.abs(scaledDuration)) * 4;
|
|
24
|
+
const normalizedDuration = Math.abs(scaledDuration - nearestInteger) <= ulpTolerance ? nearestInteger : scaledDuration;
|
|
25
|
+
const total = Math.ceil(normalizedDuration);
|
|
26
|
+
if (!Number.isSafeInteger(total) || total >= maxBeats) {
|
|
27
|
+
throw new RangeError(
|
|
28
|
+
`Beat-grid mapping would allocate more than maxBeats (${maxBeats.toLocaleString()}) samples.`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const beats = [];
|
|
32
|
+
for (let index = 0; index <= total; index++) {
|
|
33
|
+
beats.push(map.quartersToSeconds(new Rational(index, beatsPerQuarter)));
|
|
34
|
+
}
|
|
35
|
+
const tempo = map.tempoAt(Rational.ZERO);
|
|
36
|
+
const bpm = tempo.bpm * (tempo.unit ?? 1) * beatsPerQuarter;
|
|
37
|
+
return new BeatGrid({ bpm, beats });
|
|
38
|
+
}
|
|
39
|
+
function timeMapFromBeatGrid(grid) {
|
|
40
|
+
const beats = grid.beats;
|
|
41
|
+
const tempi = [];
|
|
42
|
+
if (beats.length < 2) {
|
|
43
|
+
tempi.push({ atQuarters: Rational.ZERO, bpm: grid.bpm });
|
|
44
|
+
} else {
|
|
45
|
+
for (let index = 0; index < beats.length - 1; index++) {
|
|
46
|
+
const interval = beats[index + 1] - beats[index];
|
|
47
|
+
if (!(interval > 0)) {
|
|
48
|
+
throw new RangeError(`BeatGrid interval at beat ${index} is not positive (${interval}).`);
|
|
49
|
+
}
|
|
50
|
+
tempi.push({ atQuarters: new Rational(index, 1), bpm: 60 / interval });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return new TimeMap(tempi, [
|
|
54
|
+
{ atQuarters: Rational.ZERO, measureNumber: 1, timeSignature: { numerator: 4, denominator: 4 } }
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/render.ts
|
|
59
|
+
import { createAudioClip } from "@webmusic/audio";
|
|
60
|
+
import { renderScoreToBuffer } from "@webmusic/score/play";
|
|
61
|
+
async function renderScoreToClip(score, options) {
|
|
62
|
+
const tempo = options?.tempo;
|
|
63
|
+
if (tempo !== void 0 && (!Number.isFinite(tempo) || tempo <= 0)) {
|
|
64
|
+
throw new RangeError("renderScoreToClip tempo must be finite and > 0.");
|
|
65
|
+
}
|
|
66
|
+
const tail = options?.tailSeconds;
|
|
67
|
+
if (tail !== void 0 && (!Number.isFinite(tail) || tail < 0)) {
|
|
68
|
+
throw new RangeError("renderScoreToClip tailSeconds must be finite and >= 0.");
|
|
69
|
+
}
|
|
70
|
+
const buffer = await renderScoreToBuffer(score, options);
|
|
71
|
+
const channelData = [];
|
|
72
|
+
for (let channel = 0; channel < buffer.numberOfChannels; channel++) {
|
|
73
|
+
channelData.push(buffer.getChannelData(channel));
|
|
74
|
+
}
|
|
75
|
+
return createAudioClip({ channelData, sampleRate: buffer.sampleRate });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/session.ts
|
|
79
|
+
import { AudioPlayer } from "@webmusic/audio/play/headless";
|
|
80
|
+
import { ModuleAudioEnvironment, ModuleContext, routeModuleOutput } from "@webmusic/kernel/module";
|
|
81
|
+
import { SessionTransport } from "@webmusic/kernel/session";
|
|
82
|
+
import { ScorePlayerModule } from "@webmusic/score/play/headless";
|
|
83
|
+
function createScoreAudioSession(score, clip, options = {}) {
|
|
84
|
+
const audio = new ModuleAudioEnvironment(options.context ? { context: options.context } : {});
|
|
85
|
+
const session = new SessionTransport(() => audio.peek()?.currentTime ?? 0, {
|
|
86
|
+
...options.leadInSeconds !== void 0 ? { leadInSeconds: options.leadInSeconds } : {},
|
|
87
|
+
onOperationError: options.onOperationError
|
|
88
|
+
});
|
|
89
|
+
const context = new ModuleContext({ id: "score-audio-session", audio, session });
|
|
90
|
+
let scoreModule;
|
|
91
|
+
let clipPlayer;
|
|
92
|
+
let participant;
|
|
93
|
+
let route;
|
|
94
|
+
let disposed = false;
|
|
95
|
+
const dispose = () => {
|
|
96
|
+
if (disposed) return;
|
|
97
|
+
disposed = true;
|
|
98
|
+
let failure;
|
|
99
|
+
for (const release of [
|
|
100
|
+
() => participant?.release(),
|
|
101
|
+
() => route?.release(),
|
|
102
|
+
() => clipPlayer?.dispose(),
|
|
103
|
+
() => scoreModule?.dispose(),
|
|
104
|
+
() => session.dispose(),
|
|
105
|
+
() => audio.dispose()
|
|
106
|
+
]) {
|
|
107
|
+
try {
|
|
108
|
+
release();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
failure ?? (failure = error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (failure !== void 0) throw failure;
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
scoreModule = new ScorePlayerModule(score, {
|
|
117
|
+
id: "score",
|
|
118
|
+
context,
|
|
119
|
+
synth: options.synth,
|
|
120
|
+
offsetSeconds: options.scoreOffsetSeconds,
|
|
121
|
+
positionScale: options.scorePositionScale,
|
|
122
|
+
onError: (error) => options.onOperationError?.("score", error)
|
|
123
|
+
});
|
|
124
|
+
const player = new AudioPlayer(clip, { moduleContext: context });
|
|
125
|
+
clipPlayer = player;
|
|
126
|
+
participant = registerAudioParticipant(session, player, {
|
|
127
|
+
offsetSeconds: options.clipOffsetSeconds,
|
|
128
|
+
positionScale: options.clipPositionScale,
|
|
129
|
+
prepare: async () => {
|
|
130
|
+
await player.preload();
|
|
131
|
+
if (disposed) throw new Error("Score/Audio Session was disposed during preparation.");
|
|
132
|
+
if (!route) route = routeModuleOutput(context, { id: "clip", getPort: () => player.outputPort }, player.outputPort);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
} catch (error) {
|
|
136
|
+
try {
|
|
137
|
+
dispose();
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
return Object.freeze({ session, context, scoreModule, clipPlayer, dispose });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/transcription.ts
|
|
146
|
+
import {
|
|
147
|
+
Duration,
|
|
148
|
+
MeasureId,
|
|
149
|
+
PartId,
|
|
150
|
+
Pitch,
|
|
151
|
+
Rational as Rational2,
|
|
152
|
+
ScoreBuilder,
|
|
153
|
+
VoiceId
|
|
154
|
+
} from "@webmusic/score";
|
|
155
|
+
var TICKS_PER_QUARTER = 480;
|
|
156
|
+
var DEFAULT_MAX_TRANSCRIPTION_NOTES = 1e5;
|
|
157
|
+
var DEFAULT_MAX_TRANSCRIPTION_MEASURES = 4096;
|
|
158
|
+
function scoreFromTranscription(notes, options = {}) {
|
|
159
|
+
const bpm = options.bpm ?? 120;
|
|
160
|
+
if (!(Number.isFinite(bpm) && bpm > 0)) {
|
|
161
|
+
throw new RangeError(`scoreFromTranscription: bpm must be finite and > 0, got ${bpm}.`);
|
|
162
|
+
}
|
|
163
|
+
const grid = options.quantizeGrid ?? 4;
|
|
164
|
+
if (!(Number.isSafeInteger(grid) && grid >= 0)) {
|
|
165
|
+
throw new RangeError(`scoreFromTranscription: quantizeGrid must be a non-negative safe integer, got ${grid}.`);
|
|
166
|
+
}
|
|
167
|
+
const timeSignature = options.timeSignature ?? { numerator: 4, denominator: 4 };
|
|
168
|
+
if (!Number.isSafeInteger(timeSignature.numerator) || timeSignature.numerator < 1 || !Number.isSafeInteger(timeSignature.denominator) || timeSignature.denominator < 1) {
|
|
169
|
+
throw new RangeError("scoreFromTranscription: timeSignature values must be positive safe integers.");
|
|
170
|
+
}
|
|
171
|
+
const maxNotes = resolvePositiveLimit(
|
|
172
|
+
"maxNotes",
|
|
173
|
+
options.maxNotes,
|
|
174
|
+
DEFAULT_MAX_TRANSCRIPTION_NOTES
|
|
175
|
+
);
|
|
176
|
+
const maxMeasures = resolvePositiveLimit(
|
|
177
|
+
"maxMeasures",
|
|
178
|
+
options.maxMeasures,
|
|
179
|
+
DEFAULT_MAX_TRANSCRIPTION_MEASURES
|
|
180
|
+
);
|
|
181
|
+
if (notes.length > maxNotes) {
|
|
182
|
+
throw new RangeError(
|
|
183
|
+
`Transcription resource limit exceeded: ${notes.length.toLocaleString()} note events (maxNotes is ${maxNotes.toLocaleString()}).`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const denominator = grid > 0 ? grid : TICKS_PER_QUARTER;
|
|
187
|
+
const secondsToQuarterUnits = (seconds, label) => {
|
|
188
|
+
const units = Math.round(seconds * bpm * denominator / 60);
|
|
189
|
+
if (!Number.isSafeInteger(units)) {
|
|
190
|
+
throw new RangeError(`scoreFromTranscription: ${label} is too large to represent safely.`);
|
|
191
|
+
}
|
|
192
|
+
return units;
|
|
193
|
+
};
|
|
194
|
+
const builder = new ScoreBuilder();
|
|
195
|
+
builder.setMetadata({ title: options.title ?? "Transcription" }).addTempo({ atQuarters: Rational2.ZERO, bpm }).addMeter({ atQuarters: Rational2.ZERO, measureNumber: 1, timeSignature });
|
|
196
|
+
const partId = PartId("transcription");
|
|
197
|
+
const voice = VoiceId("v1");
|
|
198
|
+
builder.addPart({ id: partId, name: options.partName ?? "Transcribed", staves: 1 });
|
|
199
|
+
let maxEndUnits = 0;
|
|
200
|
+
for (const [index, note] of notes.entries()) {
|
|
201
|
+
if (!Number.isFinite(note.midi)) {
|
|
202
|
+
throw new RangeError(`scoreFromTranscription: note ${index} pitch must be finite.`);
|
|
203
|
+
}
|
|
204
|
+
const midi = Math.round(note.midi);
|
|
205
|
+
if (midi < 0 || midi > 127) continue;
|
|
206
|
+
if (!Number.isFinite(note.startSeconds) || note.startSeconds < 0 || !Number.isFinite(note.endSeconds) || note.endSeconds < note.startSeconds) {
|
|
207
|
+
throw new RangeError(
|
|
208
|
+
`scoreFromTranscription: note ${index} must have finite, non-negative, ordered start/end seconds.`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
if (!Number.isFinite(note.velocity)) {
|
|
212
|
+
throw new RangeError(`scoreFromTranscription: note ${index} velocity must be finite.`);
|
|
213
|
+
}
|
|
214
|
+
const onsetUnits = secondsToQuarterUnits(note.startSeconds, `note ${index} startSeconds`);
|
|
215
|
+
const endUnits = Math.max(
|
|
216
|
+
onsetUnits + 1,
|
|
217
|
+
secondsToQuarterUnits(note.endSeconds, `note ${index} endSeconds`)
|
|
218
|
+
);
|
|
219
|
+
if (!Number.isSafeInteger(endUnits)) {
|
|
220
|
+
throw new RangeError(`scoreFromTranscription: note ${index} duration is too large to represent safely.`);
|
|
221
|
+
}
|
|
222
|
+
maxEndUnits = Math.max(maxEndUnits, endUnits);
|
|
223
|
+
builder.addNote(partId, {
|
|
224
|
+
id: builder.newNoteId(),
|
|
225
|
+
pitch: Pitch.fromMidi(midi),
|
|
226
|
+
onsetQuarters: new Rational2(onsetUnits, denominator),
|
|
227
|
+
duration: new Duration({ base: new Rational2(endUnits - onsetUnits, denominator) }),
|
|
228
|
+
voice,
|
|
229
|
+
performed: {
|
|
230
|
+
onsetSec: note.startSeconds,
|
|
231
|
+
durationSec: Math.max(0, note.endSeconds - note.startSeconds),
|
|
232
|
+
velocity: Math.min(127, Math.max(1, Math.round(note.velocity * 127)))
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const materialUnits = BigInt(maxEndUnits) * BigInt(timeSignature.denominator);
|
|
237
|
+
const measureUnits = BigInt(denominator) * BigInt(timeSignature.numerator) * 4n;
|
|
238
|
+
const exactMeasureCount = materialUnits === 0n ? 1n : (materialUnits + measureUnits - 1n) / measureUnits;
|
|
239
|
+
if (exactMeasureCount > BigInt(maxMeasures)) {
|
|
240
|
+
throw new RangeError(
|
|
241
|
+
`Transcription resource limit exceeded: score would create ${exactMeasureCount.toLocaleString()} measures (maxMeasures is ${maxMeasures.toLocaleString()}).`
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
const measureCount = Number(exactMeasureCount);
|
|
245
|
+
const quartersPerMeasure = quartersPerMeasureFrom(timeSignature);
|
|
246
|
+
for (let index = 0; index < measureCount; index++) {
|
|
247
|
+
builder.addMeasure({
|
|
248
|
+
id: MeasureId(`m${index + 1}`),
|
|
249
|
+
number: index + 1,
|
|
250
|
+
onsetQuarters: quartersPerMeasure.mul(new Rational2(index, 1)),
|
|
251
|
+
durationQuarters: quartersPerMeasure,
|
|
252
|
+
timeSignature
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return builder.build();
|
|
256
|
+
}
|
|
257
|
+
function resolvePositiveLimit(name, value, fallback) {
|
|
258
|
+
if (value === void 0) return fallback;
|
|
259
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
260
|
+
throw new RangeError(`scoreFromTranscription: ${name} must be a positive safe integer.`);
|
|
261
|
+
}
|
|
262
|
+
return value;
|
|
263
|
+
}
|
|
264
|
+
function quartersPerMeasureFrom(timeSignature) {
|
|
265
|
+
let numerator = BigInt(timeSignature.numerator) * 4n;
|
|
266
|
+
let denominator = BigInt(timeSignature.denominator);
|
|
267
|
+
const divisor = greatestCommonDivisor(numerator, denominator);
|
|
268
|
+
numerator /= divisor;
|
|
269
|
+
denominator /= divisor;
|
|
270
|
+
const maxSafe = BigInt(Number.MAX_SAFE_INTEGER);
|
|
271
|
+
if (numerator > maxSafe || denominator > maxSafe) {
|
|
272
|
+
throw new RangeError(
|
|
273
|
+
"scoreFromTranscription: timeSignature measure duration is too large to represent safely."
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return new Rational2(Number(numerator), Number(denominator));
|
|
277
|
+
}
|
|
278
|
+
function greatestCommonDivisor(left, right) {
|
|
279
|
+
while (right !== 0n) {
|
|
280
|
+
const remainder = left % right;
|
|
281
|
+
left = right;
|
|
282
|
+
right = remainder;
|
|
283
|
+
}
|
|
284
|
+
return left;
|
|
285
|
+
}
|
|
286
|
+
export {
|
|
287
|
+
DEFAULT_MAX_MAPPED_BEATS,
|
|
288
|
+
DEFAULT_MAX_TRANSCRIPTION_MEASURES,
|
|
289
|
+
DEFAULT_MAX_TRANSCRIPTION_NOTES,
|
|
290
|
+
beatGridFromTimeMap,
|
|
291
|
+
createScoreAudioSession,
|
|
292
|
+
createWebMusicProjectPlugins,
|
|
293
|
+
registerAudioParticipant,
|
|
294
|
+
renderScoreToClip,
|
|
295
|
+
scoreFromTranscription,
|
|
296
|
+
timeMapFromBeatGrid
|
|
297
|
+
};
|
|
298
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mapping.ts","../src/render.ts","../src/session.ts","../src/transcription.ts"],"sourcesContent":["// ============================================================================\n// Timeline conversions between the two families' musical time models.\n// TimeMap → BeatGrid is lossless sampling (evaluate the exact map at each\n// beat); BeatGrid → TimeMap is approximate (each inter-beat interval becomes\n// one tempo segment). Both project onto the same seconds ruler, which is what\n// makes score↔audio alignment composable.\n// ============================================================================\n\nimport {Rational, TimeMap, type TempoEntry} from '@webmusic/score';\nimport {BeatGrid} from '@webmusic/audio';\n\nexport interface BeatGridFromTimeMapOptions {\n /** How many quarters of the score timeline to sample. */\n durationQuarters: number;\n /** Beat subdivisions per quarter note (default 1: beat = quarter). */\n beatsPerQuarter?: number;\n /** Maximum number of beat samples to allocate. Default 1,000,000. */\n maxBeats?: number;\n}\n\nexport const DEFAULT_MAX_MAPPED_BEATS = 1_000_000;\n\n/**\n * Sample a {@link TimeMap} into a {@link BeatGrid}: one beat per\n * `1/beatsPerQuarter` quarter from 0 through `durationQuarters`. Lossless up\n * to the sampling density — tempo changes between sampled beats interpolate\n * linearly on the grid.\n */\nexport function beatGridFromTimeMap(map: TimeMap, options: BeatGridFromTimeMapOptions): BeatGrid {\n const {durationQuarters, beatsPerQuarter = 1, maxBeats = DEFAULT_MAX_MAPPED_BEATS} = options;\n if (!Number.isFinite(durationQuarters) || durationQuarters <= 0) {\n throw new RangeError('durationQuarters must be finite and > 0');\n }\n if (!Number.isSafeInteger(beatsPerQuarter) || beatsPerQuarter < 1) {\n throw new RangeError('beatsPerQuarter must be a positive safe integer');\n }\n if (!Number.isSafeInteger(maxBeats) || maxBeats < 2) {\n throw new RangeError('maxBeats must be a safe integer >= 2');\n }\n const scaledDuration = durationQuarters * beatsPerQuarter;\n const nearestInteger = Math.round(scaledDuration);\n const ulpTolerance = Number.EPSILON * Math.max(1, Math.abs(scaledDuration)) * 4;\n const normalizedDuration =\n Math.abs(scaledDuration - nearestInteger) <= ulpTolerance\n ? nearestInteger\n : scaledDuration;\n const total = Math.ceil(normalizedDuration);\n if (!Number.isSafeInteger(total) || total >= maxBeats) {\n throw new RangeError(\n `Beat-grid mapping would allocate more than maxBeats (${maxBeats.toLocaleString()}) samples.`,\n );\n }\n const beats: number[] = [];\n for (let index = 0; index <= total; index++) {\n beats.push(map.quartersToSeconds(new Rational(index, beatsPerQuarter)));\n }\n // The sampled positions come from quartersToSeconds, which integrates tempo\n // as 60 / (bpm * unit) seconds per quarter — so the effective quarters per\n // minute is `bpm * unit`, not the raw bpm. Folding `unit` in here keeps the\n // grid's nominal tempo consistent with its own beat spacing; without it a\n // metronome mark like \"half note = 60\" produced 0.5 s beats under a grid\n // claiming 60 bpm, and BeatGrid's extrapolation before beat 0 disagreed with\n // every sampled beat after it.\n const tempo = map.tempoAt(Rational.ZERO);\n const bpm = tempo.bpm * (tempo.unit ?? 1) * beatsPerQuarter;\n return new BeatGrid({bpm, beats});\n}\n\n/**\n * Approximate a {@link TimeMap} from a {@link BeatGrid}: beat index becomes\n * the quarter axis and every inter-beat interval one tempo segment. The\n * grid's absolute offset is NOT representable (a TimeMap always maps quarter\n * 0 to second 0) — align `grid.beats[0]` on the consumer side. Zero-length\n * intervals are rejected: they would demand an infinite tempo.\n */\nexport function timeMapFromBeatGrid(grid: BeatGrid): TimeMap {\n const beats = grid.beats;\n const tempi: TempoEntry[] = [];\n if (beats.length < 2) {\n tempi.push({atQuarters: Rational.ZERO, bpm: grid.bpm});\n } else {\n for (let index = 0; index < beats.length - 1; index++) {\n const interval = beats[index + 1] - beats[index];\n if (!(interval > 0)) {\n throw new RangeError(`BeatGrid interval at beat ${index} is not positive (${interval}).`);\n }\n tempi.push({atQuarters: new Rational(index, 1), bpm: 60 / interval});\n }\n }\n return new TimeMap(tempi, [\n {atQuarters: Rational.ZERO, measureNumber: 1, timeSignature: {numerator: 4, denominator: 4}},\n ]);\n}\n","import {createAudioClip, type AudioClip} from '@webmusic/audio';\nimport type {Score} from '@webmusic/score';\nimport {renderScoreToBuffer, type RenderOptions} from '@webmusic/score/play';\n\n/**\n * Render a score offline into an {@link AudioClip} — a Score→Audio conversion\n * that stays a data function (DEC-068). A positive tail (the default) keeps\n * final samples after the score ends; `tailSeconds: 0` ends with the score. A\n * tempo override changes the clip's content axis relative to the score.\n */\nexport async function renderScoreToClip(score: Score, options?: RenderOptions): Promise<AudioClip> {\n const tempo = options?.tempo;\n if (tempo !== undefined && (!Number.isFinite(tempo) || tempo <= 0)) {\n throw new RangeError('renderScoreToClip tempo must be finite and > 0.');\n }\n const tail = options?.tailSeconds;\n if (tail !== undefined && (!Number.isFinite(tail) || tail < 0)) {\n throw new RangeError('renderScoreToClip tailSeconds must be finite and >= 0.');\n }\n const buffer = await renderScoreToBuffer(score, options);\n const channelData: Float32Array[] = [];\n for (let channel = 0; channel < buffer.numberOfChannels; channel++) {\n channelData.push(buffer.getChannelData(channel));\n }\n return createAudioClip({channelData, sampleRate: buffer.sampleRate});\n}\n","import type {AudioClip} from '@webmusic/audio';\nimport {AudioPlayer} from '@webmusic/audio/play/headless';\nimport {ModuleAudioEnvironment, ModuleContext, routeModuleOutput, type ConnectionLease} from '@webmusic/kernel/module';\nimport {SessionTransport, type SessionParticipantLease} from '@webmusic/kernel/session';\nimport type {Score} from '@webmusic/score';\nimport {ScorePlayerModule, type HeadlessSynth} from '@webmusic/score/play/headless';\nimport {registerAudioParticipant} from './audio-participant';\n\nexport interface CreateScoreAudioSessionOptions {\n /** Borrowed context; without one the composition creates and owns a lazy one. */\n context?: AudioContext;\n /** Score synth; defaults to the oscillator. */\n synth?: HeadlessSynth;\n /** Session seconds → nominal Score seconds: `score = session * scale + offset`. */\n scoreOffsetSeconds?: number;\n scorePositionScale?: number;\n /** Session seconds → clip seconds: `clip = session * scale + offset`. */\n clipOffsetSeconds?: number;\n clipPositionScale?: number;\n /** Lead-in before a shared start, in seconds. */\n leadInSeconds?: number;\n onOperationError?: (operation: string, error: unknown) => void;\n}\n\n/** One Session conducting a Score engine and an Audio player (DEC-068). */\nexport interface ScoreAudioSession {\n /** The only command authority: play, pause, stop, seek, rate and loop go here. */\n readonly session: SessionTransport;\n readonly context: ModuleContext;\n readonly scoreModule: ScorePlayerModule;\n readonly clipPlayer: AudioPlayer;\n /** Release both participants, their routes, the Session and an owned context. */\n dispose(): void;\n}\n\n/**\n * Compose a Score and an Audio clip under one Session — Bridge's replacement\n * for the former master/follower sync family. Each engine is a Session\n * participant with an explicit mapping from Session seconds into its own axis\n * (`score-nominal-seconds`, `clip-seconds`); use `beatGridFromTimeMap` and\n * `timeMapFromBeatGrid` to derive mappings between musical and audio time.\n * Nothing is allocated until the Session prepares or plays.\n */\nexport function createScoreAudioSession(score: Score, clip: AudioClip, options: CreateScoreAudioSessionOptions = {}): ScoreAudioSession {\n const audio = new ModuleAudioEnvironment(options.context ? {context: options.context} : {});\n const session = new SessionTransport(() => audio.peek()?.currentTime ?? 0, {\n ...(options.leadInSeconds !== undefined ? {leadInSeconds: options.leadInSeconds} : {}),\n onOperationError: options.onOperationError,\n });\n const context = new ModuleContext({id: 'score-audio-session', audio, session});\n let scoreModule: ScorePlayerModule | undefined;\n let clipPlayer: AudioPlayer | undefined;\n let participant: SessionParticipantLease | undefined;\n let route: ConnectionLease | undefined;\n let disposed = false;\n const dispose = (): void => {\n if (disposed) return;\n disposed = true;\n let failure: unknown;\n for (const release of [() => participant?.release(), () => route?.release(), () => clipPlayer?.dispose(),\n () => scoreModule?.dispose(), () => session.dispose(), () => audio.dispose()]) {\n try { release(); } catch (error) { failure ??= error; }\n }\n if (failure !== undefined) throw failure;\n };\n try {\n scoreModule = new ScorePlayerModule(score, {\n id: 'score', context, synth: options.synth,\n offsetSeconds: options.scoreOffsetSeconds, positionScale: options.scorePositionScale,\n onError: (error) => options.onOperationError?.('score', error),\n });\n const player = new AudioPlayer(clip, {moduleContext: context});\n clipPlayer = player;\n participant = registerAudioParticipant(session, player, {\n offsetSeconds: options.clipOffsetSeconds, positionScale: options.clipPositionScale,\n prepare: async () => {\n await player.preload();\n if (disposed) throw new Error('Score/Audio Session was disposed during preparation.');\n if (!route) route = routeModuleOutput(context, {id: 'clip', getPort: () => player.outputPort}, player.outputPort!);\n },\n });\n } catch (error) {\n try { dispose(); } catch { /* Preserve the construction failure. */ }\n throw error;\n }\n return Object.freeze({session, context, scoreModule, clipPlayer, dispose});\n}\n","// ============================================================================\n// Audio → symbolic assembly: build a real @webmusic/score Score from the\n// family-neutral note events that @webmusic/audio/analyze/transcribe emits. This\n// deliberately lives in the bridge — the analyze package knows nothing about\n// scores, and this module is the only place the two vocabularies meet.\n//\n// Notation is quantized to a grid; the exact audio timing survives on each\n// note's `performed` attributes (onsetSec/durationSec/velocity), so nothing\n// the transcriber heard is lost to the grid.\n// ============================================================================\n\nimport type {TranscribedNote} from '@webmusic/audio/analyze/transcribe';\nimport {\n Duration,\n MeasureId,\n PartId,\n Pitch,\n Rational,\n ScoreBuilder,\n VoiceId,\n type Score,\n} from '@webmusic/score';\n\nexport interface ScoreFromTranscriptionOptions {\n /** Tempo of the produced score. Default 120 (pass the transcriber's bpm). */\n bpm?: number;\n /** Time signature. Default 4/4. */\n timeSignature?: {numerator: number; denominator: number};\n /**\n * Notation grid in subdivisions per quarter note: onsets/durations snap to\n * `1/grid` quarters and durations never collapse below one grid unit.\n * Default 4 (sixteenth notes). Pass 0 to keep exact (unquantized) values\n * on the 1/480 tick grid.\n */\n quantizeGrid?: number;\n /** Score title. Default 'Transcription'. */\n title?: string;\n /** Part name. Default 'Transcribed'. */\n partName?: string;\n /** Maximum number of input note events to process. Default 100,000. */\n maxNotes?: number;\n /** Maximum number of measures to materialize. Default 4,096. */\n maxMeasures?: number;\n}\n\nconst TICKS_PER_QUARTER = 480;\nexport const DEFAULT_MAX_TRANSCRIPTION_NOTES = 100_000;\nexport const DEFAULT_MAX_TRANSCRIPTION_MEASURES = 4_096;\n\n/**\n * Assemble a Score from transcribed note events. Notes with a MIDI pitch\n * outside [0, 127] are skipped (transcription noise); velocities clamp into\n * the 1..127 MIDI range; measures are laid out to cover the material.\n */\nexport function scoreFromTranscription(\n notes: readonly TranscribedNote[],\n options: ScoreFromTranscriptionOptions = {},\n): Score {\n const bpm = options.bpm ?? 120;\n if (!(Number.isFinite(bpm) && bpm > 0)) {\n throw new RangeError(`scoreFromTranscription: bpm must be finite and > 0, got ${bpm}.`);\n }\n const grid = options.quantizeGrid ?? 4;\n if (!(Number.isSafeInteger(grid) && grid >= 0)) {\n throw new RangeError(`scoreFromTranscription: quantizeGrid must be a non-negative safe integer, got ${grid}.`);\n }\n const timeSignature = options.timeSignature ?? {numerator: 4, denominator: 4};\n if (\n !Number.isSafeInteger(timeSignature.numerator) || timeSignature.numerator < 1 ||\n !Number.isSafeInteger(timeSignature.denominator) || timeSignature.denominator < 1\n ) {\n throw new RangeError('scoreFromTranscription: timeSignature values must be positive safe integers.');\n }\n const maxNotes = resolvePositiveLimit(\n 'maxNotes',\n options.maxNotes,\n DEFAULT_MAX_TRANSCRIPTION_NOTES,\n );\n const maxMeasures = resolvePositiveLimit(\n 'maxMeasures',\n options.maxMeasures,\n DEFAULT_MAX_TRANSCRIPTION_MEASURES,\n );\n if (notes.length > maxNotes) {\n throw new RangeError(\n `Transcription resource limit exceeded: ${notes.length.toLocaleString()} note events ` +\n `(maxNotes is ${maxNotes.toLocaleString()}).`,\n );\n }\n\n const denominator = grid > 0 ? grid : TICKS_PER_QUARTER;\n const secondsToQuarterUnits = (seconds: number, label: string): number => {\n const units = Math.round((seconds * bpm * denominator) / 60);\n if (!Number.isSafeInteger(units)) {\n throw new RangeError(`scoreFromTranscription: ${label} is too large to represent safely.`);\n }\n return units;\n };\n\n const builder = new ScoreBuilder();\n builder\n .setMetadata({title: options.title ?? 'Transcription'})\n .addTempo({atQuarters: Rational.ZERO, bpm})\n .addMeter({atQuarters: Rational.ZERO, measureNumber: 1, timeSignature});\n\n const partId = PartId('transcription');\n const voice = VoiceId('v1');\n builder.addPart({id: partId, name: options.partName ?? 'Transcribed', staves: 1});\n\n let maxEndUnits = 0;\n for (const [index, note] of notes.entries()) {\n if (!Number.isFinite(note.midi)) {\n throw new RangeError(`scoreFromTranscription: note ${index} pitch must be finite.`);\n }\n const midi = Math.round(note.midi);\n if (midi < 0 || midi > 127) continue; // transcription noise\n if (\n !Number.isFinite(note.startSeconds) || note.startSeconds < 0 ||\n !Number.isFinite(note.endSeconds) || note.endSeconds < note.startSeconds\n ) {\n throw new RangeError(\n `scoreFromTranscription: note ${index} must have finite, non-negative, ordered start/end seconds.`,\n );\n }\n if (!Number.isFinite(note.velocity)) {\n throw new RangeError(`scoreFromTranscription: note ${index} velocity must be finite.`);\n }\n const onsetUnits = secondsToQuarterUnits(note.startSeconds, `note ${index} startSeconds`);\n const endUnits = Math.max(\n onsetUnits + 1,\n secondsToQuarterUnits(note.endSeconds, `note ${index} endSeconds`),\n );\n if (!Number.isSafeInteger(endUnits)) {\n throw new RangeError(`scoreFromTranscription: note ${index} duration is too large to represent safely.`);\n }\n maxEndUnits = Math.max(maxEndUnits, endUnits);\n builder.addNote(partId, {\n id: builder.newNoteId(),\n pitch: Pitch.fromMidi(midi),\n onsetQuarters: new Rational(onsetUnits, denominator),\n duration: new Duration({base: new Rational(endUnits - onsetUnits, denominator)}),\n voice,\n performed: {\n onsetSec: note.startSeconds,\n durationSec: Math.max(0, note.endSeconds - note.startSeconds),\n velocity: Math.min(127, Math.max(1, Math.round(note.velocity * 127))),\n },\n });\n }\n\n // Measures cover the material (at least one, so an empty transcription is\n // still a valid score).\n const materialUnits = BigInt(maxEndUnits) * BigInt(timeSignature.denominator);\n const measureUnits = BigInt(denominator) * BigInt(timeSignature.numerator) * 4n;\n const exactMeasureCount = materialUnits === 0n\n ? 1n\n : (materialUnits + measureUnits - 1n) / measureUnits;\n if (exactMeasureCount > BigInt(maxMeasures)) {\n throw new RangeError(\n `Transcription resource limit exceeded: score would create ` +\n `${exactMeasureCount.toLocaleString()} measures ` +\n `(maxMeasures is ${maxMeasures.toLocaleString()}).`,\n );\n }\n const measureCount = Number(exactMeasureCount);\n const quartersPerMeasure = quartersPerMeasureFrom(timeSignature);\n for (let index = 0; index < measureCount; index++) {\n builder.addMeasure({\n id: MeasureId(`m${index + 1}`),\n number: index + 1,\n onsetQuarters: quartersPerMeasure.mul(new Rational(index, 1)),\n durationQuarters: quartersPerMeasure,\n timeSignature,\n });\n }\n\n return builder.build();\n}\n\nfunction resolvePositiveLimit(name: 'maxNotes' | 'maxMeasures', value: number | undefined, fallback: number): number {\n if (value === undefined) return fallback;\n if (!Number.isSafeInteger(value) || value < 1) {\n throw new RangeError(`scoreFromTranscription: ${name} must be a positive safe integer.`);\n }\n return value;\n}\n\nfunction quartersPerMeasureFrom(timeSignature: {numerator: number; denominator: number}): Rational {\n let numerator = BigInt(timeSignature.numerator) * 4n;\n let denominator = BigInt(timeSignature.denominator);\n const divisor = greatestCommonDivisor(numerator, denominator);\n numerator /= divisor;\n denominator /= divisor;\n const maxSafe = BigInt(Number.MAX_SAFE_INTEGER);\n if (numerator > maxSafe || denominator > maxSafe) {\n throw new RangeError(\n 'scoreFromTranscription: timeSignature measure duration is too large to represent safely.',\n );\n }\n return new Rational(Number(numerator), Number(denominator));\n}\n\nfunction greatestCommonDivisor(left: bigint, right: bigint): bigint {\n while (right !== 0n) {\n const remainder = left % right;\n left = right;\n right = remainder;\n }\n return left;\n}\n"],"mappings":";;;;;;AAQA,SAAQ,UAAU,eAA+B;AACjD,SAAQ,gBAAe;AAWhB,IAAM,2BAA2B;AAQjC,SAAS,oBAAoB,KAAc,SAA+C;AAC/F,QAAM,EAAC,kBAAkB,kBAAkB,GAAG,WAAW,yBAAwB,IAAI;AACrF,MAAI,CAAC,OAAO,SAAS,gBAAgB,KAAK,oBAAoB,GAAG;AAC/D,UAAM,IAAI,WAAW,yCAAyC;AAAA,EAChE;AACA,MAAI,CAAC,OAAO,cAAc,eAAe,KAAK,kBAAkB,GAAG;AACjE,UAAM,IAAI,WAAW,iDAAiD;AAAA,EACxE;AACA,MAAI,CAAC,OAAO,cAAc,QAAQ,KAAK,WAAW,GAAG;AACnD,UAAM,IAAI,WAAW,sCAAsC;AAAA,EAC7D;AACA,QAAM,iBAAiB,mBAAmB;AAC1C,QAAM,iBAAiB,KAAK,MAAM,cAAc;AAChD,QAAM,eAAe,OAAO,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,cAAc,CAAC,IAAI;AAC9E,QAAM,qBACJ,KAAK,IAAI,iBAAiB,cAAc,KAAK,eACzC,iBACA;AACN,QAAM,QAAQ,KAAK,KAAK,kBAAkB;AAC1C,MAAI,CAAC,OAAO,cAAc,KAAK,KAAK,SAAS,UAAU;AACrD,UAAM,IAAI;AAAA,MACR,wDAAwD,SAAS,eAAe,CAAC;AAAA,IACnF;AAAA,EACF;AACA,QAAM,QAAkB,CAAC;AACzB,WAAS,QAAQ,GAAG,SAAS,OAAO,SAAS;AAC3C,UAAM,KAAK,IAAI,kBAAkB,IAAI,SAAS,OAAO,eAAe,CAAC,CAAC;AAAA,EACxE;AAQA,QAAM,QAAQ,IAAI,QAAQ,SAAS,IAAI;AACvC,QAAM,MAAM,MAAM,OAAO,MAAM,QAAQ,KAAK;AAC5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,YAAQ;AAAA,EACV;AACA,SAAO;AACT;","names":["Rational"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,93 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webmusic/bridge",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Bridge between the score and audio families of the WebMusic ecosystem: synchronized score+audio playback on one AudioContext clock, score-to-clip offline rendering, and TimeMap/BeatGrid conversions. The only package allowed to import both families.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"./dist/component.global.js"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"./component": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/component.d.ts",
|
|
26
|
+
"default": "./dist/component.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/component.d.cts",
|
|
30
|
+
"default": "./dist/component.cjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./component/global": {
|
|
34
|
+
"types": "./dist/component/global.d.ts",
|
|
35
|
+
"default": "./dist/component.global.js"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "node ../../scripts/clean-dist.mjs --begin dist && tsup && node ../../scripts/bundle-notices.mjs --package-dir . && node ../../scripts/clean-dist.mjs --prune dist && node ../../scripts/package-artifacts.mjs --write",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"prepack": "node ../../scripts/package-artifacts.mjs"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"tsup": "^8.5.0",
|
|
47
|
+
"typescript": "^5.4.0",
|
|
48
|
+
"vitest": "^5.1.0"
|
|
49
|
+
},
|
|
50
|
+
"license": "Apache-2.0",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"author": "Koperative",
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": "^22.22.3 || ^24.16.0 || >=26.3.0"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist",
|
|
60
|
+
"README.md",
|
|
61
|
+
"LICENSE",
|
|
62
|
+
"NOTICE"
|
|
63
|
+
],
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "git+https://github.com/koperative-lab/WebMusic.git",
|
|
67
|
+
"directory": "bridges/score-audio"
|
|
68
|
+
},
|
|
69
|
+
"homepage": "https://github.com/koperative-lab/WebMusic",
|
|
70
|
+
"bugs": {
|
|
71
|
+
"url": "https://github.com/koperative-lab/WebMusic/issues"
|
|
72
|
+
},
|
|
73
|
+
"keywords": [
|
|
74
|
+
"webmusic",
|
|
75
|
+
"music",
|
|
76
|
+
"web-audio",
|
|
77
|
+
"score",
|
|
78
|
+
"sync",
|
|
79
|
+
"bridge",
|
|
80
|
+
"typescript"
|
|
81
|
+
],
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"@webmusic/audio": "^0.4.0",
|
|
84
|
+
"@webmusic/kernel": "^0.4.0",
|
|
85
|
+
"@webmusic/score": "^0.4.0",
|
|
86
|
+
"@webmusic/ui": "^0.4.0"
|
|
87
|
+
},
|
|
88
|
+
"peerDependenciesMeta": {
|
|
89
|
+
"@webmusic/ui": {
|
|
90
|
+
"optional": true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|