@buffered-audio/nodes 0.18.1 → 0.19.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 +47 -59
- package/dist/chunk-YJWZP2OD.js +2067 -0
- package/dist/cli.js +21 -16
- package/dist/index.d.ts +143 -221
- package/dist/index.js +1098 -3253
- package/dist/nlm-worker.d.ts +2 -0
- package/dist/nlm-worker.js +12 -0
- package/package.json +7 -6
package/dist/cli.js
CHANGED
|
@@ -4,11 +4,11 @@ import { existsSync, readFileSync } from 'fs';
|
|
|
4
4
|
import { resolve } from 'path';
|
|
5
5
|
import { SourceNode, validateGraphDefinition, createRenderJobs, BufferedSourceStream } from '@buffered-audio/core';
|
|
6
6
|
|
|
7
|
-
var labelOf = (
|
|
7
|
+
var labelOf = (identity) => identity.nodeId !== void 0 ? `${identity.nodeName}#${identity.nodeId}` : `${identity.nodeName}#${identity.streamId}`;
|
|
8
8
|
function sourceLabel(job) {
|
|
9
|
-
for (const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (const streams of job.streams.values()) {
|
|
10
|
+
for (const stream of streams) {
|
|
11
|
+
if (stream instanceof BufferedSourceStream) return labelOf(stream.identity);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
return void 0;
|
|
@@ -39,21 +39,26 @@ function parseParams(entries) {
|
|
|
39
39
|
}
|
|
40
40
|
return Object.fromEntries(parameters);
|
|
41
41
|
}
|
|
42
|
+
function stamp(createdAt) {
|
|
43
|
+
const date = new Date(createdAt);
|
|
44
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
45
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
46
|
+
}
|
|
42
47
|
function createEventSink() {
|
|
43
48
|
const totals = /* @__PURE__ */ new Map();
|
|
44
49
|
const subscribe = (events) => {
|
|
45
|
-
events.on("started", (node) => {
|
|
46
|
-
process.stdout.write(
|
|
50
|
+
events.on("started", (node, payload) => {
|
|
51
|
+
process.stdout.write(`${stamp(payload.createdAt)} [${labelOf(node)}] started
|
|
47
52
|
`);
|
|
48
53
|
});
|
|
49
54
|
events.on("progress", (node, payload) => {
|
|
50
55
|
const label = labelOf(node);
|
|
51
56
|
if (payload.framesTotal !== void 0) {
|
|
52
57
|
const percent = Math.round(payload.framesDone / payload.framesTotal * 100);
|
|
53
|
-
process.stdout.write(
|
|
58
|
+
process.stdout.write(`${stamp(payload.createdAt)} [${label}] ${payload.phase} ${percent}%
|
|
54
59
|
`);
|
|
55
60
|
} else {
|
|
56
|
-
process.stdout.write(
|
|
61
|
+
process.stdout.write(`${stamp(payload.createdAt)} [${label}] ${payload.phase} frames=${payload.framesDone}
|
|
57
62
|
`);
|
|
58
63
|
}
|
|
59
64
|
});
|
|
@@ -61,23 +66,23 @@ function createEventSink() {
|
|
|
61
66
|
const data = payload.data ? Object.entries(payload.data).map(([key, value]) => `${key}=${String(value)}`) : [];
|
|
62
67
|
const parts = [payload.message, ...data].join(" ");
|
|
63
68
|
const prefix = payload.level === "warn" ? "warn: " : "";
|
|
64
|
-
process.stdout.write(`${prefix}[${labelOf(node)}] ${parts}
|
|
69
|
+
process.stdout.write(`${stamp(payload.createdAt)} ${prefix}[${labelOf(node)}] ${parts}
|
|
65
70
|
`);
|
|
66
71
|
});
|
|
67
72
|
events.on("finished", (node, payload) => {
|
|
68
|
-
totals.set(node, { framesDone: payload.framesDone, processingMs: payload.processingMs });
|
|
69
|
-
|
|
73
|
+
totals.set(node.streamId, { label: labelOf(node), framesDone: payload.framesDone, processingMs: payload.processingMs });
|
|
74
|
+
const ms = payload.processingMs !== void 0 ? ` ms=${Math.round(payload.processingMs)}` : "";
|
|
75
|
+
process.stdout.write(`${stamp(payload.createdAt)} [${labelOf(node)}] finished frames=${payload.framesDone}${ms}
|
|
70
76
|
`);
|
|
71
77
|
});
|
|
72
78
|
};
|
|
73
79
|
const printSummary = (jobs) => {
|
|
74
|
-
for (const
|
|
75
|
-
const label = labelOf(node);
|
|
80
|
+
for (const { label, framesDone, processingMs } of totals.values()) {
|
|
76
81
|
if (processingMs !== void 0) {
|
|
77
|
-
process.stdout.write(
|
|
82
|
+
process.stdout.write(`${stamp(Date.now())} [${label}] processed ${framesDone} frames in ${Math.round(processingMs)}ms
|
|
78
83
|
`);
|
|
79
84
|
} else {
|
|
80
|
-
process.stdout.write(
|
|
85
|
+
process.stdout.write(`${stamp(Date.now())} [${label}] processed ${framesDone} frames
|
|
81
86
|
`);
|
|
82
87
|
}
|
|
83
88
|
}
|
|
@@ -85,7 +90,7 @@ function createEventSink() {
|
|
|
85
90
|
const timing = job.timing;
|
|
86
91
|
if (!timing) continue;
|
|
87
92
|
const label = sourceLabel(job) ?? "source";
|
|
88
|
-
process.stdout.write(
|
|
93
|
+
process.stdout.write(`${stamp(Date.now())} [${label}] total ${(timing.totalMs / 1e3).toFixed(1)}s, ${timing.realTimeMultiplier.toFixed(1)}x RT
|
|
89
94
|
`);
|
|
90
95
|
}
|
|
91
96
|
};
|