@hraness/dawg 0.0.0-stage → 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/CHANGELOG.md +126 -0
- package/DAWG.md +327 -0
- package/LICENSE +21 -0
- package/README.md +213 -2
- package/core/diff.ts +249 -0
- package/core/drums.ts +102 -0
- package/core/key.ts +43 -0
- package/core/loop.ts +78 -0
- package/core/pitch.ts +60 -0
- package/core/score.ts +1388 -0
- package/core/sdk/eval-child.ts +113 -0
- package/core/sdk/eval.ts +257 -0
- package/core/sdk/print.ts +393 -0
- package/core/sdk/v1.ts +954 -0
- package/core/slug.ts +19 -0
- package/package.json +45 -4
- package/src/agent/agent.ts +853 -0
- package/src/agent/brief.ts +160 -0
- package/src/agent/gateway.ts +441 -0
- package/src/agent/models.ts +633 -0
- package/src/agent/ops.ts +157 -0
- package/src/agent/planner.ts +259 -0
- package/src/agent/provider.ts +454 -0
- package/src/agent/sse.ts +114 -0
- package/src/agent/tools.ts +1373 -0
- package/src/agent/usage.ts +296 -0
- package/src/agent/workspace.ts +683 -0
- package/src/agent/xcb-agent.ts +262 -0
- package/src/agent/xcb.ts +579 -0
- package/src/audio/click.ts +125 -0
- package/src/audio/clock.ts +68 -0
- package/src/audio/engine.ts +841 -0
- package/src/audio/live.ts +152 -0
- package/src/audio/lock.ts +57 -0
- package/src/audio/player.ts +134 -0
- package/src/audio/render-worker.ts +68 -0
- package/src/audio/renderer.ts +174 -0
- package/src/audio/sampler.ts +292 -0
- package/src/audio/samples.ts +683 -0
- package/src/audio/wav.ts +861 -0
- package/src/auth/cli.ts +231 -0
- package/src/auth/credentials.ts +411 -0
- package/src/auth/discover.ts +481 -0
- package/src/auth/login.ts +1191 -0
- package/src/auth/openrouter.ts +206 -0
- package/src/auth/picker.ts +282 -0
- package/src/auth/runner.ts +207 -0
- package/src/auth/tui.ts +107 -0
- package/src/commands/edit.ts +170 -0
- package/src/commands/help.ts +247 -0
- package/src/commands/history.ts +69 -0
- package/src/commands/music.ts +461 -0
- package/src/commands/sample.ts +302 -0
- package/src/daemon.ts +31 -0
- package/src/main.ts +2209 -0
- package/src/media/analyze.ts +364 -0
- package/src/media/backend.ts +253 -0
- package/src/media/cli.ts +173 -0
- package/src/media/download.ts +281 -0
- package/src/media/dsp.ts +281 -0
- package/src/media/import.ts +130 -0
- package/src/media/lyrics.ts +201 -0
- package/src/media/notes.ts +363 -0
- package/src/media/paths.ts +168 -0
- package/src/media/process.ts +226 -0
- package/src/media/registry.ts +9 -0
- package/src/media/sidecar.ts +72 -0
- package/src/media/stemdeck.ts +254 -0
- package/src/media/stems.ts +173 -0
- package/src/media/tools.ts +292 -0
- package/src/media/types.ts +92 -0
- package/src/media/vendor/basic-pitch.ts +261 -0
- package/src/media/vendor/drums.ts +817 -0
- package/src/media/vendor/grid.ts +203 -0
- package/src/media/vendor/util.ts +139 -0
- package/src/media/vendor/wav.ts +233 -0
- package/src/project/check.ts +80 -0
- package/src/project/init.ts +253 -0
- package/src/project/sync.ts +432 -0
- package/src/project/typecheck.ts +149 -0
- package/src/render.ts +121 -0
- package/src/session/attach.ts +181 -0
- package/src/session/client.ts +498 -0
- package/src/session/daemon.ts +740 -0
- package/src/session/delta.ts +249 -0
- package/src/session/list.ts +180 -0
- package/src/session/lock.ts +92 -0
- package/src/session/meta.ts +253 -0
- package/src/session/naming.ts +430 -0
- package/src/session/port.ts +481 -0
- package/src/session/presence.ts +159 -0
- package/src/session/protocol.ts +618 -0
- package/src/session/rebase.ts +168 -0
- package/src/session/store.ts +581 -0
- package/src/tui/menu.ts +1083 -0
- package/src/tui/play-mode.ts +442 -0
- package/src/tui/play-session.ts +636 -0
- package/src/web/fetch.ts +340 -0
- package/src/web/http.ts +137 -0
- package/src/web/search.ts +681 -0
- package/tui/activity.ts +364 -0
- package/tui/app.ts +1372 -0
- package/tui/drums.ts +65 -0
- package/tui/highway.ts +921 -0
- package/tui/input.ts +63 -0
- package/tui/keys.ts +102 -0
- package/tui/layers.ts +80 -0
- package/tui/play-strip.ts +143 -0
- package/tui/prompt.ts +609 -0
- package/tui/render.ts +124 -0
- package/tui/screen.ts +247 -0
- package/tui/text.ts +72 -0
- package/tui/theme.ts +451 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export class TransportClock {
|
|
2
|
+
private startedAtMs: number | undefined;
|
|
3
|
+
private pausedBeat = 0;
|
|
4
|
+
private bpm: number;
|
|
5
|
+
|
|
6
|
+
constructor(bpm = 120) {
|
|
7
|
+
this.bpm = bpm;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
play(nowMs = performance.now()): void {
|
|
11
|
+
if (this.startedAtMs === undefined)
|
|
12
|
+
this.startedAtMs = nowMs - this.beatToMs(this.pausedBeat);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
pause(nowMs = performance.now()): void {
|
|
16
|
+
this.pausedBeat = this.beatAt(nowMs);
|
|
17
|
+
this.startedAtMs = undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toggle(nowMs = performance.now()): void {
|
|
21
|
+
if (this.startedAtMs === undefined) this.play(nowMs);
|
|
22
|
+
else this.pause(nowMs);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
beatAt(nowMs = performance.now()): number {
|
|
26
|
+
if (this.startedAtMs === undefined) return this.pausedBeat;
|
|
27
|
+
return Math.max(0, (nowMs - this.startedAtMs) / this.beatToMs(1));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get playing(): boolean {
|
|
31
|
+
return this.startedAtMs !== undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setTempo(bpm: number, nowMs = performance.now()): void {
|
|
35
|
+
if (!Number.isFinite(bpm) || bpm <= 0) return;
|
|
36
|
+
const beat = this.beatAt(nowMs);
|
|
37
|
+
this.bpm = bpm;
|
|
38
|
+
if (this.startedAtMs !== undefined)
|
|
39
|
+
this.startedAtMs = nowMs - this.beatToMs(beat);
|
|
40
|
+
else this.pausedBeat = beat;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Converge to a timestamped transport event from another TUI process. */
|
|
44
|
+
sync(
|
|
45
|
+
beat: number,
|
|
46
|
+
playing: boolean,
|
|
47
|
+
eventAtMs = Date.now(),
|
|
48
|
+
nowWallMs = Date.now(),
|
|
49
|
+
nowMonotonicMs = performance.now(),
|
|
50
|
+
): void {
|
|
51
|
+
if (!Number.isFinite(beat) || beat < 0) return;
|
|
52
|
+
if (!Number.isFinite(eventAtMs) || !Number.isFinite(nowWallMs)) return;
|
|
53
|
+
const elapsed = playing
|
|
54
|
+
? Math.max(0, nowWallMs - eventAtMs) / this.beatToMs(1)
|
|
55
|
+
: 0;
|
|
56
|
+
const currentBeat = beat + elapsed;
|
|
57
|
+
if (playing) {
|
|
58
|
+
this.startedAtMs = nowMonotonicMs - this.beatToMs(currentBeat);
|
|
59
|
+
} else {
|
|
60
|
+
this.pausedBeat = currentBeat;
|
|
61
|
+
this.startedAtMs = undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private beatToMs(beats: number): number {
|
|
66
|
+
return (beats * 60_000) / this.bpm;
|
|
67
|
+
}
|
|
68
|
+
}
|