@joewinke/jatui 0.12.0 → 0.14.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/dist/components/VideoPlayer.svelte +332 -8
- package/dist/components/VideoPlayer.svelte.d.ts +76 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -0
- package/dist/video/README.md +6 -5
- package/dist/video/audio/graph.d.ts +115 -0
- package/dist/video/audio/graph.js +400 -0
- package/dist/video/audio/rider.d.ts +134 -0
- package/dist/video/audio/rider.js +187 -0
- package/dist/video/audio.d.ts +30 -19
- package/dist/video/audio.js +30 -19
- package/dist/video/rate/ads.d.ts +36 -0
- package/dist/video/rate/ads.js +59 -0
- package/dist/video/rate/compose.d.ts +82 -0
- package/dist/video/rate/compose.js +114 -0
- package/dist/video/rate/silence.d.ts +27 -0
- package/dist/video/rate/silence.js +48 -0
- package/dist/video/rate/speaker.d.ts +54 -0
- package/dist/video/rate/speaker.js +94 -0
- package/dist/video/rate/tick.d.ts +38 -0
- package/dist/video/rate/tick.js +15 -0
- package/dist/video/rate.d.ts +20 -63
- package/dist/video/rate.js +20 -82
- package/dist/video/settings.js +16 -2
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart speed — the `silence` factor of the rate composer (mos-5lzns.32).
|
|
3
|
+
*
|
|
4
|
+
* The measuring is `../advisors/smart-speed` (ported verbatim by .27): hold
|
|
5
|
+
* 1× through speech, run the gaps between sentences at `boost` (2.2× by
|
|
6
|
+
* default), found off the waveform envelope the band already draws. This
|
|
7
|
+
* file adapts the component's `VideoWaveform` prop and collapses to 1 when
|
|
8
|
+
* the feature is off or the envelope has not arrived.
|
|
9
|
+
*
|
|
10
|
+
* Pure: no DOM, no <video>, no settings reads (src/lib/video/README.md).
|
|
11
|
+
*/
|
|
12
|
+
import { boostAt, buildSilenceMap, estimateSaving } from '../advisors/smart-speed';
|
|
13
|
+
/**
|
|
14
|
+
* The silence map for a waveform, or null when there is nothing to map (no
|
|
15
|
+
* peaks, no known duration, or no qualifying gap at all — a map with zero
|
|
16
|
+
* ranges can never boost, so the caller may as well not hold one).
|
|
17
|
+
*/
|
|
18
|
+
export function silenceMapFor(waveform, durationSec) {
|
|
19
|
+
if (!waveform || !waveform.peaks || !waveform.peaks.length)
|
|
20
|
+
return null;
|
|
21
|
+
const d = Number.isFinite(waveform.durationSec) && waveform.durationSec > 0
|
|
22
|
+
? waveform.durationSec
|
|
23
|
+
: durationSec;
|
|
24
|
+
if (!(Number.isFinite(d) && d > 0))
|
|
25
|
+
return null;
|
|
26
|
+
const map = buildSilenceMap({ duration: d, peaks: waveform.peaks });
|
|
27
|
+
return map.ranges.length ? map : null;
|
|
28
|
+
}
|
|
29
|
+
/** The silence factor at time t: `boost` inside a gap, 1 everywhere else. */
|
|
30
|
+
export function silenceFactor(t, map, opts) {
|
|
31
|
+
if (!map)
|
|
32
|
+
return 1;
|
|
33
|
+
const b = boostAt(t, map, opts ?? null);
|
|
34
|
+
return Number.isFinite(b) && b >= 1 ? b : 1;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* "Smart speed · about 6 min shorter" — the visible surface for an automatic
|
|
38
|
+
* correction (doctrine 2). Empty when the saving would round to nothing, so
|
|
39
|
+
* the caller never flashes a claim it can't back.
|
|
40
|
+
*/
|
|
41
|
+
export function smartSpeedLabel(map, opts) {
|
|
42
|
+
const saved = map ? estimateSaving(map, opts ?? null) : 0;
|
|
43
|
+
if (!(saved >= 1))
|
|
44
|
+
return '';
|
|
45
|
+
if (saved < 60)
|
|
46
|
+
return `Smart speed · ${Math.round(saved)}s shorter`;
|
|
47
|
+
return `Smart speed · ~${Math.round(saved / 60)} min shorter`;
|
|
48
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-speaker pace — the `speaker` factor of the rate composer (mos-5lzns.32).
|
|
3
|
+
*
|
|
4
|
+
* The measuring is `../advisors/speaker-rate` (ported verbatim by .27); this
|
|
5
|
+
* file is the adapter that feeds it the component's props and decides which
|
|
6
|
+
* rate wins for a name:
|
|
7
|
+
*
|
|
8
|
+
* · MANUAL rates are keyed by speaker NAME (the display name a human sees
|
|
9
|
+
* in the legend, not a diarisation label) and ALWAYS beat measured ones.
|
|
10
|
+
* A person who set "Darren 1.3×" meant it; a measurement that disagrees
|
|
11
|
+
* is the thing that is wrong.
|
|
12
|
+
* · MEASURED rates come from `suggestRates(speakerPace(...))` — words per
|
|
13
|
+
* minute off the diarised transcript, levelled to the median pace — and
|
|
14
|
+
* fill only the names nobody set by hand.
|
|
15
|
+
*
|
|
16
|
+
* The advisor collapses to 1 whenever it has nothing to say: feature off, no
|
|
17
|
+
* turns, a gap between turns, an ad read, or a name with no rate. `1` is the
|
|
18
|
+
* composer's identity, so there is no "feature absent" branch anywhere.
|
|
19
|
+
*
|
|
20
|
+
* Pure: no DOM, no <video>, no settings reads (src/lib/video/README.md).
|
|
21
|
+
*/
|
|
22
|
+
import { type RateMap, type RateSegment, type RateTurn, type SuggestOpts } from '../advisors/speaker-rate';
|
|
23
|
+
import type { VideoSpeakerTurn, VideoTranscriptSegment } from '../types';
|
|
24
|
+
/**
|
|
25
|
+
* The name a rate is keyed by — the display name when there is one, else the
|
|
26
|
+
* identity. Deliberately the same precedence for turns and segments, so a
|
|
27
|
+
* measured row and a manual entry for the same person share a key.
|
|
28
|
+
*/
|
|
29
|
+
export declare function speakerNameOf(s: {
|
|
30
|
+
speakerName?: string | null;
|
|
31
|
+
speakerIdentity?: string | null;
|
|
32
|
+
}): string | null;
|
|
33
|
+
/** Component turns → the advisor's shape. Ad reads keep their flag (never a person). */
|
|
34
|
+
export declare function toRateTurns(turns: readonly VideoSpeakerTurn[] | null | undefined): RateTurn[];
|
|
35
|
+
/** Component transcript → the advisor's shape. */
|
|
36
|
+
export declare function toRateSegments(segments: readonly VideoTranscriptSegment[] | null | undefined): RateSegment[];
|
|
37
|
+
export interface SpeakerRateInput {
|
|
38
|
+
turns: RateTurn[];
|
|
39
|
+
segments: RateSegment[];
|
|
40
|
+
/** Hand-set rates by NAME. Always win. */
|
|
41
|
+
manual?: Record<string, number> | null;
|
|
42
|
+
/** Measure the rest from the transcript (false ⇒ manual only). */
|
|
43
|
+
measure?: boolean;
|
|
44
|
+
opts?: SuggestOpts | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* name → rate. Measured first (if asked), then every valid manual entry laid
|
|
48
|
+
* over it — so manual beats measured by construction, not by a comparison.
|
|
49
|
+
* Null-prototype for the same reason the advisor's maps are: a speaker named
|
|
50
|
+
* "__proto__" is a key, not a prototype write.
|
|
51
|
+
*/
|
|
52
|
+
export declare function speakerRateMap(input: SpeakerRateInput): RateMap;
|
|
53
|
+
/** The speaker factor at time t. 1 when nobody (or an ad) is talking, or no rate is known. */
|
|
54
|
+
export declare function speakerFactor(t: number, turns: RateTurn[], rates: RateMap | null): number;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-speaker pace — the `speaker` factor of the rate composer (mos-5lzns.32).
|
|
3
|
+
*
|
|
4
|
+
* The measuring is `../advisors/speaker-rate` (ported verbatim by .27); this
|
|
5
|
+
* file is the adapter that feeds it the component's props and decides which
|
|
6
|
+
* rate wins for a name:
|
|
7
|
+
*
|
|
8
|
+
* · MANUAL rates are keyed by speaker NAME (the display name a human sees
|
|
9
|
+
* in the legend, not a diarisation label) and ALWAYS beat measured ones.
|
|
10
|
+
* A person who set "Darren 1.3×" meant it; a measurement that disagrees
|
|
11
|
+
* is the thing that is wrong.
|
|
12
|
+
* · MEASURED rates come from `suggestRates(speakerPace(...))` — words per
|
|
13
|
+
* minute off the diarised transcript, levelled to the median pace — and
|
|
14
|
+
* fill only the names nobody set by hand.
|
|
15
|
+
*
|
|
16
|
+
* The advisor collapses to 1 whenever it has nothing to say: feature off, no
|
|
17
|
+
* turns, a gap between turns, an ad read, or a name with no rate. `1` is the
|
|
18
|
+
* composer's identity, so there is no "feature absent" branch anywhere.
|
|
19
|
+
*
|
|
20
|
+
* Pure: no DOM, no <video>, no settings reads (src/lib/video/README.md).
|
|
21
|
+
*/
|
|
22
|
+
import { rateAt, speakerPace, suggestRates } from '../advisors/speaker-rate';
|
|
23
|
+
import { RATE_MAX, RATE_MIN } from './compose';
|
|
24
|
+
/**
|
|
25
|
+
* The name a rate is keyed by — the display name when there is one, else the
|
|
26
|
+
* identity. Deliberately the same precedence for turns and segments, so a
|
|
27
|
+
* measured row and a manual entry for the same person share a key.
|
|
28
|
+
*/
|
|
29
|
+
export function speakerNameOf(s) {
|
|
30
|
+
const n = (s.speakerName ?? '').trim() || (s.speakerIdentity ?? '').trim();
|
|
31
|
+
return n || null;
|
|
32
|
+
}
|
|
33
|
+
/** Component turns → the advisor's shape. Ad reads keep their flag (never a person). */
|
|
34
|
+
export function toRateTurns(turns) {
|
|
35
|
+
if (!Array.isArray(turns))
|
|
36
|
+
return [];
|
|
37
|
+
const out = [];
|
|
38
|
+
for (const t of turns) {
|
|
39
|
+
if (!t || typeof t !== 'object')
|
|
40
|
+
continue;
|
|
41
|
+
out.push({ start: t.startSec, end: t.endSec, name: t.ad ? null : speakerNameOf(t), ad: !!t.ad });
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/** Component transcript → the advisor's shape. */
|
|
46
|
+
export function toRateSegments(segments) {
|
|
47
|
+
if (!Array.isArray(segments))
|
|
48
|
+
return [];
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const s of segments) {
|
|
51
|
+
if (!s || typeof s !== 'object')
|
|
52
|
+
continue;
|
|
53
|
+
out.push({ start: s.startSec, end: s.endSec, text: s.text, speaker: speakerNameOf(s) });
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** A usable multiplier, or null. The composer's clamp range is the only sane one. */
|
|
58
|
+
function rateOrNull(v) {
|
|
59
|
+
const n = typeof v === 'number' ? v : Number.NaN;
|
|
60
|
+
return Number.isFinite(n) && n >= RATE_MIN && n <= RATE_MAX ? n : null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* name → rate. Measured first (if asked), then every valid manual entry laid
|
|
64
|
+
* over it — so manual beats measured by construction, not by a comparison.
|
|
65
|
+
* Null-prototype for the same reason the advisor's maps are: a speaker named
|
|
66
|
+
* "__proto__" is a key, not a prototype write.
|
|
67
|
+
*/
|
|
68
|
+
export function speakerRateMap(input) {
|
|
69
|
+
const out = Object.create(null);
|
|
70
|
+
if (input.measure) {
|
|
71
|
+
const measured = suggestRates(speakerPace(input.segments, input.turns), input.opts ?? null);
|
|
72
|
+
for (const [name, r] of Object.entries(measured)) {
|
|
73
|
+
const v = rateOrNull(r);
|
|
74
|
+
if (v != null)
|
|
75
|
+
out[name] = v;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const manual = input.manual;
|
|
79
|
+
if (manual && typeof manual === 'object') {
|
|
80
|
+
for (const [name, r] of Object.entries(manual)) {
|
|
81
|
+
const key = name.trim();
|
|
82
|
+
const v = rateOrNull(r);
|
|
83
|
+
if (key && v != null)
|
|
84
|
+
out[key] = v;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
/** The speaker factor at time t. 1 when nobody (or an ad) is talking, or no rate is known. */
|
|
90
|
+
export function speakerFactor(t, turns, rates) {
|
|
91
|
+
if (!rates || !turns.length)
|
|
92
|
+
return 1;
|
|
93
|
+
return rateOrNull(rateAt(t, turns, rates, 1)) ?? 1;
|
|
94
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rate loop's one-tick decision (mos-5lzns.32).
|
|
3
|
+
*
|
|
4
|
+
* The component runs its OWN 120ms interval for rate — separate from
|
|
5
|
+
* timeupdate (~4Hz, too coarse: a 0.35s gap would be half over before the
|
|
6
|
+
* boost arrived) and from night's ~1s meter. Each tick it reads the playhead
|
|
7
|
+
* and asks this module for the two advisor factors; `composeRate` does the
|
|
8
|
+
* multiplication and `shouldWriteRate` the deadband. This file only bundles
|
|
9
|
+
* the per-tick inputs so the component block stays a few lines long.
|
|
10
|
+
*
|
|
11
|
+
* Pure: no DOM, no <video>, no settings reads (src/lib/video/README.md).
|
|
12
|
+
*/
|
|
13
|
+
import type { BoostOpts, SilenceMap } from '../advisors/smart-speed';
|
|
14
|
+
import type { RateMap, RateTurn } from '../advisors/speaker-rate';
|
|
15
|
+
/** The rate loop's cadence. */
|
|
16
|
+
export declare const RATE_TICK_MS = 120;
|
|
17
|
+
export interface RateAdvisors {
|
|
18
|
+
/** null ⇒ the speaker advisor is off (collapses to 1). */
|
|
19
|
+
speakerRates: RateMap | null;
|
|
20
|
+
turns: RateTurn[];
|
|
21
|
+
/** null ⇒ smart speed is off or has no map yet (collapses to 1). */
|
|
22
|
+
silence: SilenceMap | null;
|
|
23
|
+
boost?: BoostOpts | null;
|
|
24
|
+
}
|
|
25
|
+
export interface RateAdvice {
|
|
26
|
+
speaker: number;
|
|
27
|
+
silence: number;
|
|
28
|
+
/** base × speaker × silence, clamped — what the element should play at. */
|
|
29
|
+
rate: number;
|
|
30
|
+
}
|
|
31
|
+
/** What `onRateChange` reports. `base` is the only factor the UI shows. */
|
|
32
|
+
export interface RateReport extends RateAdvice {
|
|
33
|
+
base: number;
|
|
34
|
+
}
|
|
35
|
+
/** The composed rate at playhead `t` for the human's `base`. */
|
|
36
|
+
export declare function adviseRate(base: number, t: number, a: RateAdvisors): RateAdvice;
|
|
37
|
+
/** Is any advisor able to move the rate? False ⇒ the loop need not run. */
|
|
38
|
+
export declare function advisorsActive(a: RateAdvisors): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { composeRate } from './compose';
|
|
2
|
+
import { silenceFactor } from './silence';
|
|
3
|
+
import { speakerFactor } from './speaker';
|
|
4
|
+
/** The rate loop's cadence. */
|
|
5
|
+
export const RATE_TICK_MS = 120;
|
|
6
|
+
/** The composed rate at playhead `t` for the human's `base`. */
|
|
7
|
+
export function adviseRate(base, t, a) {
|
|
8
|
+
const speaker = speakerFactor(t, a.turns, a.speakerRates);
|
|
9
|
+
const silence = silenceFactor(t, a.silence, a.boost ?? null);
|
|
10
|
+
return { speaker, silence, rate: composeRate(base, speaker, silence).rate };
|
|
11
|
+
}
|
|
12
|
+
/** Is any advisor able to move the rate? False ⇒ the loop need not run. */
|
|
13
|
+
export function advisorsActive(a) {
|
|
14
|
+
return !!a.silence || (!!a.speakerRates && a.turns.length > 0 && Object.keys(a.speakerRates).length > 0);
|
|
15
|
+
}
|
package/dist/video/rate.d.ts
CHANGED
|
@@ -1,69 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Rate module (mos-5lzns.32) — the rate composer and its advisors: smart
|
|
3
|
+
* speed, per-speaker pace, skip ad reads. Ported from extension-library
|
|
4
|
+
* FEATURES.md §The rate composer.
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
* composer") — this is the one non-obvious rule, stated up front because it
|
|
6
|
-
* looks like a bug from the outside:
|
|
6
|
+
* rate = base × speaker × silence (clamp [0.0625, 16], 0.001 deadband)
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* · you — the speed keys (−/=/Backspace, alt+wheel)
|
|
10
|
-
* · speaker — "this person talks fast" (mos-5lzns.32 fills)
|
|
11
|
-
* · silence — "nothing is being said here" (mos-5lzns.32 fills)
|
|
8
|
+
* `base` is the only factor a human chose and the only one the UI reports.
|
|
12
9
|
*
|
|
13
|
-
*
|
|
10
|
+
* Layout (every file pure and node-testable — `npm run test:unit`):
|
|
14
11
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* staircase) — it returns early, before any multiplication, because no
|
|
25
|
-
* advisor gets to un-pause the video by multiplying its way out of zero.
|
|
26
|
-
* 3. Only real changes are written. `playbackRate` is a live audio
|
|
27
|
-
* parameter: writing a *slightly* different value is audible as a wobble.
|
|
28
|
-
* Hence the 0.001 deadband.
|
|
29
|
-
* 4. The clamp is [0.0625, 16] — the range HTML media elements actually
|
|
30
|
-
* support. A product of three multipliers can leave it; a single one
|
|
31
|
-
* cannot.
|
|
32
|
-
*
|
|
33
|
-
* The SPEED_STEPS staircase and formatSpeedLabel are ported from the
|
|
34
|
-
* extension's theater (linear 0.1 steps below 1×, all the way down to 0 —
|
|
35
|
-
* playbackRate=0 is a genuine frozen frame; above 1× the familiar jumps).
|
|
36
|
-
*/
|
|
37
|
-
/** The speed staircase — one step per press of −/=, Backspace resets to 1. */
|
|
38
|
-
export declare const SPEED_STEPS: number[];
|
|
39
|
-
/**
|
|
40
|
-
* "A quarter speed" reads faster as "−.75" than "0.25×" — below 1× the label
|
|
41
|
-
* is the delta, not the multiplier. The 0 step is the frozen-frame end of the
|
|
42
|
-
* staircase — a state, not a level — and the label says so ("0×"), because a
|
|
43
|
-
* frozen frame labeled "1×" lies. Garbage degrades to `1×`.
|
|
44
|
-
*/
|
|
45
|
-
export declare function formatSpeedLabel(rate: number): string;
|
|
46
|
-
/**
|
|
47
|
-
* One step along the staircase. Unknown current rate snaps to 1 first (a
|
|
48
|
-
* hand-set rate off the staircase still steps from where the user expects).
|
|
49
|
-
*/
|
|
50
|
-
export declare function stepRate(current: number, direction: 1 | -1): number;
|
|
51
|
-
/** The clamp the composer applies — the range HTML media elements actually support. */
|
|
52
|
-
export declare const RATE_MIN = 0.0625;
|
|
53
|
-
export declare const RATE_MAX = 16;
|
|
54
|
-
/** Writes only on real change — a slightly-different write is audible as a wobble. */
|
|
55
|
-
export declare const RATE_DEADBAND = 0.001;
|
|
56
|
-
export interface ComposedRate {
|
|
57
|
-
rate: number;
|
|
58
|
-
/** False when the deadband swallowed the write (keep the previous rate). */
|
|
59
|
-
changed: boolean;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* The whole arbitration. `speaker` and `silence` are advisor products in
|
|
63
|
-
* [0.0625, 16] that COLLAPSE TO 1 when their feature is off or its data has
|
|
64
|
-
* not arrived — mos-5lzns.32 fills both; until then they are always 1 and
|
|
65
|
-
* this is exactly `base`.
|
|
66
|
-
*
|
|
67
|
-
* `base === 0` returns early: a frozen frame is a state, not a level.
|
|
12
|
+
* · rate/compose.ts — the contract: SPEED_STEPS staircase, formatSpeedLabel,
|
|
13
|
+
* composeRate (base 0 is a state, advisors collapse to 1, clamp), and
|
|
14
|
+
* shouldWriteRate (deadband, except an exact return to base).
|
|
15
|
+
* · rate/speaker.ts — props → advisors/speaker-rate; manual rates keyed by
|
|
16
|
+
* NAME always beat measured ones.
|
|
17
|
+
* · rate/silence.ts — waveform → advisors/smart-speed map + boost factor.
|
|
18
|
+
* · rate/ads.ts — adSpans ∪ `ad: true` turns; skip only when PLAYBACK
|
|
19
|
+
* runs into an ad, never when a seek lands in one.
|
|
20
|
+
* · rate/tick.ts — the 120ms loop's one-tick decision.
|
|
68
21
|
*/
|
|
69
|
-
export
|
|
22
|
+
export * from './rate/compose';
|
|
23
|
+
export * from './rate/speaker';
|
|
24
|
+
export * from './rate/silence';
|
|
25
|
+
export * from './rate/ads';
|
|
26
|
+
export * from './rate/tick';
|
package/dist/video/rate.js
CHANGED
|
@@ -1,88 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Rate module (mos-5lzns.32) — the rate composer and its advisors: smart
|
|
3
|
+
* speed, per-speaker pace, skip ad reads. Ported from extension-library
|
|
4
|
+
* FEATURES.md §The rate composer.
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
* composer") — this is the one non-obvious rule, stated up front because it
|
|
6
|
-
* looks like a bug from the outside:
|
|
6
|
+
* rate = base × speaker × silence (clamp [0.0625, 16], 0.001 deadband)
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* · you — the speed keys (−/=/Backspace, alt+wheel)
|
|
10
|
-
* · speaker — "this person talks fast" (mos-5lzns.32 fills)
|
|
11
|
-
* · silence — "nothing is being said here" (mos-5lzns.32 fills)
|
|
8
|
+
* `base` is the only factor a human chose and the only one the UI reports.
|
|
12
9
|
*
|
|
13
|
-
*
|
|
10
|
+
* Layout (every file pure and node-testable — `npm run test:unit`):
|
|
14
11
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* staircase) — it returns early, before any multiplication, because no
|
|
25
|
-
* advisor gets to un-pause the video by multiplying its way out of zero.
|
|
26
|
-
* 3. Only real changes are written. `playbackRate` is a live audio
|
|
27
|
-
* parameter: writing a *slightly* different value is audible as a wobble.
|
|
28
|
-
* Hence the 0.001 deadband.
|
|
29
|
-
* 4. The clamp is [0.0625, 16] — the range HTML media elements actually
|
|
30
|
-
* support. A product of three multipliers can leave it; a single one
|
|
31
|
-
* cannot.
|
|
32
|
-
*
|
|
33
|
-
* The SPEED_STEPS staircase and formatSpeedLabel are ported from the
|
|
34
|
-
* extension's theater (linear 0.1 steps below 1×, all the way down to 0 —
|
|
35
|
-
* playbackRate=0 is a genuine frozen frame; above 1× the familiar jumps).
|
|
36
|
-
*/
|
|
37
|
-
/** The speed staircase — one step per press of −/=, Backspace resets to 1. */
|
|
38
|
-
export const SPEED_STEPS = [
|
|
39
|
-
0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2, 2.5, 5, 10
|
|
40
|
-
];
|
|
41
|
-
/**
|
|
42
|
-
* "A quarter speed" reads faster as "−.75" than "0.25×" — below 1× the label
|
|
43
|
-
* is the delta, not the multiplier. The 0 step is the frozen-frame end of the
|
|
44
|
-
* staircase — a state, not a level — and the label says so ("0×"), because a
|
|
45
|
-
* frozen frame labeled "1×" lies. Garbage degrades to `1×`.
|
|
46
|
-
*/
|
|
47
|
-
export function formatSpeedLabel(rate) {
|
|
48
|
-
if (!Number.isFinite(rate) || rate < 0)
|
|
49
|
-
return '1×';
|
|
50
|
-
if (rate === 0)
|
|
51
|
-
return '0×';
|
|
52
|
-
if (rate < 1) {
|
|
53
|
-
return (rate - 1).toFixed(2).replace(/\.?0+$/, '').replace(/^-0\./, '-.') + '×';
|
|
54
|
-
}
|
|
55
|
-
return rate.toFixed(2).replace(/\.?0+$/, '') + '×';
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* One step along the staircase. Unknown current rate snaps to 1 first (a
|
|
59
|
-
* hand-set rate off the staircase still steps from where the user expects).
|
|
60
|
-
*/
|
|
61
|
-
export function stepRate(current, direction) {
|
|
62
|
-
const i = SPEED_STEPS.indexOf(current);
|
|
63
|
-
const cur = i === -1 ? SPEED_STEPS.indexOf(1) : i;
|
|
64
|
-
return SPEED_STEPS[Math.min(SPEED_STEPS.length - 1, Math.max(0, cur + direction))];
|
|
65
|
-
}
|
|
66
|
-
/** The clamp the composer applies — the range HTML media elements actually support. */
|
|
67
|
-
export const RATE_MIN = 0.0625;
|
|
68
|
-
export const RATE_MAX = 16;
|
|
69
|
-
/** Writes only on real change — a slightly-different write is audible as a wobble. */
|
|
70
|
-
export const RATE_DEADBAND = 0.001;
|
|
71
|
-
/**
|
|
72
|
-
* The whole arbitration. `speaker` and `silence` are advisor products in
|
|
73
|
-
* [0.0625, 16] that COLLAPSE TO 1 when their feature is off or its data has
|
|
74
|
-
* not arrived — mos-5lzns.32 fills both; until then they are always 1 and
|
|
75
|
-
* this is exactly `base`.
|
|
76
|
-
*
|
|
77
|
-
* `base === 0` returns early: a frozen frame is a state, not a level.
|
|
12
|
+
* · rate/compose.ts — the contract: SPEED_STEPS staircase, formatSpeedLabel,
|
|
13
|
+
* composeRate (base 0 is a state, advisors collapse to 1, clamp), and
|
|
14
|
+
* shouldWriteRate (deadband, except an exact return to base).
|
|
15
|
+
* · rate/speaker.ts — props → advisors/speaker-rate; manual rates keyed by
|
|
16
|
+
* NAME always beat measured ones.
|
|
17
|
+
* · rate/silence.ts — waveform → advisors/smart-speed map + boost factor.
|
|
18
|
+
* · rate/ads.ts — adSpans ∪ `ad: true` turns; skip only when PLAYBACK
|
|
19
|
+
* runs into an ad, never when a seek lands in one.
|
|
20
|
+
* · rate/tick.ts — the 120ms loop's one-tick decision.
|
|
78
21
|
*/
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const si = Number.isFinite(silence) && silence > 0 ? silence : 1;
|
|
85
|
-
const rate = Math.min(RATE_MAX, Math.max(RATE_MIN, base * sp * si));
|
|
86
|
-
const changed = Math.abs(rate - base) > RATE_DEADBAND;
|
|
87
|
-
return { rate: changed ? rate : base, changed };
|
|
88
|
-
}
|
|
22
|
+
export * from './rate/compose';
|
|
23
|
+
export * from './rate/speaker';
|
|
24
|
+
export * from './rate/silence';
|
|
25
|
+
export * from './rate/ads';
|
|
26
|
+
export * from './rate/tick';
|
package/dist/video/settings.js
CHANGED
|
@@ -32,8 +32,22 @@
|
|
|
32
32
|
export const VIDEO_SETTINGS = [
|
|
33
33
|
// Read by VideoPlayer's `oneAxis` prop → video/band/axis.ts resolveAxis().
|
|
34
34
|
{ id: 'player.oneAxis', type: 'bool', default: true, owner: 'mos-5lzns.30', wired: true },
|
|
35
|
-
//
|
|
36
|
-
//
|
|
35
|
+
// Read by VideoPlayer's `loudness` / `loudnessTarget` / `quietListening` /
|
|
36
|
+
// `limiter` props → video/audio/* (graph.createAudioSession, rider.*). As with
|
|
37
|
+
// night, the DEFAULT is the host's opt-in: an absent prop means nothing is
|
|
38
|
+
// ever routed through WebAudio on that player.
|
|
39
|
+
{ id: 'audio.level', type: 'bool', default: true, owner: 'mos-5lzns.31', wired: true },
|
|
40
|
+
{ id: 'audio.target', type: 'range', default: -20, min: -30, max: -12, step: 2, owner: 'mos-5lzns.31', wired: true },
|
|
41
|
+
{ id: 'audio.quiet', type: 'bool', default: true, owner: 'mos-5lzns.31', wired: true },
|
|
42
|
+
{ id: 'audio.limiter', type: 'bool', default: true, owner: 'mos-5lzns.31', wired: true },
|
|
43
|
+
// Read by VideoPlayer's `smartSpeed` / `speakerPace` (+ `speakerRates`) /
|
|
44
|
+
// `skipAds` (+ `adSpans`) props → video/rate/* (silenceMapFor + silenceFactor,
|
|
45
|
+
// speakerRateMap + speakerFactor, normalizeAdSpans + adSkipTarget), composed
|
|
46
|
+
// by rate/compose.ts composeRate. All default off: an automatic rate change
|
|
47
|
+
// is the host's opt-in.
|
|
48
|
+
{ id: 'player.smartSpeed', type: 'bool', default: false, owner: 'mos-5lzns.32', wired: true },
|
|
49
|
+
{ id: 'player.speakerRate', type: 'bool', default: false, owner: 'mos-5lzns.32', wired: true },
|
|
50
|
+
{ id: 'player.skipAds', type: 'bool', default: false, owner: 'mos-5lzns.32', wired: true },
|
|
37
51
|
// Read by VideoPlayer's `night` / `nightDepth` / `biasLight` / `predictive` /
|
|
38
52
|
// `strobeGuard` props → video/night/* (clock.nightArmed, levels.nightLevels,
|
|
39
53
|
// meter.biasCells, track.lumaAhead / inFlash / composeNight). Unlike the
|