@webmusic/bridge 0.0.0-stage → 0.2.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Koperative
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,102 @@
1
- # Temporary Holding Version
1
+ # @webmusic/bridge
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Compose `@webmusic/score` and `@webmusic/audio` through synchronized playback,
4
+ offline rendering and timeline/note conversion. Score and Audio remain independent
5
+ packages; Bridge supplies the integration between them.
6
+
7
+ ## Playback
8
+
9
+ - `createSyncedPlayback(score, clip)` / `ScoreAudioSync`: Score drives a decoded
10
+ audio clip on the nominal score-seconds axis.
11
+ - `createAudioMasteredPlayback(score, clip)`: a recording or an offline-rendered
12
+ clip with an effect tail drives the Score player on the clip-seconds axis.
13
+ `clipOffsetSeconds` places score-zero inside a recording; the score waits
14
+ through material before that point. Use `scorePlayer.setVolume(0)` when only
15
+ the clip should sound.
16
+ - `clipAsMaster` / `scoreAsFollower`: structural adapters for explicit composition.
17
+
18
+ The factories provide one AudioContext reference to both players and use the
19
+ buffer engine. The group coordinates scheduled starts, seek, rate and drift using
20
+ the master's readable clock. Players still own separate TransportClock instances;
21
+ the same-instance session-clock injection protocol is not yet implemented.
22
+ Independent sessions can have separate groups, even when they share a context.
23
+
24
+ A common scheduled origin allows audio-clock alignment when backends support
25
+ future scheduling and are ready before that origin. It does not guarantee UI
26
+ callback precision or sample-accurate loop wrap. Group loop boundaries are currently
27
+ detected by a tick and followed by a scheduled re-entry. Clockless or just-in-time
28
+ backends have weaker timing behavior. See the [integration contracts](../README.md).
29
+
30
+ Issue transport commands through `sync.play()`, `pause()`, `stop()`, `seek()`,
31
+ `setRate()` and `setLoop()`. `setRate()` accepts finite values from 0.25× through
32
+ 4× and rejects values outside that range. Both factories reject defined
33
+ `clipOptions.loop` and `clipOptions.rate` overrides, including `false` and `1`,
34
+ before allocating a context or constructing players. Supply a group loop through
35
+ `options.loop` or `sync.setLoop()` and change the shared rate with `sync.setRate()`.
36
+ Both also reject non-buffer engine/media-adapter overrides and URL-only clips.
37
+ These pair factories do not expose independent native-loop phase mapping. Use
38
+ Kernel's group with explicitly configured looping participants for that contract.
39
+ The buffer engine changes clip pitch when playback rate changes;
40
+ `clipOptions.preservesPitch` does not apply to these factories.
41
+
42
+ `renderScoreToClip(score)` includes a short tail by default, or a longer effect
43
+ tail when an effect is selected. Pair that output with
44
+ `createAudioMasteredPlayback(score, clip)` so the clip plays through its end.
45
+ To keep Score as master, render with `{tailSeconds: 0}`. The Score-master factory
46
+ rejects a Bridge-rendered clip with a positive tail instead of silently
47
+ stopping it early. Both factories require the original Score instance used for
48
+ that render and reject a `tempo` override that changes its time axis;
49
+ render at the Score's base tempo and use `sync.setRate()` for coordinated speed
50
+ changes. This provenance check applies to the original AudioClip object
51
+ returned by one render call; copying or serializing it does not carry that
52
+ identity through the API.
53
+
54
+ For repeated notation, call `expandRepeats(score)` first, then render and pair
55
+ that expanded Score instance. `scoreOptions.expandRepeats` would expand only
56
+ the player timeline, so the factories reject it for Bridge-rendered clips.
57
+
58
+ ## Conversion
59
+
60
+ | API | Output and information boundary |
61
+ |---|---|
62
+ | `renderScoreToClip(score)` | Offline audio samples in an `AudioClip`; notation metadata is not recoverable from samples in general. |
63
+ | `beatGridFromTimeMap` | Exact evaluation at sampled beat positions; intervening tempo changes may be lost. |
64
+ | `timeMapFromBeatGrid` | Per-interval tempo segments with quarter zero at second zero; callers retain absolute grid offset separately. Original meter is not recovered. |
65
+ | `scoreFromTranscription(notes)` | Validated Score from estimated note events, preserving supplied performed timing while quantizing notation; cannot restore information missing from transcription. |
66
+
67
+ These conversions do not guarantee lossless Audio ↔ Score round-trips. Timeline
68
+ sampling is bounded by `maxBeats` (1,000,000 by default); transcription assembly
69
+ uses `maxNotes` and `maxMeasures` to bound work.
70
+
71
+ ## Ownership and dependencies
72
+
73
+ Call the returned `sync.dispose()` to release factory-created players and request
74
+ closure of a factory-created context. A context passed in `options.context` stays
75
+ caller-owned. Direct `ScoreAudioSync` construction invokes participants' optional
76
+ `dispose()` methods when the group is disposed; use non-owning adapters when needed.
77
+
78
+ Kernel, Score and Audio are required peers. Install compatible versions in the
79
+ application; Bridge externalizes them. Sharing package implementations does not
80
+ itself share live clocks, contexts or players. Detailed lifetime, fallback and
81
+ concurrency contracts live in [bridges/README.md](../README.md). Accepted session
82
+ time requirements and remaining injection work are described in the
83
+ [clock design note](../../platform/shared-clock-injection.md) and
84
+ [STATUS.md](../../dev/STATUS.md).
85
+
86
+ ## License
87
+
88
+ MIT
89
+
90
+ ## Observing and commanding one session
91
+
92
+ `ScoreAudioSync.snapshot`, `subscribe(listener)` and `dispatch(command)` expose
93
+ Kernel's revisioned command protocol through the existing group. New callers can
94
+ await actual play/seek/rate settlement and distinguish failures or superseded
95
+ work. Seek positions remain on the stable master axis at every rate. Existing
96
+ control methods remain available. The complete contracts and migration boundaries
97
+ are in the [ScoreAudioSync reference](../../apps/doc/webmusic/src/content/docs/bridge/headless/score-audio-sync.mdx).
98
+
99
+ Independent native clip loops are available through explicitly configured Kernel
100
+ follower adapters with local offset/scale/loop metadata. The pair factories retain
101
+ their clip-loop restrictions; their top-level loop remains coordinated, tick-watched
102
+ re-entry. See [Kernel mappings](../../apps/doc/webmusic/src/content/docs/kernel/api.mdx).
@@ -0,0 +1,7 @@
1
+ {
2
+ "schema": 1,
3
+ "name": "@webmusic/bridge",
4
+ "version": "0.2.0",
5
+ "source": "373019d816fb463de4490f2ad83f17dfccd8defbc7063ad78b1f2e1114e24ae4",
6
+ "outputs": "4380f0a9116796a9da75169bd73914d4e54e943c134290934a704adb6d826bb0"
7
+ }