@softure-ai/marketing-kit 0.13.2 → 0.15.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +45 -13
  3. package/dist/config/schema.d.ts +2 -0
  4. package/dist/config/schema.d.ts.map +1 -1
  5. package/dist/config/schema.js +10 -2
  6. package/dist/config/schema.js.map +1 -1
  7. package/dist/footage/compose.d.ts +13 -0
  8. package/dist/footage/compose.d.ts.map +1 -1
  9. package/dist/footage/compose.js +26 -14
  10. package/dist/footage/compose.js.map +1 -1
  11. package/dist/footage/draft.js +2 -2
  12. package/dist/footage/draft.js.map +1 -1
  13. package/dist/footage/failure.d.ts +42 -0
  14. package/dist/footage/failure.d.ts.map +1 -0
  15. package/dist/footage/failure.js +14 -0
  16. package/dist/footage/failure.js.map +1 -0
  17. package/dist/footage/film-mix.d.ts +31 -0
  18. package/dist/footage/film-mix.d.ts.map +1 -0
  19. package/dist/footage/film-mix.js +45 -0
  20. package/dist/footage/film-mix.js.map +1 -0
  21. package/dist/footage/isolate-ranges.d.ts +47 -4
  22. package/dist/footage/isolate-ranges.d.ts.map +1 -1
  23. package/dist/footage/isolate-ranges.js +64 -14
  24. package/dist/footage/isolate-ranges.js.map +1 -1
  25. package/dist/footage/loudness.d.ts +91 -27
  26. package/dist/footage/loudness.d.ts.map +1 -1
  27. package/dist/footage/loudness.js +143 -69
  28. package/dist/footage/loudness.js.map +1 -1
  29. package/dist/footage/paid.d.ts +3 -0
  30. package/dist/footage/paid.d.ts.map +1 -1
  31. package/dist/footage/paid.js +2 -1
  32. package/dist/footage/paid.js.map +1 -1
  33. package/dist/footage/pipeline.d.ts +40 -12
  34. package/dist/footage/pipeline.d.ts.map +1 -1
  35. package/dist/footage/pipeline.js +137 -80
  36. package/dist/footage/pipeline.js.map +1 -1
  37. package/dist/footage/publish.js +4 -4
  38. package/dist/footage/publish.js.map +1 -1
  39. package/dist/footage/speech-ranges.d.ts +29 -4
  40. package/dist/footage/speech-ranges.d.ts.map +1 -1
  41. package/dist/footage/speech-ranges.js +56 -11
  42. package/dist/footage/speech-ranges.js.map +1 -1
  43. package/dist/index.d.ts +7 -5
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +6 -4
  46. package/dist/index.js.map +1 -1
  47. package/package.json +1 -1
  48. package/schema/marketing.schema.json +13 -1
  49. package/src/config/schema.ts +14 -2
  50. package/src/footage/compose.ts +33 -12
  51. package/src/footage/draft.ts +2 -2
  52. package/src/footage/failure.ts +44 -0
  53. package/src/footage/film-mix.ts +65 -0
  54. package/src/footage/isolate-ranges.ts +110 -14
  55. package/src/footage/loudness.ts +166 -68
  56. package/src/footage/paid.ts +5 -2
  57. package/src/footage/pipeline.ts +173 -90
  58. package/src/footage/publish.ts +4 -4
  59. package/src/footage/speech-ranges.ts +68 -11
  60. package/src/index.ts +43 -8
@@ -20,8 +20,11 @@ export interface LoudnessMeasurement {
20
20
  inputThresh: number;
21
21
  targetOffset: number;
22
22
  }
23
- /** The first pass: decodes the sound only (a film's picture is skipped), prints the measurement on stderr, writes nothing. */
24
- export declare function buildLoudnessMeasureArgs(input: string, target: LoudnessTarget): string[];
23
+ /**
24
+ * The first pass: decodes the sound only (a film's picture is skipped), prints the measurement on stderr, writes
25
+ * nothing. With `filter`, what is measured is the sound through it (the mix stage's uncompressed probes).
26
+ */
27
+ export declare function buildLoudnessMeasureArgs(input: string, target: LoudnessTarget, filter?: string): string[];
25
28
  /** The measurement from the first pass's stderr (its last JSON block); null when there is none or it is incomplete. */
26
29
  export declare function readLoudnessMeasurement(stderr: string): LoudnessMeasurement | null;
27
30
  /** True when the measured track is silence, which no gain can bring to the target. */
@@ -42,12 +45,13 @@ export type LoudnessMeasureOutcome = {
42
45
  kind: "silent";
43
46
  };
44
47
  /**
45
- * The first pass over `input`: its measurement, or silent when no gain can bring it to the target. Throws naming
48
+ * The first pass over `input` (through `filter` when given): its measurement, or silent when no gain can bring it to the target. Throws naming
46
49
  * `label` (what is measured) when ffmpeg fails, rejects with the signal's reason on abort.
47
50
  */
48
51
  export declare function measureLoudness(input: string, target: LoudnessTarget, options: {
49
52
  label: string;
50
53
  signal?: AbortSignal;
54
+ filter?: string;
51
55
  }): Promise<LoudnessMeasureOutcome>;
52
56
  export type LoudnessOutcome = {
53
57
  kind: "normalized";
@@ -81,60 +85,120 @@ export interface MixLoudnessTarget extends LoudnessTarget {
81
85
  tolerance?: number;
82
86
  /** What the mix's gain keeps: the mix at the target (absent, `"loudness"`) or the speech's level (`"speech"`). */
83
87
  keep?: "loudness" | "speech";
88
+ /** How many times the mix is encoded and measured before the film fails. Absent: `MIX_ATTEMPTS`. */
89
+ attempts?: number;
90
+ /**
91
+ * A near-miss band in LU, at least `tolerance`: a finished mix outside `target ± tolerance` but inside
92
+ * `target ± warnTolerance`, under the true peak limit, finishes with a warning instead of failing. Absent: none.
93
+ */
94
+ warnTolerance?: number;
84
95
  }
85
- /** The limiter's first ceiling sits this far under the true peak limit: AAC adds inter-sample overshoot after it. */
96
+ /** The limiter's ceiling sits this far under the true peak limit: AAC adds inter-sample overshoot after it. */
86
97
  export declare const MIX_ENCODE_HEADROOM = 1;
87
- /** How many times the mix is encoded and measured before the film fails. */
98
+ /** How many times the mix is encoded and measured before the film fails, unless `MixLoudnessTarget.attempts` says. */
88
99
  export declare const MIX_ATTEMPTS = 4;
89
- /** With `keep: "speech"`, a retry aims this far inside the window's edge (at most half the tolerance), in LU. */
90
- export declare const MIX_RETRY_EDGE_MARGIN = 0.3;
91
- /** The limiter's loudness cost per dB of drive (gain minus ceiling) until the tries measure it, in LU per dB. */
92
- export declare const MIX_LIMITER_SLOPE = 0.5;
93
- /** The steepest limiter cost a retry believes: near 1 a gain step would barely move the mix and the gain would run away. */
94
- export declare const MIX_LIMITER_SLOPE_MAX = 0.7;
100
+ /** With `keep: "speech"`, a mix that misses the window is aimed this far inside its edge (at most half the tolerance), in LU. */
101
+ export declare const MIX_AIM_EDGE_MARGIN = 0.45;
102
+ /** How close to its aim a probe must land, in LU: the plain target's window, and how far inside the edge keep speech aims. */
103
+ export declare const MIX_GAIN_PRECISION = 0.15;
104
+ /** How many uncompressed passes one solve of the gain may take. */
105
+ export declare const MIX_GAIN_PROBES = 6;
106
+ /**
107
+ * The mix is low-passed here after the limiter, and the AAC encoder cuts here too: the limiter's fast gain moves leave
108
+ * high frequencies on every transient that AAC turns into inter-sample overshoot (up to 3.4 dB on clicky speech,
109
+ * issue #1124); without them it stays within about 1 dB.
110
+ */
111
+ export declare const MIX_LOWPASS_HZ = 16000;
95
112
  /** One try at the mix's last stage: a linear gain, then a true peak limiter at the ceiling. */
96
113
  export interface MixAttempt {
97
114
  gainDb: number;
98
115
  ceilingDbtp: number;
99
116
  }
100
- /** One encode of the mix: the attempt and what the encoded file measured. */
117
+ /** One measurement of the mix through an attempt: uncompressed (a probe of the gain) or encoded (a try). */
101
118
  export interface MixTry {
102
119
  attempt: MixAttempt;
103
120
  measured: MixLoudness;
104
121
  }
105
122
  /** The window's half width around the mix target, in LU. */
106
123
  export declare function getMixTolerance(target: MixLoudnessTarget): number;
124
+ /** How many encodes the mix stage may take. */
125
+ export declare function getMixAttempts(target: MixLoudnessTarget): number;
107
126
  /**
108
- * The gain a mix measuring `integrated` LUFS needs: to the target in the default mode; with `keep: "speech"` none
109
- * inside `target ± tolerance`, else to the nearest edge (aimed a little inside, see `MIX_EDGE_MARGIN`).
127
+ * The gain a mix measuring `integrated` LUFS needs before any limiter: to the target in the default mode; with
128
+ * `keep: "speech"` none inside `target ± tolerance`, else to the nearest edge (aimed a little inside, see
129
+ * `MIX_EDGE_MARGIN`). The first probe of the gain starts here.
110
130
  */
111
131
  export declare function getMixGain(integrated: number, target: MixLoudnessTarget): number;
112
- /** The first try: the gain the measured mix needs (`getMixGain`), the ceiling one encode's headroom under the limit. */
113
- export declare function getFirstMixAttempt(measurement: Pick<LoudnessMeasurement, "inputI">, target: MixLoudnessTarget): MixAttempt;
132
+ /** The first ceiling: one encode's headroom under the true peak limit, never under the limiter's floor. */
133
+ export declare function getFirstMixCeiling(target: MixLoudnessTarget): number;
114
134
  /**
115
- * How much loudness the limiter takes per dB it is driven harder, fitted (least squares) from the tries once their
116
- * drives spread, else `MIX_LIMITER_SLOPE`; clamped to 0..`MIX_LIMITER_SLOPE_MAX`. `inputI` is the render's mix as measured.
135
+ * The ceiling for the next encode: lowered by the encode's true peak excess plus a margin when it broke the limit,
136
+ * else kept. The excess is the codec's (the gain does not move it), so the ceiling never moves with the loudness.
117
137
  */
118
- export declare function getLimiterSlope(tries: readonly MixTry[], inputI: number): number;
138
+ export declare function getNextMixCeiling(ceilingDbtp: number, measured: MixLoudness, target: MixLoudnessTarget): number;
139
+ /** Where a probe of the gain should land a mix that measures `integrated` LUFS, and whether it already does. */
140
+ export interface MixAim {
141
+ aim: number;
142
+ isMet: boolean;
143
+ }
144
+ /**
145
+ * The gain's aim for a mix at `integrated` LUFS: in the default mode the target (met within `MIX_GAIN_PRECISION`);
146
+ * with `keep: "speech"` met (no gain moves it) inside the window shrunk by `MIX_MET_MARGIN`, else
147
+ * `MIX_AIM_EDGE_MARGIN` inside the edge it misses.
148
+ */
149
+ export declare function getMixAim(integrated: number, target: MixLoudnessTarget): MixAim;
119
150
  /**
120
- * The next try after the encodes in `tries` (oldest first; the last one missed `target`). The ceiling is lowered by
121
- * the last overshoot plus a margin when its true peak is over (never under the limiter's floor). The gain comes from
122
- * a model of the limiter: the loudness it takes grows with how hard it is driven (gain minus ceiling) at the slope
123
- * `getLimiterSlope` measures, so the gain is solved for the loudness the mix will have at the new ceiling, not the
124
- * one it had at the old one. `inputI` is the render's mix as measured before any try.
151
+ * The next gain to probe at a fixed ceiling, from the probes so far (oldest first) and `shift` (what the encode adds
152
+ * to a probe's loudness, 0 before the first encode): a secant step through the last two probes, or a step by the
153
+ * miss when there is one probe or the slope is flat or falling (the limiter takes back what the gain adds, so the
154
+ * loudness is not monotone in the gain on clicky speech). Null when the last probe meets its aim, or the step would
155
+ * repeat a gain already probed.
125
156
  */
126
- export declare function getNextMixAttempt(tries: readonly MixTry[], inputI: number, target: MixLoudnessTarget): MixAttempt;
157
+ export declare function getNextGainProbe(probes: readonly MixTry[], target: MixLoudnessTarget, shift?: number): number | null;
158
+ /** The probe closest to its aim: the one the encode uses. */
159
+ export declare function getBestGainProbe(probes: readonly MixTry[], target: MixLoudnessTarget, shift?: number): MixTry;
160
+ /**
161
+ * The gain at `ceilingDbtp` found by measuring the uncompressed chain (`measure`, one decode of the sound, no encode)
162
+ * from `startGainDb`, at most `MIX_GAIN_PROBES` times: the best probe, with every probe it took.
163
+ */
164
+ export declare function solveMixGain(options: {
165
+ ceilingDbtp: number;
166
+ startGainDb: number;
167
+ target: MixLoudnessTarget;
168
+ shift: number;
169
+ measure: (attempt: MixAttempt) => Promise<MixLoudness>;
170
+ }): Promise<{
171
+ best: MixTry;
172
+ probes: MixTry[];
173
+ }>;
127
174
  /**
128
175
  * The mix's last stage: one linear gain, then a lookahead limiter at 4x the film's rate (its delay compensated, so
129
- * the sound stays in sync with the picture; no auto level), back to the film's rate.
176
+ * the sound stays in sync with the picture; no auto level), back to the film's rate, then a low-pass at
177
+ * `MIX_LOWPASS_HZ` that keeps AAC's overshoot small.
130
178
  */
131
179
  export declare function getMixFilter(attempt: MixAttempt): string;
132
- /** The mix's sound on its own through `filter`, encoded as the finished film carries it (AAC 192k, 48 kHz, stereo). */
180
+ /** The mix's sound on its own through `filter`, encoded as the finished film carries it (AAC 192k cut at `MIX_LOWPASS_HZ`, 48 kHz, stereo). */
133
181
  export declare function buildMixArgs(options: {
134
182
  input: string;
135
183
  filter: string;
136
184
  output: string;
137
185
  }): string[];
186
+ /** How a measured mix stands against its target: inside it, a near miss inside `warnTolerance`, or outside. */
187
+ export type LoudnessVerdict = {
188
+ kind: "pass";
189
+ } | {
190
+ kind: "warn";
191
+ warning: string;
192
+ } | {
193
+ kind: "fail";
194
+ problems: string[];
195
+ };
196
+ /**
197
+ * The verdict on a measured mix: `pass` inside `target ± tolerance` and at most `truePeak`; `warn` (a sentence with
198
+ * both values) when only the integrated loudness misses, by at most `warnTolerance`; else `fail` with the problems.
199
+ * The true peak limit has no near-miss band.
200
+ */
201
+ export declare function getLoudnessVerdict(measured: MixLoudness, target: MixLoudnessTarget): LoudnessVerdict;
138
202
  /** What keeps a measured mix outside the target, as sentences with both values; empty when it meets it. */
139
203
  export declare function findLoudnessProblems(measured: MixLoudness, target: MixLoudnessTarget): string[];
140
204
  /** A level with one decimal and its sign (`+0.1`, `-14.0`). */
@@ -1 +1 @@
1
- {"version":3,"file":"loudness.d.ts","sourceRoot":"","sources":["../../src/footage/loudness.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,EAAE,cAA8C,CAAC;AAQ9E,sFAAsF;AACtF,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAcD,8HAA8H;AAC9H,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CAExF;AAED,uHAAuH;AACvH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CA8BlF;AAED,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAElE;AAED,sIAAsI;AACtI,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAWlG;AA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,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE1H;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,GAAG,eAAe,CAWpG;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAQ/F;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG9C"}
@@ -19,9 +19,13 @@ const measurementSchema = z.looseObject({
19
19
  function getLoudnormFilter(target) {
20
20
  return `loudnorm=I=${target.target}:TP=${target.truePeak}:LRA=${LOUDNESS_RANGE}`;
21
21
  }
22
- /** The first pass: decodes the sound only (a film's picture is skipped), prints the measurement on stderr, writes nothing. */
23
- export function buildLoudnessMeasureArgs(input, target) {
24
- return ["-hide_banner", "-nostats", "-i", input, "-vn", "-af", `${getLoudnormFilter(target)}:print_format=json`, "-f", "null", "-"];
22
+ /**
23
+ * The first pass: decodes the sound only (a film's picture is skipped), prints the measurement on stderr, writes
24
+ * nothing. With `filter`, what is measured is the sound through it (the mix stage's uncompressed probes).
25
+ */
26
+ export function buildLoudnessMeasureArgs(input, target, filter) {
27
+ const measure = `${getLoudnormFilter(target)}:print_format=json`;
28
+ return ["-hide_banner", "-nostats", "-i", input, "-vn", "-af", filter === undefined ? measure : `${filter},${measure}`, "-f", "null", "-"];
25
29
  }
26
30
  /** The measurement from the first pass's stderr (its last JSON block); null when there is none or it is incomplete. */
27
31
  export function readLoudnessMeasurement(stderr) {
@@ -96,12 +100,12 @@ export function buildLoudnessArgs(options) {
96
100
  ];
97
101
  }
98
102
  /**
99
- * The first pass over `input`: its measurement, or silent when no gain can bring it to the target. Throws naming
103
+ * The first pass over `input` (through `filter` when given): its measurement, or silent when no gain can bring it to the target. Throws naming
100
104
  * `label` (what is measured) when ffmpeg fails, rejects with the signal's reason on abort.
101
105
  */
102
106
  export async function measureLoudness(input, target, options) {
103
107
  const step = `Measuring ${options.label}'s loudness`;
104
- const measured = await runProcess({ command: "ffmpeg", args: buildLoudnessMeasureArgs(input, target), ...(options.signal === undefined ? {} : { signal: options.signal }) });
108
+ const measured = await runProcess({ command: "ffmpeg", args: buildLoudnessMeasureArgs(input, target, options.filter), ...(options.signal === undefined ? {} : { signal: options.signal }) });
105
109
  if (measured.kind === "not-started")
106
110
  throw new Error(`${step}: ffmpeg did not start (${measured.error}).`);
107
111
  if (measured.code !== 0)
@@ -134,20 +138,30 @@ export async function normalizeLoudness(input, output, target, options = {}) {
134
138
  export const MIX_LOUDNESS_TOLERANCE = 1;
135
139
  /** A gain to the window's edge aims this far inside it (at most half the tolerance), so the encode's drift stays in. */
136
140
  const MIX_EDGE_MARGIN = 0.2;
137
- /** The limiter's first ceiling sits this far under the true peak limit: AAC adds inter-sample overshoot after it. */
141
+ /** The limiter's ceiling sits this far under the true peak limit: AAC adds inter-sample overshoot after it. */
138
142
  export const MIX_ENCODE_HEADROOM = 1;
139
- /** How many times the mix is encoded and measured before the film fails. */
143
+ /** How many times the mix is encoded and measured before the film fails, unless `MixLoudnessTarget.attempts` says. */
140
144
  export const MIX_ATTEMPTS = 4;
141
- /** What a retry lowers the ceiling by on top of the measured overshoot, in dB. */
145
+ /** What a retry lowers the ceiling by on top of the measured true peak excess, in dB. */
142
146
  const MIX_RETRY_MARGIN = 0.3;
143
- /** With `keep: "speech"`, a retry aims this far inside the window's edge (at most half the tolerance), in LU. */
144
- export const MIX_RETRY_EDGE_MARGIN = 0.3;
145
- /** The limiter's loudness cost per dB of drive (gain minus ceiling) until the tries measure it, in LU per dB. */
146
- export const MIX_LIMITER_SLOPE = 0.5;
147
- /** The steepest limiter cost a retry believes: near 1 a gain step would barely move the mix and the gain would run away. */
148
- export const MIX_LIMITER_SLOPE_MAX = 0.7;
149
- /** How far apart the tries' drives must spread (their variance, in dB²) before the slope is fitted from them. */
150
- const MIX_SLOPE_SPREAD = 0.09;
147
+ /** With `keep: "speech"`, a probe inside the window shrunk by this much needs no gain (the encode moves a mix about this much), in LU. */
148
+ const MIX_MET_MARGIN = 0.1;
149
+ /** With `keep: "speech"`, a mix that misses the window is aimed this far inside its edge (at most half the tolerance), in LU. */
150
+ export const MIX_AIM_EDGE_MARGIN = 0.45;
151
+ /** How close to its aim a probe must land, in LU: the plain target's window, and how far inside the edge keep speech aims. */
152
+ export const MIX_GAIN_PRECISION = 0.15;
153
+ /** How many uncompressed passes one solve of the gain may take. */
154
+ export const MIX_GAIN_PROBES = 6;
155
+ /** The largest gain a probe tries, either way, in dB. */
156
+ const MIX_GAIN_LIMIT = 30;
157
+ /** Below this loudness change per dB of gain the slope is not trusted (the limiter takes it back): a probe steps by its miss. */
158
+ const MIX_MIN_SLOPE = 0.2;
159
+ /**
160
+ * The mix is low-passed here after the limiter, and the AAC encoder cuts here too: the limiter's fast gain moves leave
161
+ * high frequencies on every transient that AAC turns into inter-sample overshoot (up to 3.4 dB on clicky speech,
162
+ * issue #1124); without them it stays within about 1 dB.
163
+ */
164
+ export const MIX_LOWPASS_HZ = 16000;
151
165
  /** `alimiter`'s lowest ceiling (its `limit` of 0.0625), in dB. */
152
166
  const LIMITER_FLOOR = -24;
153
167
  /** The limiter runs at 4x the film's rate, so it holds the true peak rather than the sample peak. */
@@ -160,9 +174,14 @@ function roundTo(value, digits) {
160
174
  export function getMixTolerance(target) {
161
175
  return target.tolerance ?? MIX_LOUDNESS_TOLERANCE;
162
176
  }
177
+ /** How many encodes the mix stage may take. */
178
+ export function getMixAttempts(target) {
179
+ return target.attempts ?? MIX_ATTEMPTS;
180
+ }
163
181
  /**
164
- * The gain a mix measuring `integrated` LUFS needs: to the target in the default mode; with `keep: "speech"` none
165
- * inside `target ± tolerance`, else to the nearest edge (aimed a little inside, see `MIX_EDGE_MARGIN`).
182
+ * The gain a mix measuring `integrated` LUFS needs before any limiter: to the target in the default mode; with
183
+ * `keep: "speech"` none inside `target ± tolerance`, else to the nearest edge (aimed a little inside, see
184
+ * `MIX_EDGE_MARGIN`). The first probe of the gain starts here.
166
185
  */
167
186
  export function getMixGain(integrated, target) {
168
187
  if (target.keep !== "speech")
@@ -175,77 +194,132 @@ export function getMixGain(integrated, target) {
175
194
  return roundTo(target.target + inside - integrated, 2);
176
195
  return 0;
177
196
  }
178
- /** The first try: the gain the measured mix needs (`getMixGain`), the ceiling one encode's headroom under the limit. */
179
- export function getFirstMixAttempt(measurement, target) {
180
- return { gainDb: getMixGain(measurement.inputI, target), ceilingDbtp: Math.max(LIMITER_FLOOR, roundTo(target.truePeak - MIX_ENCODE_HEADROOM, 2)) };
181
- }
182
- /** One try as the limiter model sees it: how hard the limiter was driven (gain minus ceiling) and the loudness it took. */
183
- function getLimiterPoint(entry, inputI) {
184
- return { drive: entry.attempt.gainDb - entry.attempt.ceilingDbtp, cost: inputI + entry.attempt.gainDb - entry.measured.integrated };
197
+ /** The first ceiling: one encode's headroom under the true peak limit, never under the limiter's floor. */
198
+ export function getFirstMixCeiling(target) {
199
+ return Math.max(LIMITER_FLOOR, roundTo(target.truePeak - MIX_ENCODE_HEADROOM, 2));
185
200
  }
186
201
  /**
187
- * How much loudness the limiter takes per dB it is driven harder, fitted (least squares) from the tries once their
188
- * drives spread, else `MIX_LIMITER_SLOPE`; clamped to 0..`MIX_LIMITER_SLOPE_MAX`. `inputI` is the render's mix as measured.
202
+ * The ceiling for the next encode: lowered by the encode's true peak excess plus a margin when it broke the limit,
203
+ * else kept. The excess is the codec's (the gain does not move it), so the ceiling never moves with the loudness.
189
204
  */
190
- export function getLimiterSlope(tries, inputI) {
191
- const points = tries.map((entry) => getLimiterPoint(entry, inputI));
192
- const meanDrive = points.reduce((sum, point) => sum + point.drive, 0) / Math.max(1, points.length);
193
- const meanCost = points.reduce((sum, point) => sum + point.cost, 0) / Math.max(1, points.length);
194
- const spread = points.reduce((sum, point) => sum + (point.drive - meanDrive) ** 2, 0);
195
- const slope = points.length >= 2 && spread >= MIX_SLOPE_SPREAD ? points.reduce((sum, point) => sum + (point.drive - meanDrive) * (point.cost - meanCost), 0) / spread : MIX_LIMITER_SLOPE;
196
- return roundTo(Math.min(MIX_LIMITER_SLOPE_MAX, Math.max(0, slope)), 3);
205
+ export function getNextMixCeiling(ceilingDbtp, measured, target) {
206
+ const excess = measured.truePeak - target.truePeak;
207
+ return excess > 0 ? Math.max(LIMITER_FLOOR, roundTo(ceilingDbtp - excess - MIX_RETRY_MARGIN, 2)) : ceilingDbtp;
197
208
  }
198
209
  /**
199
- * Where a retry aims the mix's integrated loudness when it would land at `predicted` LUFS with the gain kept: the
200
- * target in the default mode; with `keep: "speech"` nowhere (the gain stays) while `predicted` is inside the window
201
- * shrunk by `MIX_RETRY_EDGE_MARGIN`, else that margin inside the edge it would miss.
210
+ * The gain's aim for a mix at `integrated` LUFS: in the default mode the target (met within `MIX_GAIN_PRECISION`);
211
+ * with `keep: "speech"` met (no gain moves it) inside the window shrunk by `MIX_MET_MARGIN`, else
212
+ * `MIX_AIM_EDGE_MARGIN` inside the edge it misses.
202
213
  */
203
- function getRetryAim(predicted, target) {
214
+ export function getMixAim(integrated, target) {
204
215
  if (target.keep !== "speech")
205
- return target.target;
216
+ return { aim: target.target, isMet: Math.abs(integrated - target.target) <= MIX_GAIN_PRECISION };
206
217
  const tolerance = getMixTolerance(target);
207
- const inside = tolerance - Math.min(MIX_RETRY_EDGE_MARGIN, tolerance / 2);
208
- if (predicted < target.target - inside)
209
- return target.target - inside;
210
- if (predicted > target.target + inside)
211
- return target.target + inside;
212
- return null;
218
+ const met = tolerance - Math.min(MIX_MET_MARGIN, tolerance / 2);
219
+ const aim = tolerance - Math.min(MIX_AIM_EDGE_MARGIN, tolerance / 2);
220
+ if (integrated < target.target - met)
221
+ return { aim: roundTo(target.target - aim, 2), isMet: false };
222
+ if (integrated > target.target + met)
223
+ return { aim: roundTo(target.target + aim, 2), isMet: false };
224
+ return { aim: integrated, isMet: true };
213
225
  }
214
226
  /**
215
- * The next try after the encodes in `tries` (oldest first; the last one missed `target`). The ceiling is lowered by
216
- * the last overshoot plus a margin when its true peak is over (never under the limiter's floor). The gain comes from
217
- * a model of the limiter: the loudness it takes grows with how hard it is driven (gain minus ceiling) at the slope
218
- * `getLimiterSlope` measures, so the gain is solved for the loudness the mix will have at the new ceiling, not the
219
- * one it had at the old one. `inputI` is the render's mix as measured before any try.
227
+ * The next gain to probe at a fixed ceiling, from the probes so far (oldest first) and `shift` (what the encode adds
228
+ * to a probe's loudness, 0 before the first encode): a secant step through the last two probes, or a step by the
229
+ * miss when there is one probe or the slope is flat or falling (the limiter takes back what the gain adds, so the
230
+ * loudness is not monotone in the gain on clicky speech). Null when the last probe meets its aim, or the step would
231
+ * repeat a gain already probed.
220
232
  */
221
- export function getNextMixAttempt(tries, inputI, target) {
222
- const last = tries.at(-1);
233
+ export function getNextGainProbe(probes, target, shift = 0) {
234
+ const last = probes.at(-1);
223
235
  if (last === undefined)
224
- throw new Error("getNextMixAttempt: no encode of the mix to correct.");
225
- const overshoot = last.measured.truePeak - target.truePeak;
226
- const ceilingDbtp = overshoot > 0 ? Math.max(LIMITER_FLOOR, roundTo(last.attempt.ceilingDbtp - overshoot - MIX_RETRY_MARGIN, 2)) : last.attempt.ceilingDbtp;
227
- const slope = getLimiterSlope(tries, inputI);
228
- const { drive, cost } = getLimiterPoint(last, inputI);
229
- // The limiter's cost at a gain, at the new ceiling: never below none.
230
- const getCost = (gainDb) => Math.max(0, cost + slope * (gainDb - ceilingDbtp - drive));
231
- const aim = getRetryAim(inputI + last.attempt.gainDb - getCost(last.attempt.gainDb), target);
232
- if (aim === null)
233
- return { gainDb: last.attempt.gainDb, ceilingDbtp };
234
- const gainDb = (aim - inputI + cost - slope * (ceilingDbtp + drive)) / (1 - slope);
235
- // A gain so low that the limiter would take nothing: the mix moves by the gain alone.
236
- return { gainDb: roundTo(getCost(gainDb) > 0 ? gainDb : aim - inputI, 2), ceilingDbtp };
236
+ throw new Error("getNextGainProbe: no probe of the mix to correct.");
237
+ const { aim, isMet } = getMixAim(last.measured.integrated + shift, target);
238
+ if (isMet)
239
+ return null;
240
+ const miss = aim - shift - last.measured.integrated;
241
+ const before = probes.at(-2);
242
+ const slope = before === undefined || before.attempt.gainDb === last.attempt.gainDb ? 0 : (last.measured.integrated - before.measured.integrated) / (last.attempt.gainDb - before.attempt.gainDb);
243
+ const step = slope > MIX_MIN_SLOPE ? miss / slope : miss;
244
+ const gainDb = roundTo(Math.min(MIX_GAIN_LIMIT, Math.max(-MIX_GAIN_LIMIT, last.attempt.gainDb + step)), 2);
245
+ return probes.some((probe) => probe.attempt.gainDb === gainDb) ? null : gainDb;
246
+ }
247
+ /** The probe closest to its aim: the one the encode uses. */
248
+ export function getBestGainProbe(probes, target, shift = 0) {
249
+ const score = (probe) => {
250
+ const { aim, isMet } = getMixAim(probe.measured.integrated + shift, target);
251
+ return isMet ? 0 : Math.abs(aim - shift - probe.measured.integrated);
252
+ };
253
+ const first = probes[0];
254
+ if (first === undefined)
255
+ throw new Error("getBestGainProbe: no probe of the mix.");
256
+ return probes.reduce((best, probe) => (score(probe) < score(best) ? probe : best), first);
257
+ }
258
+ /**
259
+ * The gain at `ceilingDbtp` found by measuring the uncompressed chain (`measure`, one decode of the sound, no encode)
260
+ * from `startGainDb`, at most `MIX_GAIN_PROBES` times: the best probe, with every probe it took.
261
+ */
262
+ export async function solveMixGain(options) {
263
+ const probes = [];
264
+ let gainDb = options.startGainDb;
265
+ while (gainDb !== null && probes.length < MIX_GAIN_PROBES) {
266
+ const attempt = { gainDb, ceilingDbtp: options.ceilingDbtp };
267
+ probes.push({ attempt, measured: await options.measure(attempt) });
268
+ gainDb = getNextGainProbe(probes, options.target, options.shift);
269
+ }
270
+ return { best: getBestGainProbe(probes, options.target, options.shift), probes };
237
271
  }
238
272
  /**
239
273
  * The mix's last stage: one linear gain, then a lookahead limiter at 4x the film's rate (its delay compensated, so
240
- * the sound stays in sync with the picture; no auto level), back to the film's rate.
274
+ * the sound stays in sync with the picture; no auto level), back to the film's rate, then a low-pass at
275
+ * `MIX_LOWPASS_HZ` that keeps AAC's overshoot small.
241
276
  */
242
277
  export function getMixFilter(attempt) {
243
278
  const limit = roundTo(10 ** (attempt.ceilingDbtp / 20), 5);
244
- return [`volume=${attempt.gainDb}dB`, `aresample=${LIMITER_RATE}`, `alimiter=limit=${limit}:level=false:latency=true`, `aresample=${FOOTAGE_SAMPLE_RATE}`].join(",");
279
+ return [`volume=${attempt.gainDb}dB`, `aresample=${LIMITER_RATE}`, `alimiter=limit=${limit}:level=false:latency=true`, `aresample=${FOOTAGE_SAMPLE_RATE}`, `lowpass=f=${MIX_LOWPASS_HZ}`].join(",");
245
280
  }
246
- /** The mix's sound on its own through `filter`, encoded as the finished film carries it (AAC 192k, 48 kHz, stereo). */
281
+ /** The mix's sound on its own through `filter`, encoded as the finished film carries it (AAC 192k cut at `MIX_LOWPASS_HZ`, 48 kHz, stereo). */
247
282
  export function buildMixArgs(options) {
248
- return ["-v", "error", "-y", "-i", options.input, "-vn", "-map", "0:a:0", "-af", options.filter, "-c:a", "aac", "-b:a", FINISHED_AUDIO_BITRATE, "-ar", String(FOOTAGE_SAMPLE_RATE), "-ac", "2", options.output];
283
+ return [
284
+ "-v",
285
+ "error",
286
+ "-y",
287
+ "-i",
288
+ options.input,
289
+ "-vn",
290
+ "-map",
291
+ "0:a:0",
292
+ "-af",
293
+ options.filter,
294
+ "-c:a",
295
+ "aac",
296
+ "-b:a",
297
+ FINISHED_AUDIO_BITRATE,
298
+ "-cutoff",
299
+ String(MIX_LOWPASS_HZ),
300
+ "-ar",
301
+ String(FOOTAGE_SAMPLE_RATE),
302
+ "-ac",
303
+ "2",
304
+ options.output,
305
+ ];
306
+ }
307
+ /**
308
+ * The verdict on a measured mix: `pass` inside `target ± tolerance` and at most `truePeak`; `warn` (a sentence with
309
+ * both values) when only the integrated loudness misses, by at most `warnTolerance`; else `fail` with the problems.
310
+ * The true peak limit has no near-miss band.
311
+ */
312
+ export function getLoudnessVerdict(measured, target) {
313
+ const problems = findLoudnessProblems(measured, target);
314
+ if (problems.length === 0)
315
+ return { kind: "pass" };
316
+ const band = target.warnTolerance;
317
+ if (band !== undefined && measured.truePeak <= target.truePeak && Math.abs(measured.integrated - target.target) <= band) {
318
+ const warning = `the mix measures ${formatDb(measured.integrated)} LUFS integrated, ${formatDb(measured.truePeak)} dBTP true peak: ` +
319
+ `outside ${formatDb(target.target)} ± ${getMixTolerance(target)} LUFS, inside the ± ${band} LU near-miss band.`;
320
+ return { kind: "warn", warning };
321
+ }
322
+ return { kind: "fail", problems };
249
323
  }
250
324
  /** What keeps a measured mix outside the target, as sentences with both values; empty when it meets it. */
251
325
  export function findLoudnessProblems(measured, target) {
@@ -1 +1 @@
1
- {"version":3,"file":"loudness.js","sourceRoot":"","sources":["../../src/footage/loudness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAgBtD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAmB,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;AAE9E,+GAA+G;AAC/G,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,sEAAsE;AACtE,MAAM,YAAY,GAAG,CAAC,EAAE,CAAC;AAWzB,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM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AE,OAAO,EAAE,CAAC;IACnC,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,oBAAoB,CAAC,QAAqB,EAAE,MAAyB;IACnF,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ;QAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC1J,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;QAC9D,QAAQ,CAAC,IAAI,CAAC,cAAc,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,SAAS,OAAO,CAAC,CAAC;IAC5H,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,KAAK,GAAG,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACnF,CAAC"}
@@ -2,6 +2,7 @@ import { type TtsResult } from "../voice/provider.js";
2
2
  import { type Edl } from "./edl.js";
3
3
  import type { FootageClip, FootageFilm } from "./film.js";
4
4
  import type { FootageProviders, FootageRates, PaidStepKind } from "./providers.js";
5
+ import { type SpeechRangeCacheResolver } from "./speech-ranges.js";
5
6
  /**
6
7
  * Where each paid result of a footage film is cached, shared by the pipeline and by the questions an app asks before
7
8
  * a run: is this step cached (`findCachedStep`), and what will the film cost (`estimateFootageFilm`). Neither question
@@ -72,6 +73,8 @@ export interface EstimateFootageOptions extends FootageCacheOptions {
72
73
  isolate?: "clips" | "segments";
73
74
  /** Seconds around each sound span with `isolate: "segments"`; default `DEFAULT_SPEECH_RANGE_MARGIN`. */
74
75
  margin?: number;
76
+ /** Where a range's cleaned voice is cached with `isolate: "segments"`, as `isolateSpeechRanges` takes it; default `getSpeechRangeCache`. */
77
+ rangeCache?: SpeechRangeCacheResolver;
75
78
  }
76
79
  /**
77
80
  * What a footage film will cost in the caller's credits, before anything runs: every clip probed (a URL clip not yet
@@ -1 +1 @@
1
- {"version":3,"file":"paid.d.ts","sourceRoot":"","sources":["../../src/footage/paid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnF;;;;GAIG;AAEH,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oHAAoH;IACpH,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,KAAG,OAAuC,CA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QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,wGAAwG;IACxG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4IAA4I;IAC5I,UAAU,CAAC,EAAE,wBAAwB,CAAC;CACvC;AAOD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAsDjI;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAKnJ"}
@@ -184,7 +184,8 @@ export async function estimateFootageFilm(film, options) {
184
184
  const provider = options.providers.isolation.id;
185
185
  for (const range of planSpeechRanges(edl, rangeClips, options.margin === undefined ? {} : { margin: options.margin })) {
186
186
  const clipKey = clipKeys[range.clip] ?? null;
187
- const cached = clipKey !== null && existsSync(getSpeechRangeCache(film.id, clipKey, range, { cacheDir: options.cacheDir, provider }).path);
187
+ const cache = clipKey === null ? null : (options.rangeCache?.(range, clipKey) ?? getSpeechRangeCache(film.id, clipKey, range, { cacheDir: options.cacheDir, provider }));
188
+ const cached = cache !== null && existsSync(cache.path);
188
189
  add("isolate", range.clip, provider, (range.endMs - range.startMs) / 1000, cached);
189
190
  const item = items.at(-1);
190
191
  if (item !== undefined)