canvas-recorder-lib 0.7.1 → 0.7.3
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 +51 -8
- package/dev/audio-builder.ts +5 -1
- package/dev/canvas-recorder.css +15 -4
- package/dev/canvas-recorder.ts +518 -131
- package/dev/delay-files.ts +1 -1
- package/dev/format-editor.ts +7 -2
- package/dev/fourier-panel.ts +11 -3
- package/dev/handwriting-panel.ts +14 -9
- package/dev/local-file-row.ts +12 -5
- package/dev/multi-text-dialog.ts +15 -6
- package/dev/multi-text-panel.ts +6 -2
- package/dev/player-body.ts +4 -0
- package/dev/schedule-helpers.ts +11 -4
- package/dev/sound-clips.ts +4 -1
- package/dev/soundtrack.ts +42 -11
- package/dev/split-dialog.ts +49 -19
- package/dev/static-image-panel.ts +17 -5
- package/dev/synced-file.ts +4 -5
- package/dev/timeline-display.ts +152 -50
- package/dev/transcribe-core.ts +48 -17
- package/dev/transcribe-worker.ts +20 -9
- package/dev/transcript-align.ts +95 -20
- package/dev/transcript-export.ts +18 -7
- package/dev/transcript-view.ts +78 -22
- package/dev/transcripts.ts +43 -23
- package/dev/video-clip-panel.ts +64 -18
- package/dev/voice/chirp.ts +21 -5
- package/dev/voice/folder.ts +22 -7
- package/dev/voice/voice-panel.ts +34 -10
- package/dev/voice/voice-recorder.ts +74 -18
- package/dist/dev/audio-builder.js.map +1 -1
- package/dist/dev/canvas-recorder.css +15 -4
- package/dist/dev/canvas-recorder.js +375 -85
- package/dist/dev/canvas-recorder.js.map +1 -1
- package/dist/dev/format-editor.d.ts.map +1 -1
- package/dist/dev/format-editor.js.map +1 -1
- package/dist/dev/fourier-panel.d.ts.map +1 -1
- package/dist/dev/fourier-panel.js.map +1 -1
- package/dist/dev/handwriting-panel.d.ts.map +1 -1
- package/dist/dev/handwriting-panel.js +10 -8
- package/dist/dev/handwriting-panel.js.map +1 -1
- package/dist/dev/local-file-row.d.ts.map +1 -1
- package/dist/dev/local-file-row.js +12 -4
- package/dist/dev/local-file-row.js.map +1 -1
- package/dist/dev/multi-text-dialog.d.ts.map +1 -1
- package/dist/dev/multi-text-dialog.js +4 -2
- package/dist/dev/multi-text-dialog.js.map +1 -1
- package/dist/dev/multi-text-panel.d.ts.map +1 -1
- package/dist/dev/multi-text-panel.js +2 -1
- package/dist/dev/multi-text-panel.js.map +1 -1
- package/dist/dev/player-body.d.ts +1 -1
- package/dist/dev/player-body.d.ts.map +1 -1
- package/dist/dev/player-body.js +4 -0
- package/dist/dev/player-body.js.map +1 -1
- package/dist/dev/schedule-helpers.d.ts.map +1 -1
- package/dist/dev/schedule-helpers.js +4 -1
- package/dist/dev/schedule-helpers.js.map +1 -1
- package/dist/dev/sound-clips.d.ts.map +1 -1
- package/dist/dev/sound-clips.js.map +1 -1
- package/dist/dev/soundtrack.d.ts +12 -0
- package/dist/dev/soundtrack.d.ts.map +1 -1
- package/dist/dev/soundtrack.js +33 -7
- package/dist/dev/soundtrack.js.map +1 -1
- package/dist/dev/split-dialog.d.ts.map +1 -1
- package/dist/dev/split-dialog.js +17 -10
- package/dist/dev/split-dialog.js.map +1 -1
- package/dist/dev/static-image-panel.d.ts.map +1 -1
- package/dist/dev/static-image-panel.js +7 -3
- package/dist/dev/static-image-panel.js.map +1 -1
- package/dist/dev/synced-file.d.ts.map +1 -1
- package/dist/dev/synced-file.js.map +1 -1
- package/dist/dev/timeline-display.d.ts.map +1 -1
- package/dist/dev/timeline-display.js +62 -17
- package/dist/dev/timeline-display.js.map +1 -1
- package/dist/dev/transcribe-core.d.ts.map +1 -1
- package/dist/dev/transcribe-core.js +13 -3
- package/dist/dev/transcribe-core.js.map +1 -1
- package/dist/dev/transcribe-worker.d.ts.map +1 -1
- package/dist/dev/transcribe-worker.js +9 -3
- package/dist/dev/transcribe-worker.js.map +1 -1
- package/dist/dev/transcript-align.d.ts.map +1 -1
- package/dist/dev/transcript-align.js +52 -9
- package/dist/dev/transcript-align.js.map +1 -1
- package/dist/dev/transcript-export.d.ts.map +1 -1
- package/dist/dev/transcript-export.js +10 -4
- package/dist/dev/transcript-export.js.map +1 -1
- package/dist/dev/transcript-view.d.ts +2 -0
- package/dist/dev/transcript-view.d.ts.map +1 -1
- package/dist/dev/transcript-view.js +32 -11
- package/dist/dev/transcript-view.js.map +1 -1
- package/dist/dev/transcripts.d.ts.map +1 -1
- package/dist/dev/transcripts.js +5 -3
- package/dist/dev/transcripts.js.map +1 -1
- package/dist/dev/video-clip-panel.d.ts.map +1 -1
- package/dist/dev/video-clip-panel.js +25 -8
- package/dist/dev/video-clip-panel.js.map +1 -1
- package/dist/dev/voice/chirp.d.ts.map +1 -1
- package/dist/dev/voice/chirp.js +5 -1
- package/dist/dev/voice/chirp.js.map +1 -1
- package/dist/dev/voice/folder.d.ts.map +1 -1
- package/dist/dev/voice/folder.js +1 -1
- package/dist/dev/voice/folder.js.map +1 -1
- package/dist/dev/voice/voice-panel.d.ts.map +1 -1
- package/dist/dev/voice/voice-panel.js +15 -6
- package/dist/dev/voice/voice-panel.js.map +1 -1
- package/dist/dev/voice/voice-recorder.d.ts.map +1 -1
- package/dist/dev/voice/voice-recorder.js +34 -9
- package/dist/dev/voice/voice-recorder.js.map +1 -1
- package/dist/lib/main-control.d.ts +35 -1
- package/dist/lib/main-control.d.ts.map +1 -1
- package/dist/lib/main-control.js +76 -0
- package/dist/lib/main-control.js.map +1 -1
- package/dist/src/corner-rounder.d.ts.map +1 -1
- package/dist/src/corner-rounder.js +1 -1
- package/dist/src/corner-rounder.js.map +1 -1
- package/dist/src/local-files.d.ts.map +1 -1
- package/dist/src/local-files.js +5 -2
- package/dist/src/local-files.js.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.d.ts +7 -0
- package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.js +8 -1
- package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
- package/dist/src/showable.d.ts +74 -0
- package/dist/src/showable.d.ts.map +1 -1
- package/dist/src/showable.js.map +1 -1
- package/dist/src/slide-components/fourier.d.ts.map +1 -1
- package/dist/src/slide-components/fourier.js +12 -4
- package/dist/src/slide-components/fourier.js.map +1 -1
- package/dist/src/slide-components/image.d.ts.map +1 -1
- package/dist/src/slide-components/image.js +1 -1
- package/dist/src/slide-components/image.js.map +1 -1
- package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
- package/dist/src/slide-components/in-parallel.js.map +1 -1
- package/dist/src/slide-components/multi-text.d.ts.map +1 -1
- package/dist/src/slide-components/multi-text.js +1 -1
- package/dist/src/slide-components/multi-text.js.map +1 -1
- package/dist/src/slide-components/rectangle.d.ts.map +1 -1
- package/dist/src/slide-components/rectangle.js +1 -1
- package/dist/src/slide-components/rectangle.js.map +1 -1
- package/dist/src/slide-components/registry.js.map +1 -1
- package/dist/src/slide-components/serialize.d.ts.map +1 -1
- package/dist/src/slide-components/serialize.js +2 -1
- package/dist/src/slide-components/serialize.js.map +1 -1
- package/dist/src/slide-components/split-video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/split-video-clip.js +4 -1
- package/dist/src/slide-components/split-video-clip.js.map +1 -1
- package/dist/src/slide-components/video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.js +7 -4
- package/dist/src/slide-components/video-clip.js.map +1 -1
- package/dist/src/slide-components/video-info.d.ts.map +1 -1
- package/dist/src/slide-components/video-info.js.map +1 -1
- package/dist/src/slow-image-sources.d.ts.map +1 -1
- package/dist/src/slow-image-sources.js +1 -1
- package/dist/src/slow-image-sources.js.map +1 -1
- package/dist/src/snapshot.d.ts.map +1 -1
- package/dist/src/snapshot.js +1 -1
- package/dist/src/snapshot.js.map +1 -1
- package/dist/src/utility.d.ts.map +1 -1
- package/dist/src/utility.js +1 -3
- package/dist/src/utility.js.map +1 -1
- package/lib/main-control.ts +95 -2
- package/package.json +4 -1
- package/src/corner-rounder.ts +5 -12
- package/src/glib/letters-base.ts +1 -1
- package/src/local-files.ts +19 -6
- package/src/peano-fourier/fourier-shared.ts +8 -1
- package/src/showable.ts +79 -0
- package/src/slide-components/fourier.ts +32 -10
- package/src/slide-components/image.ts +4 -1
- package/src/slide-components/in-parallel.ts +1 -2
- package/src/slide-components/multi-text.ts +17 -4
- package/src/slide-components/rectangle.ts +4 -1
- package/src/slide-components/registry.ts +1 -1
- package/src/slide-components/serialize.ts +4 -1
- package/src/slide-components/split-video-clip.ts +4 -1
- package/src/slide-components/video-clip.ts +21 -8
- package/src/slide-components/video-info.ts +4 -1
- package/src/slow-image-sources.ts +5 -1
- package/src/snapshot.ts +13 -4
- package/src/utility.ts +70 -33
package/dev/video-clip-panel.ts
CHANGED
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
shrinkToAspect,
|
|
14
14
|
VideoInfo,
|
|
15
15
|
} from "../src/slide-components/video-info.ts";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ALIGN_HORIZONTALLY,
|
|
18
|
+
ALIGN_VERTICALLY,
|
|
19
|
+
buildSnapRow,
|
|
20
|
+
} from "./rect-snap.ts";
|
|
17
21
|
import { buildLocalFileRow } from "./local-file-row.ts";
|
|
18
22
|
import {
|
|
19
23
|
LocalFileError,
|
|
@@ -86,7 +90,8 @@ function quietError(error: unknown): string {
|
|
|
86
90
|
if (error instanceof LocalFileError) return error.message;
|
|
87
91
|
const text = String(error);
|
|
88
92
|
if (/404|not found|Failed to fetch/i.test(text)) return "Not found";
|
|
89
|
-
if (/unsupported|unrecognized|format/i.test(text))
|
|
93
|
+
if (/unsupported|unrecognized|format/i.test(text))
|
|
94
|
+
return "Not a video file this can read";
|
|
90
95
|
return text.replace(/^Error:\s*/, "");
|
|
91
96
|
}
|
|
92
97
|
|
|
@@ -245,7 +250,10 @@ export function buildVideoClipPanel(
|
|
|
245
250
|
|
|
246
251
|
const statusEl = line(panel, "font-weight:bold;margin-bottom:0.2em");
|
|
247
252
|
const statsEl = line(panel, "font-size:0.9em;line-height:1.4");
|
|
248
|
-
const derivedEl = line(
|
|
253
|
+
const derivedEl = line(
|
|
254
|
+
panel,
|
|
255
|
+
"font-size:0.9em;line-height:1.4;margin-top:0.3em",
|
|
256
|
+
);
|
|
249
257
|
|
|
250
258
|
const timingRow = line(panel, "margin-top:0.5em");
|
|
251
259
|
const WHOLE_FILE_TITLE =
|
|
@@ -266,17 +274,23 @@ export function buildVideoClipPanel(
|
|
|
266
274
|
const SIZE_VIDEO_TITLE =
|
|
267
275
|
"Make the whole video exactly this clip's size, in pixels, and fill it with this clip, " +
|
|
268
276
|
"one video pixel per output pixel. The units stay as wide as they are now.";
|
|
269
|
-
const sizeVideoBtn = button(
|
|
277
|
+
const sizeVideoBtn = button(
|
|
278
|
+
rectRow,
|
|
279
|
+
"Make video this size",
|
|
280
|
+
SIZE_VIDEO_TITLE,
|
|
281
|
+
);
|
|
270
282
|
const rectButtons = [
|
|
271
283
|
{
|
|
272
284
|
text: "Fit canvas",
|
|
273
|
-
title:
|
|
285
|
+
title:
|
|
286
|
+
"As large as possible while the whole video stays on the canvas. Centered.",
|
|
274
287
|
make: (info: VideoInfo) =>
|
|
275
288
|
centeredOnCanvas(maxFit(info.video.width, info.video.height)),
|
|
276
289
|
},
|
|
277
290
|
{
|
|
278
291
|
text: "Cover canvas",
|
|
279
|
-
title:
|
|
292
|
+
title:
|
|
293
|
+
"Just large enough to cover the whole canvas. Some of the video will be off screen. Centered.",
|
|
280
294
|
make: (info: VideoInfo) =>
|
|
281
295
|
centeredOnCanvas(minCover(info.video.width, info.video.height)),
|
|
282
296
|
},
|
|
@@ -288,11 +302,15 @@ export function buildVideoClipPanel(
|
|
|
288
302
|
},
|
|
289
303
|
{
|
|
290
304
|
text: "Shrink to video",
|
|
291
|
-
title:
|
|
305
|
+
title:
|
|
306
|
+
"Shrink the rectangle to the area the video actually covers inside it, so the handles hug the picture.",
|
|
292
307
|
make: (info: VideoInfo, rect: ReadOnlyRect) =>
|
|
293
308
|
shrinkToAspect(rect, info.video.width / info.video.height),
|
|
294
309
|
},
|
|
295
|
-
].map(({ text, title, make }) => ({
|
|
310
|
+
].map(({ text, title, make }) => ({
|
|
311
|
+
btn: button(rectRow, text, title),
|
|
312
|
+
make,
|
|
313
|
+
}));
|
|
296
314
|
|
|
297
315
|
/**
|
|
298
316
|
* Snap one edge of the Dest Rect to the canvas, or center it, keeping its
|
|
@@ -323,7 +341,11 @@ export function buildVideoClipPanel(
|
|
|
323
341
|
audioStatusEl.style.marginRight = "0.5em";
|
|
324
342
|
audioRow.append(audioStatusEl);
|
|
325
343
|
const importBtn = button(audioRow, "Import audio", "");
|
|
326
|
-
const removeAudioBtn = button(
|
|
344
|
+
const removeAudioBtn = button(
|
|
345
|
+
audioRow,
|
|
346
|
+
"Remove",
|
|
347
|
+
"Remove the audio this panel imported.",
|
|
348
|
+
);
|
|
327
349
|
|
|
328
350
|
/** The last answer we got from the file, or why there isn't one. */
|
|
329
351
|
let info: VideoInfo | undefined;
|
|
@@ -407,7 +429,10 @@ export function buildVideoClipPanel(
|
|
|
407
429
|
if (ready) {
|
|
408
430
|
const fileMs = info!.durationMs;
|
|
409
431
|
if (end > fileMs + 0.5) {
|
|
410
|
-
add(
|
|
432
|
+
add(
|
|
433
|
+
`End is past the end of the file (${Math.round(fileMs)} ms).`,
|
|
434
|
+
"#a06000",
|
|
435
|
+
);
|
|
411
436
|
} else if (fileMs > 0) {
|
|
412
437
|
const used = (Math.max(0, Math.max(start, end) - start) / fileMs) * 100;
|
|
413
438
|
add(`Using ${used.toFixed(used < 10 ? 1 : 0)}% of the file.`);
|
|
@@ -433,7 +458,9 @@ export function buildVideoClipPanel(
|
|
|
433
458
|
|
|
434
459
|
const splitProblem = hooks.splitProblem();
|
|
435
460
|
splitBtn.disabled = splitProblem !== undefined;
|
|
436
|
-
splitBtn.title = splitProblem
|
|
461
|
+
splitBtn.title = splitProblem
|
|
462
|
+
? `${SPLIT_TITLE}\n\n${splitProblem}`
|
|
463
|
+
: SPLIT_TITLE;
|
|
437
464
|
wholeFileBtn.disabled = !ready;
|
|
438
465
|
realTimeBtn.hidden = Number.isNaN(speed) || isRealTime(speed);
|
|
439
466
|
realTimeBtn.disabled = !(end > start);
|
|
@@ -473,13 +500,22 @@ export function buildVideoClipPanel(
|
|
|
473
500
|
if (state !== "ready" || !info) {
|
|
474
501
|
setStatus(imported.length ? "Audio: imported" : "Audio:");
|
|
475
502
|
importBtn.disabled = true;
|
|
476
|
-
importBtn.textContent = imported.length
|
|
503
|
+
importBtn.textContent = imported.length
|
|
504
|
+
? "Re-import audio"
|
|
505
|
+
: "Import audio";
|
|
477
506
|
return;
|
|
478
507
|
}
|
|
479
508
|
const audio = info.audio;
|
|
480
|
-
importBtn.textContent = imported.length
|
|
509
|
+
importBtn.textContent = imported.length
|
|
510
|
+
? "Re-import audio"
|
|
511
|
+
: "Import audio";
|
|
481
512
|
if (!audio) {
|
|
482
|
-
setStatus(
|
|
513
|
+
setStatus(
|
|
514
|
+
imported.length
|
|
515
|
+
? "Audio: imported, but this file has none"
|
|
516
|
+
: "No audio track",
|
|
517
|
+
"#888",
|
|
518
|
+
);
|
|
483
519
|
importBtn.disabled = true;
|
|
484
520
|
importBtn.title = "This file has no audio track.";
|
|
485
521
|
return;
|
|
@@ -487,7 +523,10 @@ export function buildVideoClipPanel(
|
|
|
487
523
|
if (!isRealTime(speed)) {
|
|
488
524
|
// The soundtrack can't change the speed of a sound, so anything but 1×
|
|
489
525
|
// would drift out of sync.
|
|
490
|
-
setStatus(
|
|
526
|
+
setStatus(
|
|
527
|
+
`Audio needs 1× — currently ${Number.isNaN(speed) ? "—" : formatSpeed(speed)}`,
|
|
528
|
+
"#a06000",
|
|
529
|
+
);
|
|
491
530
|
importBtn.disabled = true;
|
|
492
531
|
importBtn.title = "Click Play at 1× first.";
|
|
493
532
|
return;
|
|
@@ -501,7 +540,8 @@ export function buildVideoClipPanel(
|
|
|
501
540
|
setStatus("");
|
|
502
541
|
} else if (imported.length > 1) {
|
|
503
542
|
setStatus("Audio imported, then cut into pieces");
|
|
504
|
-
importBtn.title +=
|
|
543
|
+
importBtn.title +=
|
|
544
|
+
"\n\nRe-import replaces the pieces with one sound clip, lined up with the picture.";
|
|
505
545
|
} else if (sameSoundClip(imported[0], expected)) {
|
|
506
546
|
setStatus("Audio imported ✓", "#070");
|
|
507
547
|
} else {
|
|
@@ -593,7 +633,12 @@ export function buildVideoClipPanel(
|
|
|
593
633
|
const unitsPerPixel = width / pixelWidth;
|
|
594
634
|
return {
|
|
595
635
|
size: { pixelWidth, pixelHeight, width, height },
|
|
596
|
-
rect: {
|
|
636
|
+
rect: {
|
|
637
|
+
x: 0,
|
|
638
|
+
y: 0,
|
|
639
|
+
width: videoWidth * unitsPerPixel,
|
|
640
|
+
height: videoHeight * unitsPerPixel,
|
|
641
|
+
},
|
|
597
642
|
};
|
|
598
643
|
}
|
|
599
644
|
|
|
@@ -603,7 +648,8 @@ export function buildVideoClipPanel(
|
|
|
603
648
|
// Several keyframes and none chosen: clicking explains that, so keep the button enabled.
|
|
604
649
|
if (typeof target === "string") return false;
|
|
605
650
|
const { size, rect } = clipSize(info);
|
|
606
|
-
const close = (a: number, b: number) =>
|
|
651
|
+
const close = (a: number, b: number) =>
|
|
652
|
+
Math.abs(a - b) <= 1e-6 * Math.max(1, Math.abs(b));
|
|
607
653
|
const current = canvasRecorder.size;
|
|
608
654
|
return (
|
|
609
655
|
current.pixelWidth === size.pixelWidth &&
|
package/dev/voice/chirp.ts
CHANGED
|
@@ -36,7 +36,8 @@ function sweepSamples({ from, to, seconds }: Sweep, sampleRate: number) {
|
|
|
36
36
|
const k = Math.log(to / from);
|
|
37
37
|
for (let i = 0; i < count; i++) {
|
|
38
38
|
const t = i / sampleRate;
|
|
39
|
-
const phase =
|
|
39
|
+
const phase =
|
|
40
|
+
(2 * Math.PI * from * seconds * (Math.exp((t * k) / seconds) - 1)) / k;
|
|
40
41
|
samples[i] = AMPLITUDE * Math.sin(phase);
|
|
41
42
|
}
|
|
42
43
|
const fade = Math.min(count / 2, Math.round(FADE_SECONDS * sampleRate));
|
|
@@ -78,7 +79,9 @@ export function findSound(
|
|
|
78
79
|
for (let i = 0; i < sound.length; i += step) {
|
|
79
80
|
sum += sound[i] * recording[lag + i];
|
|
80
81
|
}
|
|
81
|
-
const norm = Math.sqrt(
|
|
82
|
+
const norm = Math.sqrt(
|
|
83
|
+
energy(recording, lag, sound.length, step) * (soundEnergy / step),
|
|
84
|
+
);
|
|
82
85
|
return norm > 0 ? sum / norm : 0;
|
|
83
86
|
};
|
|
84
87
|
// Coarse: every 4th lag, every 4th sample.
|
|
@@ -93,7 +96,11 @@ export function findSound(
|
|
|
93
96
|
}
|
|
94
97
|
// Exact: every lag near the best one, every sample.
|
|
95
98
|
const exact = new Map<number, number>();
|
|
96
|
-
for (
|
|
99
|
+
for (
|
|
100
|
+
let lag = Math.max(first, best - 6);
|
|
101
|
+
lag <= Math.min(last, best + 6);
|
|
102
|
+
lag++
|
|
103
|
+
) {
|
|
97
104
|
exact.set(lag, score(lag, 1));
|
|
98
105
|
}
|
|
99
106
|
for (const [lag, s] of exact) {
|
|
@@ -116,10 +123,19 @@ export function findSound(
|
|
|
116
123
|
for (let i = best; i < best + sound.length; i++) {
|
|
117
124
|
peak = Math.max(peak, Math.abs(recording[i]));
|
|
118
125
|
}
|
|
119
|
-
return {
|
|
126
|
+
return {
|
|
127
|
+
position,
|
|
128
|
+
match: Math.max(0, here),
|
|
129
|
+
peakDb: 20 * Math.log10(peak || 1e-12),
|
|
130
|
+
};
|
|
120
131
|
}
|
|
121
132
|
|
|
122
|
-
function energy(
|
|
133
|
+
function energy(
|
|
134
|
+
samples: Float32Array,
|
|
135
|
+
start: number,
|
|
136
|
+
length: number,
|
|
137
|
+
step: number,
|
|
138
|
+
) {
|
|
123
139
|
let sum = 0;
|
|
124
140
|
for (let i = 0; i < length; i += step) {
|
|
125
141
|
const v = samples[start + i];
|
package/dev/voice/folder.ts
CHANGED
|
@@ -27,7 +27,9 @@ function inStore<T>(
|
|
|
27
27
|
open.onupgradeneeded = () => open.result.createObjectStore(STORE);
|
|
28
28
|
open.onerror = () => reject(open.error);
|
|
29
29
|
open.onsuccess = () => {
|
|
30
|
-
const request = run(
|
|
30
|
+
const request = run(
|
|
31
|
+
open.result.transaction(STORE, mode).objectStore(STORE),
|
|
32
|
+
);
|
|
31
33
|
request.onsuccess = () => resolve(request.result);
|
|
32
34
|
request.onerror = () => reject(request.error);
|
|
33
35
|
};
|
|
@@ -35,7 +37,9 @@ function inStore<T>(
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** The folder chosen last time, if there is one. */
|
|
38
|
-
export async function rememberedFolder(): Promise<
|
|
40
|
+
export async function rememberedFolder(): Promise<
|
|
41
|
+
FileSystemDirectoryHandle | undefined
|
|
42
|
+
> {
|
|
39
43
|
try {
|
|
40
44
|
return await inStore("readonly", (store) => store.get(KEY));
|
|
41
45
|
} catch {
|
|
@@ -44,15 +48,21 @@ export async function rememberedFolder(): Promise<FileSystemDirectoryHandle | un
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/** Save recordings here from now on. */
|
|
47
|
-
export async function rememberFolder(
|
|
51
|
+
export async function rememberFolder(
|
|
52
|
+
folder: FileSystemDirectoryHandle,
|
|
53
|
+
): Promise<void> {
|
|
48
54
|
await inStore("readwrite", (store) => store.put(folder, KEY));
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
/** Ask the user for a folder. Undefined if they cancel. Call this from a click. */
|
|
52
|
-
export async function chooseFolder(): Promise<
|
|
58
|
+
export async function chooseFolder(): Promise<
|
|
59
|
+
FileSystemDirectoryHandle | undefined
|
|
60
|
+
> {
|
|
53
61
|
const picker = (
|
|
54
62
|
window as unknown as {
|
|
55
|
-
showDirectoryPicker?: (
|
|
63
|
+
showDirectoryPicker?: (
|
|
64
|
+
options: object,
|
|
65
|
+
) => Promise<FileSystemDirectoryHandle>;
|
|
56
66
|
}
|
|
57
67
|
).showDirectoryPicker;
|
|
58
68
|
if (!picker) {
|
|
@@ -71,7 +81,10 @@ export async function chooseFolder(): Promise<FileSystemDirectoryHandle | undefi
|
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
/** Can we write to this folder? If ask is true, ask for permission if we need it. That needs a click. */
|
|
74
|
-
export async function canWrite(
|
|
84
|
+
export async function canWrite(
|
|
85
|
+
folder: FileSystemDirectoryHandle,
|
|
86
|
+
ask: boolean,
|
|
87
|
+
): Promise<boolean> {
|
|
75
88
|
const handle = folder as WithPermission;
|
|
76
89
|
// Folders that don't need permission, like the browser's private storage, don't have these.
|
|
77
90
|
if (!handle.queryPermission || !handle.requestPermission) {
|
|
@@ -80,5 +93,7 @@ export async function canWrite(folder: FileSystemDirectoryHandle, ask: boolean):
|
|
|
80
93
|
if ((await handle.queryPermission({ mode: "readwrite" })) == "granted") {
|
|
81
94
|
return true;
|
|
82
95
|
}
|
|
83
|
-
return
|
|
96
|
+
return (
|
|
97
|
+
ask && (await handle.requestPermission({ mode: "readwrite" })) == "granted"
|
|
98
|
+
);
|
|
84
99
|
}
|
package/dev/voice/voice-panel.ts
CHANGED
|
@@ -27,7 +27,10 @@ export type VoicePanelOptions = {
|
|
|
27
27
|
/** The player's AudioContext, so the mic and the video share one clock. */
|
|
28
28
|
readonly context: AudioContext;
|
|
29
29
|
/** ● Record, with a folder we can write to. Start recording, and the video. */
|
|
30
|
-
readonly onRecord: (
|
|
30
|
+
readonly onRecord: (
|
|
31
|
+
recorder: VoiceRecorder,
|
|
32
|
+
folder: FileSystemDirectoryHandle,
|
|
33
|
+
) => Promise<void>;
|
|
31
34
|
/** ■ Stop. */
|
|
32
35
|
readonly onStop: () => void;
|
|
33
36
|
/** Called after the panel closes, by × or by {@link VoicePanel.close}. */
|
|
@@ -263,7 +266,9 @@ function loadChoices(): ProcessingChoices {
|
|
|
263
266
|
* Open the panel and turn on the mic. Call this from a click, so the browser lets audio start.
|
|
264
267
|
* The browser asks for permission to use the mic the first time.
|
|
265
268
|
*/
|
|
266
|
-
export async function openVoicePanel(
|
|
269
|
+
export async function openVoicePanel(
|
|
270
|
+
options: VoicePanelOptions,
|
|
271
|
+
): Promise<VoicePanel> {
|
|
267
272
|
addStyles();
|
|
268
273
|
const panel = element("div", "vr-panel");
|
|
269
274
|
const close = element("button", "vr-close", "×");
|
|
@@ -290,7 +295,14 @@ export async function openVoicePanel(options: VoicePanelOptions): Promise<VoiceP
|
|
|
290
295
|
const folderName = element("b", "", "…");
|
|
291
296
|
const changeFolder = element("button", "", "Change…");
|
|
292
297
|
changeFolder.style.padding = "0 6px";
|
|
293
|
-
const folderLine = element(
|
|
298
|
+
const folderLine = element(
|
|
299
|
+
"div",
|
|
300
|
+
"vr-small",
|
|
301
|
+
"Folder: ",
|
|
302
|
+
folderName,
|
|
303
|
+
" ",
|
|
304
|
+
changeFolder,
|
|
305
|
+
);
|
|
294
306
|
const record = element("button", "vr-record", "● Record");
|
|
295
307
|
record.title =
|
|
296
308
|
"Play the chirp, then record your voice while the video plays. Pause the video to stop. " +
|
|
@@ -322,7 +334,9 @@ export async function openVoicePanel(options: VoicePanelOptions): Promise<VoiceP
|
|
|
322
334
|
const savedChirpLevel = Number(localStorage.getItem(STORAGE.chirpLevel));
|
|
323
335
|
placeMark(
|
|
324
336
|
soundMark,
|
|
325
|
-
Number.isFinite(savedChirpLevel) && savedChirpLevel < 0
|
|
337
|
+
Number.isFinite(savedChirpLevel) && savedChirpLevel < 0
|
|
338
|
+
? savedChirpLevel
|
|
339
|
+
: undefined,
|
|
326
340
|
);
|
|
327
341
|
const closed = () => {
|
|
328
342
|
panel.remove();
|
|
@@ -333,7 +347,9 @@ export async function openVoicePanel(options: VoicePanelOptions): Promise<VoiceP
|
|
|
333
347
|
// Not awaited: the mic should start while this click still counts as a click.
|
|
334
348
|
let folder: FileSystemDirectoryHandle | undefined;
|
|
335
349
|
const showFolder = () => {
|
|
336
|
-
folderName.textContent = folder
|
|
350
|
+
folderName.textContent = folder
|
|
351
|
+
? folder.name || "browser storage"
|
|
352
|
+
: "not chosen yet";
|
|
337
353
|
};
|
|
338
354
|
void rememberedFolder().then((remembered) => {
|
|
339
355
|
// ??=, in case Change… or setFolder() got here first.
|
|
@@ -355,7 +371,10 @@ export async function openVoicePanel(options: VoicePanelOptions): Promise<VoiceP
|
|
|
355
371
|
recorder = await VoiceRecorder.open(options.context, loadChoices());
|
|
356
372
|
} catch (error) {
|
|
357
373
|
micLine.textContent = "No mic.";
|
|
358
|
-
say(
|
|
374
|
+
say(
|
|
375
|
+
`Couldn't turn on the mic: ${error instanceof Error ? error.message : error}`,
|
|
376
|
+
true,
|
|
377
|
+
);
|
|
359
378
|
// Leave the panel up, so you can read why.
|
|
360
379
|
close.addEventListener("click", closed);
|
|
361
380
|
throw error;
|
|
@@ -371,7 +390,8 @@ export async function openVoicePanel(options: VoicePanelOptions): Promise<VoiceP
|
|
|
371
390
|
const now = performance.now();
|
|
372
391
|
const seconds = (now - lastLevel) / 1000;
|
|
373
392
|
lastLevel = now;
|
|
374
|
-
meanSquare +=
|
|
393
|
+
meanSquare +=
|
|
394
|
+
(rms * rms - meanSquare) * (1 - Math.exp(-seconds / METER_SECONDS));
|
|
375
395
|
const peakDb = toDb(peakLevel);
|
|
376
396
|
if (peakDb >= held) {
|
|
377
397
|
held = peakDb;
|
|
@@ -396,13 +416,16 @@ export async function openVoicePanel(options: VoicePanelOptions): Promise<VoiceP
|
|
|
396
416
|
const requested = loadChoices();
|
|
397
417
|
for (const [name, got] of gotLabels) {
|
|
398
418
|
const value = actual[name];
|
|
399
|
-
got.textContent =
|
|
419
|
+
got.textContent =
|
|
420
|
+
value === undefined ? "got: ?" : `got: ${value ? "on" : "off"}`;
|
|
400
421
|
got.classList.toggle(
|
|
401
422
|
"vr-mismatch",
|
|
402
423
|
value !== undefined && value !== (requested[name] ?? false),
|
|
403
424
|
);
|
|
404
425
|
}
|
|
405
|
-
const rate = actual.sampleRate
|
|
426
|
+
const rate = actual.sampleRate
|
|
427
|
+
? ` · ${Number(actual.sampleRate) / 1000} kHz`
|
|
428
|
+
: "";
|
|
406
429
|
micLine.textContent = `Mic: ${recorder.micName || "unknown"}${rate}`;
|
|
407
430
|
};
|
|
408
431
|
for (const { name, label, help } of supportedProcessing()) {
|
|
@@ -505,7 +528,8 @@ export async function openVoicePanel(options: VoicePanelOptions): Promise<VoiceP
|
|
|
505
528
|
}
|
|
506
529
|
},
|
|
507
530
|
setPastEnd(ms) {
|
|
508
|
-
pastEnd.textContent =
|
|
531
|
+
pastEnd.textContent =
|
|
532
|
+
ms === undefined ? "" : `+${(ms / 1000).toFixed(1)} s past the end`;
|
|
509
533
|
},
|
|
510
534
|
say,
|
|
511
535
|
setFolder(newFolder) {
|
|
@@ -139,7 +139,12 @@ registerProcessor("voice-recorder", VoiceRecorderProcessor);
|
|
|
139
139
|
/** addModule() for each context only once: registering the processor twice is an error. */
|
|
140
140
|
const workletLoaded = new WeakMap<BaseAudioContext, Promise<void>>();
|
|
141
141
|
|
|
142
|
-
type Chunk = {
|
|
142
|
+
type Chunk = {
|
|
143
|
+
first: number;
|
|
144
|
+
samples: Float32Array;
|
|
145
|
+
peak: number;
|
|
146
|
+
rms: number;
|
|
147
|
+
};
|
|
143
148
|
|
|
144
149
|
export type HeardResult = {
|
|
145
150
|
/** Undefined if the chirp wasn't found: speakers off, or headphones. */
|
|
@@ -241,16 +246,22 @@ export class VoiceRecorder {
|
|
|
241
246
|
this.#choices = choices;
|
|
242
247
|
const saved = Number(localStorage.getItem(DELAY_KEY));
|
|
243
248
|
this.micDelayMs = saved > 0 ? saved : DEFAULT_DELAY_MS;
|
|
244
|
-
node.port.onmessage = (event: MessageEvent<Chunk>) =>
|
|
249
|
+
node.port.onmessage = (event: MessageEvent<Chunk>) =>
|
|
250
|
+
this.#receive(event.data);
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
/**
|
|
248
254
|
* Turn on the mic. Call this from a click, so the browser lets the audio start.
|
|
249
255
|
* The browser asks for permission to use the mic the first time.
|
|
250
256
|
*/
|
|
251
|
-
static async open(
|
|
257
|
+
static async open(
|
|
258
|
+
context: AudioContext,
|
|
259
|
+
choices: ProcessingChoices,
|
|
260
|
+
): Promise<VoiceRecorder> {
|
|
252
261
|
await workletLoaded.getOrInsertComputed(context, async () => {
|
|
253
|
-
const url = URL.createObjectURL(
|
|
262
|
+
const url = URL.createObjectURL(
|
|
263
|
+
new Blob([WORKLET], { type: "text/javascript" }),
|
|
264
|
+
);
|
|
254
265
|
try {
|
|
255
266
|
await context.audioWorklet.addModule(url);
|
|
256
267
|
} finally {
|
|
@@ -281,8 +292,12 @@ export class VoiceRecorder {
|
|
|
281
292
|
}
|
|
282
293
|
|
|
283
294
|
async #connectMic() {
|
|
284
|
-
this.#stream = await navigator.mediaDevices.getUserMedia({
|
|
285
|
-
|
|
295
|
+
this.#stream = await navigator.mediaDevices.getUserMedia({
|
|
296
|
+
audio: this.#constraints(),
|
|
297
|
+
});
|
|
298
|
+
this.#source = new MediaStreamAudioSourceNode(this.context, {
|
|
299
|
+
mediaStream: this.#stream,
|
|
300
|
+
});
|
|
286
301
|
this.#source.connect(this.#node);
|
|
287
302
|
}
|
|
288
303
|
|
|
@@ -333,7 +348,10 @@ export class VoiceRecorder {
|
|
|
333
348
|
*
|
|
334
349
|
* @param prefix The start of each file's name, usually the video's name.
|
|
335
350
|
*/
|
|
336
|
-
async start(
|
|
351
|
+
async start(
|
|
352
|
+
folder: FileSystemDirectoryHandle,
|
|
353
|
+
prefix: string,
|
|
354
|
+
): Promise<void> {
|
|
337
355
|
if (this.#session) return;
|
|
338
356
|
await this.context.resume();
|
|
339
357
|
const chirp = chirpSamples(SAMPLE_RATE);
|
|
@@ -346,7 +364,11 @@ export class VoiceRecorder {
|
|
|
346
364
|
session.current = file;
|
|
347
365
|
this.#listening = { file, samples: chirp };
|
|
348
366
|
// Straight to the speakers, so the player's mute doesn't silence it.
|
|
349
|
-
const buffer = new AudioBuffer({
|
|
367
|
+
const buffer = new AudioBuffer({
|
|
368
|
+
numberOfChannels: 1,
|
|
369
|
+
length: chirp.length,
|
|
370
|
+
sampleRate: SAMPLE_RATE,
|
|
371
|
+
});
|
|
350
372
|
buffer.copyToChannel(chirp, 0);
|
|
351
373
|
const node = new AudioBufferSourceNode(this.context, { buffer });
|
|
352
374
|
node.connect(this.context.destination);
|
|
@@ -354,7 +376,10 @@ export class VoiceRecorder {
|
|
|
354
376
|
node.start(when);
|
|
355
377
|
const videoStarts = when + buffer.duration + AFTER_CHIRP_S;
|
|
356
378
|
await new Promise((resolve) =>
|
|
357
|
-
setTimeout(
|
|
379
|
+
setTimeout(
|
|
380
|
+
resolve,
|
|
381
|
+
Math.max(0, videoStarts - this.context.currentTime) * 1000,
|
|
382
|
+
),
|
|
358
383
|
);
|
|
359
384
|
}
|
|
360
385
|
|
|
@@ -448,7 +473,11 @@ export class VoiceRecorder {
|
|
|
448
473
|
folder: session.folder,
|
|
449
474
|
name,
|
|
450
475
|
startFrame,
|
|
451
|
-
buffer: new AudioBuffer({
|
|
476
|
+
buffer: new AudioBuffer({
|
|
477
|
+
numberOfChannels: 1,
|
|
478
|
+
length: 10 * SAMPLE_RATE,
|
|
479
|
+
sampleRate: SAMPLE_RATE,
|
|
480
|
+
}),
|
|
452
481
|
frames: 0,
|
|
453
482
|
handle,
|
|
454
483
|
writing: handle
|
|
@@ -484,7 +513,10 @@ export class VoiceRecorder {
|
|
|
484
513
|
(file.endFrame ?? Infinity) - chunk.first,
|
|
485
514
|
);
|
|
486
515
|
if (to > from) this.#append(file, chunk.samples.subarray(from, to));
|
|
487
|
-
if (
|
|
516
|
+
if (
|
|
517
|
+
file.endFrame !== undefined &&
|
|
518
|
+
chunk.first + chunk.samples.length >= file.endFrame
|
|
519
|
+
) {
|
|
488
520
|
void this.#finish(file);
|
|
489
521
|
}
|
|
490
522
|
}
|
|
@@ -499,7 +531,9 @@ export class VoiceRecorder {
|
|
|
499
531
|
length: Math.max(needed, file.buffer.length * 2),
|
|
500
532
|
sampleRate: SAMPLE_RATE,
|
|
501
533
|
});
|
|
502
|
-
bigger
|
|
534
|
+
bigger
|
|
535
|
+
.getChannelData(0)
|
|
536
|
+
.set(file.buffer.getChannelData(0).subarray(0, file.frames));
|
|
503
537
|
file.buffer = bigger;
|
|
504
538
|
}
|
|
505
539
|
file.buffer.getChannelData(0).set(samples, file.frames);
|
|
@@ -518,10 +552,19 @@ export class VoiceRecorder {
|
|
|
518
552
|
if (!listening) return;
|
|
519
553
|
const { file, samples } = listening;
|
|
520
554
|
// The file starts when the chirp was played, so a sound that took no time at all would be at 0.
|
|
521
|
-
if (
|
|
555
|
+
if (
|
|
556
|
+
!file.done &&
|
|
557
|
+
file.frames < samples.length + SEARCH_AFTER_S * SAMPLE_RATE
|
|
558
|
+
)
|
|
559
|
+
return;
|
|
522
560
|
this.#listening = undefined;
|
|
523
561
|
const recording = file.buffer.getChannelData(0).subarray(0, file.frames);
|
|
524
|
-
const found = findSound(
|
|
562
|
+
const found = findSound(
|
|
563
|
+
recording,
|
|
564
|
+
samples,
|
|
565
|
+
0,
|
|
566
|
+
SEARCH_AFTER_S * SAMPLE_RATE,
|
|
567
|
+
);
|
|
525
568
|
const heard = found.match > HEARD;
|
|
526
569
|
const result: HeardResult = {
|
|
527
570
|
roundTripMs: heard ? (found.position / SAMPLE_RATE) * 1000 : undefined,
|
|
@@ -548,7 +591,11 @@ export class VoiceRecorder {
|
|
|
548
591
|
const frames = file.frames;
|
|
549
592
|
try {
|
|
550
593
|
const stream = await file.writing;
|
|
551
|
-
await stream.write({
|
|
594
|
+
await stream.write({
|
|
595
|
+
type: "write",
|
|
596
|
+
position: 0,
|
|
597
|
+
data: wavHeader(frames),
|
|
598
|
+
});
|
|
552
599
|
await stream.close();
|
|
553
600
|
const handle = await file.handle;
|
|
554
601
|
if (file.clipStart === undefined) {
|
|
@@ -562,10 +609,19 @@ export class VoiceRecorder {
|
|
|
562
609
|
length: Math.max(1, frames),
|
|
563
610
|
sampleRate: SAMPLE_RATE,
|
|
564
611
|
});
|
|
565
|
-
buffer.copyToChannel(
|
|
612
|
+
buffer.copyToChannel(
|
|
613
|
+
file.buffer.getChannelData(0).subarray(0, frames),
|
|
614
|
+
0,
|
|
615
|
+
);
|
|
566
616
|
const trimMs = this.#trimMs(file);
|
|
567
|
-
const lengthMs =
|
|
568
|
-
|
|
617
|
+
const lengthMs =
|
|
618
|
+
((file.clipEnd ?? file.clipStart) - file.clipStart) * 1000;
|
|
619
|
+
file.resolve({
|
|
620
|
+
url: await addLocalFile(handle),
|
|
621
|
+
buffer,
|
|
622
|
+
trimMs,
|
|
623
|
+
lengthMs,
|
|
624
|
+
});
|
|
569
625
|
} catch (error) {
|
|
570
626
|
file.reject(error);
|
|
571
627
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio-builder.js","sourceRoot":"","sources":["../../dev/audio-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IACvB;;OAEG;IACK,MAAM,CAAc;IAE5B,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YAAY,eAAuB,EAAE,UAAU,GAAG,KAAK;QACrD,sEAAsE;QACtE,yCAAyC;QACzC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAC3B,CAAC,EACD,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,UAAU,CAAC,CACjD,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC;YAC5B,gBAAgB,EAAE,CAAC;YACnB,MAAM,EAAE,YAAY;YACpB,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,GAAG,CACD,YAAyB,EACzB,oBAA4B,EAC5B,kBAA0B,CAAC,EAC3B,SAAiB,QAAQ;QAEzB,IAAI,oBAAoB,GAAG,CAAC,EAAE,CAAC;YAC7B,yDAAyD;YACzD,eAAe,IAAI,oBAA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AE,EAAE,GAAG,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrD,IAAI,CAAC,QAAQ,CACX,MAAM,EACN,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,EAC9C,IAAI,CACL,CAAC;YACF,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -22,8 +22,12 @@ body {
|
|
|
22
22
|
height: 100%;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
#left-col
|
|
26
|
-
|
|
25
|
+
#left-col {
|
|
26
|
+
flex: 0 0 50%;
|
|
27
|
+
}
|
|
28
|
+
#right-col {
|
|
29
|
+
flex: 1;
|
|
30
|
+
}
|
|
27
31
|
|
|
28
32
|
/* ── Vertical resize handle between left/right columns ──────────────── */
|
|
29
33
|
|
|
@@ -139,7 +143,7 @@ body {
|
|
|
139
143
|
display: block;
|
|
140
144
|
width: 100%;
|
|
141
145
|
min-height: 28px;
|
|
142
|
-
max-height: 168px;
|
|
146
|
+
max-height: 168px; /* cap at 6 rows × 28 px */
|
|
143
147
|
cursor: crosshair;
|
|
144
148
|
border-bottom: 1px solid #bbb;
|
|
145
149
|
box-sizing: border-box;
|
|
@@ -208,6 +212,9 @@ body {
|
|
|
208
212
|
font-style: italic;
|
|
209
213
|
color: #777;
|
|
210
214
|
}
|
|
215
|
+
#transcriptView .tv-problem {
|
|
216
|
+
color: #b00020;
|
|
217
|
+
}
|
|
211
218
|
#transcriptView .tv-word {
|
|
212
219
|
cursor: pointer;
|
|
213
220
|
border-radius: 2px;
|
|
@@ -337,6 +344,11 @@ body {
|
|
|
337
344
|
flex-grow: 1;
|
|
338
345
|
}
|
|
339
346
|
|
|
347
|
+
/* About 60% of the default width, to make room for "local". */
|
|
348
|
+
#playPositionSeconds {
|
|
349
|
+
width: 6.5em;
|
|
350
|
+
}
|
|
351
|
+
|
|
340
352
|
/* ── History dialog ──────────────────────────────────────────────────── */
|
|
341
353
|
|
|
342
354
|
#historyList li.selected {
|
|
@@ -359,7 +371,6 @@ body {
|
|
|
359
371
|
outline-offset: -2px;
|
|
360
372
|
}
|
|
361
373
|
|
|
362
|
-
|
|
363
374
|
/* ── Component picker dialog ─────────────────────────────────────────── */
|
|
364
375
|
|
|
365
376
|
.component-picker li.selected {
|