@nodetool-ai/timeline 0.8.6 → 0.8.8
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/.nodetool-build-stamp +1 -1
- package/dist/audioCrossfade.d.ts +26 -0
- package/dist/audioCrossfade.d.ts.map +1 -0
- package/dist/audioCrossfade.js +106 -0
- package/dist/audioCrossfade.js.map +1 -0
- package/dist/automation.d.ts +92 -0
- package/dist/automation.d.ts.map +1 -0
- package/dist/automation.js +274 -0
- package/dist/automation.js.map +1 -0
- package/dist/dropResolve.d.ts +11 -7
- package/dist/dropResolve.d.ts.map +1 -1
- package/dist/dropResolve.js +68 -42
- package/dist/dropResolve.js.map +1 -1
- package/dist/generatedMatte.d.ts.map +1 -1
- package/dist/generatedMatte.js +2 -1
- package/dist/generatedMatte.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/keyframes.d.ts +11 -0
- package/dist/keyframes.d.ts.map +1 -1
- package/dist/keyframes.js +3 -1
- package/dist/keyframes.js.map +1 -1
- package/dist/midi/fablesynthPresets.gen.d.ts +3 -0
- package/dist/midi/fablesynthPresets.gen.d.ts.map +1 -0
- package/dist/midi/fablesynthPresets.gen.js +119 -0
- package/dist/midi/fablesynthPresets.gen.js.map +1 -0
- package/dist/midi/instrument.d.ts +2 -0
- package/dist/midi/instrument.d.ts.map +1 -1
- package/dist/midi/instrument.js +5 -0
- package/dist/midi/instrument.js.map +1 -1
- package/dist/midi/presets.d.ts +32 -4
- package/dist/midi/presets.d.ts.map +1 -1
- package/dist/midi/presets.js +56 -2
- package/dist/midi/presets.js.map +1 -1
- package/dist/midi/voice.d.ts +7 -0
- package/dist/midi/voice.d.ts.map +1 -1
- package/dist/midi/voice.js +15 -3
- package/dist/midi/voice.js.map +1 -1
- package/dist/ops/apply.d.ts.map +1 -1
- package/dist/ops/apply.js +5 -1
- package/dist/ops/apply.js.map +1 -1
- package/dist/ops/op.d.ts +5 -2
- package/dist/ops/op.d.ts.map +1 -1
- package/dist/ops/op.js +1 -0
- package/dist/ops/op.js.map +1 -1
- package/dist/ops/parse.d.ts.map +1 -1
- package/dist/ops/parse.js +4 -0
- package/dist/ops/parse.js.map +1 -1
- package/dist/render/canvas2d.d.ts.map +1 -1
- package/dist/render/canvas2d.js +31 -50
- package/dist/render/canvas2d.js.map +1 -1
- package/dist/render/cpuLegacyEffects.d.ts.map +1 -1
- package/dist/render/cpuLegacyEffects.js +74 -46
- package/dist/render/cpuLegacyEffects.js.map +1 -1
- package/dist/render/effects.d.ts.map +1 -1
- package/dist/render/effects.js +7 -5
- package/dist/render/effects.js.map +1 -1
- package/dist/render/headlessRender.d.ts +1 -0
- package/dist/render/headlessRender.d.ts.map +1 -1
- package/dist/render/sceneModel.d.ts.map +1 -1
- package/dist/render/sceneModel.js +16 -10
- package/dist/render/sceneModel.js.map +1 -1
- package/dist/render/textLayout.d.ts +2 -0
- package/dist/render/textLayout.d.ts.map +1 -1
- package/dist/render/textLayout.js.map +1 -1
- package/dist/script.d.ts +34 -4
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +196 -34
- package/dist/script.js.map +1 -1
- package/dist/slideEdit.d.ts +20 -0
- package/dist/slideEdit.d.ts.map +1 -0
- package/dist/slideEdit.js +92 -0
- package/dist/slideEdit.js.map +1 -0
- package/dist/storyboard.d.ts +19 -1
- package/dist/storyboard.d.ts.map +1 -1
- package/dist/storyboard.js +55 -1
- package/dist/storyboard.js.map +1 -1
- package/dist/subtitles.d.ts +3 -2
- package/dist/subtitles.d.ts.map +1 -1
- package/dist/subtitles.js +8 -3
- package/dist/subtitles.js.map +1 -1
- package/dist/testing/ops.d.ts.map +1 -1
- package/dist/testing/ops.js +5 -0
- package/dist/testing/ops.js.map +1 -1
- package/dist/types.d.ts +94 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
2026-10-
|
|
1
|
+
2026-10-25T16:17:26.868Z
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Premiere's default audio transition (Ctrl+Shift+D): a constant power
|
|
3
|
+
* cross-fade at each edit of the chosen audio clips.
|
|
4
|
+
*
|
|
5
|
+
* Audio has no `transitionIn`, so a cross-fade is two fades that overlap.
|
|
6
|
+
* At a cut where an audio clip runs straight into the next one on its track,
|
|
7
|
+
* the earlier clip is extended under the later one by the fade length (as
|
|
8
|
+
* far as its source allows), it fades out across the overlap and the later
|
|
9
|
+
* one fades in across it, both along the equal-power `plus3dB` curve, so the
|
|
10
|
+
* level holds through the change. An edge with no clip against it fades to
|
|
11
|
+
* or from silence along the same curve. An earlier clip with no source left
|
|
12
|
+
* to extend dips instead: each side takes half the length.
|
|
13
|
+
*/
|
|
14
|
+
import type { TimelineClip } from "./types.js";
|
|
15
|
+
export interface AudioCrossfadeOptions {
|
|
16
|
+
/** Whether the clip may be lengthened under its neighbour. */
|
|
17
|
+
canExtend?: (clip: TimelineClip) => boolean;
|
|
18
|
+
/** The clip's source length in ms, when known. Unknown is not capped. */
|
|
19
|
+
sourceDurationMs?: (clip: TimelineClip) => number | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Cross-fade every edit of the audio clips in `clipIds`. Returns the same
|
|
23
|
+
* array when nothing changes.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyAudioCrossfades(clips: readonly TimelineClip[], clipIds: ReadonlySet<string>, durationMs: number, options?: AudioCrossfadeOptions): readonly TimelineClip[];
|
|
26
|
+
//# sourceMappingURL=audioCrossfade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioCrossfade.d.ts","sourceRoot":"","sources":["../src/audioCrossfade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO/C,MAAM,WAAW,qBAAqB;IACpC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;IAC5C,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,GAAG,SAAS,CAAC;CAC/D;AAaD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,qBAA0B,GAClC,SAAS,YAAY,EAAE,CA4EzB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Premiere's default audio transition (Ctrl+Shift+D): a constant power
|
|
3
|
+
* cross-fade at each edit of the chosen audio clips.
|
|
4
|
+
*
|
|
5
|
+
* Audio has no `transitionIn`, so a cross-fade is two fades that overlap.
|
|
6
|
+
* At a cut where an audio clip runs straight into the next one on its track,
|
|
7
|
+
* the earlier clip is extended under the later one by the fade length (as
|
|
8
|
+
* far as its source allows), it fades out across the overlap and the later
|
|
9
|
+
* one fades in across it, both along the equal-power `plus3dB` curve, so the
|
|
10
|
+
* level holds through the change. An edge with no clip against it fades to
|
|
11
|
+
* or from silence along the same curve. An earlier clip with no source left
|
|
12
|
+
* to extend dips instead: each side takes half the length.
|
|
13
|
+
*/
|
|
14
|
+
import { sourceRate } from "./sourceRate.js";
|
|
15
|
+
import { trimClip } from "./trimClip.js";
|
|
16
|
+
/** Within this many ms two edges touch. */
|
|
17
|
+
const TOUCH_MS = 1;
|
|
18
|
+
const endOf = (c) => c.startMs + c.durationMs;
|
|
19
|
+
/** How far `clip`'s tail can be extended before its source runs out. */
|
|
20
|
+
function tailHandleMs(clip, sourceDurationMs) {
|
|
21
|
+
if (sourceDurationMs === undefined)
|
|
22
|
+
return Number.POSITIVE_INFINITY;
|
|
23
|
+
const rate = sourceRate(clip);
|
|
24
|
+
const outMs = clip.outPointMs ?? (clip.inPointMs ?? 0) + clip.durationMs * rate;
|
|
25
|
+
return Math.max(0, (sourceDurationMs - outMs) / rate);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Cross-fade every edit of the audio clips in `clipIds`. Returns the same
|
|
29
|
+
* array when nothing changes.
|
|
30
|
+
*/
|
|
31
|
+
export function applyAudioCrossfades(clips, clipIds, durationMs, options = {}) {
|
|
32
|
+
if (!(durationMs > 0))
|
|
33
|
+
return clips;
|
|
34
|
+
const canExtend = options.canExtend ?? (() => true);
|
|
35
|
+
const next = new Map();
|
|
36
|
+
const current = (c) => next.get(c.id) ?? c;
|
|
37
|
+
const audio = clips.filter((c) => c.mediaType === "audio");
|
|
38
|
+
const chosen = audio.filter((c) => clipIds.has(c.id));
|
|
39
|
+
// Each cut once, even when both of its clips are chosen.
|
|
40
|
+
const cuts = new Map();
|
|
41
|
+
const touching = (a, b) => a.id !== b.id &&
|
|
42
|
+
a.trackId === b.trackId &&
|
|
43
|
+
Math.abs(endOf(a) - b.startMs) <= TOUCH_MS;
|
|
44
|
+
for (const clip of chosen) {
|
|
45
|
+
const before = audio.find((c) => touching(c, clip));
|
|
46
|
+
const after = audio.find((c) => touching(clip, c));
|
|
47
|
+
if (before)
|
|
48
|
+
cuts.set(`${before.id}>${clip.id}`, [before, clip]);
|
|
49
|
+
else {
|
|
50
|
+
const span = Math.floor(Math.min(durationMs, clip.durationMs / 2));
|
|
51
|
+
if (span > 0) {
|
|
52
|
+
next.set(clip.id, {
|
|
53
|
+
...current(clip),
|
|
54
|
+
fadeInMs: span,
|
|
55
|
+
fadeInShape: "plus3dB"
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (after)
|
|
60
|
+
cuts.set(`${clip.id}>${after.id}`, [clip, after]);
|
|
61
|
+
else {
|
|
62
|
+
const span = Math.floor(Math.min(durationMs, clip.durationMs / 2));
|
|
63
|
+
if (span > 0) {
|
|
64
|
+
next.set(clip.id, {
|
|
65
|
+
...current(clip),
|
|
66
|
+
fadeOutMs: span,
|
|
67
|
+
fadeOutShape: "plus3dB"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const [outgoing, incoming] of cuts.values()) {
|
|
73
|
+
const a = current(outgoing);
|
|
74
|
+
const b = current(incoming);
|
|
75
|
+
const handleMs = canExtend(a)
|
|
76
|
+
? tailHandleMs(a, options.sourceDurationMs?.(a))
|
|
77
|
+
: 0;
|
|
78
|
+
const overlapMs = Math.floor(Math.min(durationMs, handleMs, b.durationMs / 2));
|
|
79
|
+
if (overlapMs > 0) {
|
|
80
|
+
let extended;
|
|
81
|
+
try {
|
|
82
|
+
extended = trimClip(a, "end", overlapMs);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// A time-remapped clip cannot be trimmed; leave this cut alone.
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
next.set(a.id, {
|
|
89
|
+
...extended,
|
|
90
|
+
fadeOutMs: overlapMs,
|
|
91
|
+
fadeOutShape: "plus3dB"
|
|
92
|
+
});
|
|
93
|
+
next.set(b.id, { ...b, fadeInMs: overlapMs, fadeInShape: "plus3dB" });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const halfMs = Math.floor(Math.min(durationMs / 2, a.durationMs / 2, b.durationMs / 2));
|
|
97
|
+
if (halfMs <= 0)
|
|
98
|
+
continue;
|
|
99
|
+
next.set(a.id, { ...a, fadeOutMs: halfMs, fadeOutShape: "plus3dB" });
|
|
100
|
+
next.set(b.id, { ...b, fadeInMs: halfMs, fadeInShape: "plus3dB" });
|
|
101
|
+
}
|
|
102
|
+
if (next.size === 0)
|
|
103
|
+
return clips;
|
|
104
|
+
return clips.map((c) => next.get(c.id) ?? c);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=audioCrossfade.js.map
|
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C,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track automation lanes: one curve per parameter, over document time, drawn
|
|
3
|
+
* under the track the way Ableton and Cubase draw them.
|
|
4
|
+
*
|
|
5
|
+
* A lane's points use the clip keyframe model: each point carries the easing
|
|
6
|
+
* of the segment that arrives at it, the value holds before the first point
|
|
7
|
+
* and after the last, and {@link curveValueAtT} evaluates both. Values are in
|
|
8
|
+
* the parameter's own unit, so a lane reads the same whether a mixer, a synth
|
|
9
|
+
* or a renderer plays it.
|
|
10
|
+
*
|
|
11
|
+
* Hosts apply lanes by target kind:
|
|
12
|
+
* - `mixer` and `device` lanes are audio. The browser audio graph schedules
|
|
13
|
+
* them on the context clock ({@link automationBreakpoints}).
|
|
14
|
+
* - `clip` lanes are picture. {@link applyTrackAutomation} turns them into
|
|
15
|
+
* one clip-spanning animation per clip, so every renderer that samples
|
|
16
|
+
* clip animations plays them with no code of its own.
|
|
17
|
+
*
|
|
18
|
+
* These are pure functions; the store wraps the edits.
|
|
19
|
+
*/
|
|
20
|
+
import type { AutomationLane, AutomationPoint, AutomationTarget, TimelineClip, TimelineTrack } from "./types.js";
|
|
21
|
+
/** The `deviceId` of a `device` target that names the track's instrument. */
|
|
22
|
+
export declare const INSTRUMENT_DEVICE_ID = "instrument";
|
|
23
|
+
/** The marker on an animation {@link applyTrackAutomation} synthesized. */
|
|
24
|
+
export declare const TRACK_AUTOMATION_PARAM = "trackAutomation";
|
|
25
|
+
/** One string per target, equal exactly when two targets drive the same control. */
|
|
26
|
+
export declare function automationTargetKey(target: AutomationTarget): string;
|
|
27
|
+
export declare function sameAutomationTarget(a: AutomationTarget, b: AutomationTarget): boolean;
|
|
28
|
+
/** Whether a lane plays: enabled and holding at least one point. */
|
|
29
|
+
export declare function isAutomationLaneActive(lane: AutomationLane): boolean;
|
|
30
|
+
/** The track's lane for `target`, if it has one. */
|
|
31
|
+
export declare function findAutomationLane(track: Pick<TimelineTrack, "automation">, target: AutomationTarget): AutomationLane | undefined;
|
|
32
|
+
/** A new lane with no points. */
|
|
33
|
+
export declare function createAutomationLane(target: AutomationTarget): AutomationLane;
|
|
34
|
+
/** The lane's value at `timeMs`, or `fallback` when it has no points. */
|
|
35
|
+
export declare function automationValueAt(points: readonly AutomationPoint[], timeMs: number, fallback?: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Add a point, or replace the one already at its time. Returns the new points
|
|
38
|
+
* and the index the point landed on.
|
|
39
|
+
*/
|
|
40
|
+
export declare function addAutomationPoint(points: readonly AutomationPoint[], point: AutomationPoint): {
|
|
41
|
+
points: AutomationPoint[];
|
|
42
|
+
index: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Move the point at `index` to a new time and value. It cannot pass its
|
|
46
|
+
* neighbours, so the indices of every other point stay where they were.
|
|
47
|
+
*/
|
|
48
|
+
export declare function moveAutomationPoint(points: readonly AutomationPoint[], index: number, timeMs: number, value: number): AutomationPoint[];
|
|
49
|
+
/** Remove the points at `indices`. */
|
|
50
|
+
export declare function removeAutomationPoints(points: readonly AutomationPoint[], indices: Iterable<number>): AutomationPoint[];
|
|
51
|
+
/** Set the easing of the segment arriving at the point at `index`. */
|
|
52
|
+
export declare function setAutomationPointEasing(points: readonly AutomationPoint[], index: number, easing: string): AutomationPoint[];
|
|
53
|
+
/** The point indices with `fromMs <= timeMs <= toMs`. */
|
|
54
|
+
export declare function automationPointsInRange(points: readonly AutomationPoint[], fromMs: number, toMs: number): number[];
|
|
55
|
+
export interface AutomationBreakpoint {
|
|
56
|
+
timeMs: number;
|
|
57
|
+
value: number;
|
|
58
|
+
}
|
|
59
|
+
export interface AutomationBreakpointOptions {
|
|
60
|
+
/**
|
|
61
|
+
* Longest straight piece an eased segment is cut into, in ms. Linear
|
|
62
|
+
* segments stay one piece unless `subdivideLinear` is set.
|
|
63
|
+
*/
|
|
64
|
+
maxStepMs?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Cut linear segments too: for a host that ramps in another unit than the
|
|
67
|
+
* lane's (a dB lane ramped as linear gain).
|
|
68
|
+
*/
|
|
69
|
+
subdivideLinear?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The lane as straight ramps from `fromMs` on: the value at `fromMs`, then
|
|
73
|
+
* every point after it, with eased segments cut into pieces no longer than
|
|
74
|
+
* `maxStepMs`. A host plays it by setting the first value and ramping
|
|
75
|
+
* linearly to each next one. A `hold` segment comes out as two breakpoints
|
|
76
|
+
* at the same time, the jump. Empty without points.
|
|
77
|
+
*/
|
|
78
|
+
export declare function automationBreakpoints(points: readonly AutomationPoint[], fromMs: number, options?: AutomationBreakpointOptions): AutomationBreakpoint[];
|
|
79
|
+
/** Whether `track` can hold a lane for `target`. */
|
|
80
|
+
export declare function trackAcceptsAutomationTarget(track: Pick<TimelineTrack, "type" | "effects">, target: AutomationTarget): boolean;
|
|
81
|
+
/** The value a picture lane starts at: the one that changes nothing. */
|
|
82
|
+
export declare function clipAutomationIdentity(property: string): number;
|
|
83
|
+
/**
|
|
84
|
+
* `clips` with every picture track's `clip` lanes added to each clip on that
|
|
85
|
+
* track as one more animation. Clips on tracks without such lanes are
|
|
86
|
+
* returned as they are, and so is `clips` itself when no track has any.
|
|
87
|
+
*
|
|
88
|
+
* Cached by the identity of both arrays, which a document replaces rather than
|
|
89
|
+
* edits, so the scene model's per-clip caches keep hitting between frames.
|
|
90
|
+
*/
|
|
91
|
+
export declare function applyTrackAutomation(tracks: readonly TimelineTrack[], clips: readonly TimelineClip[]): readonly TimelineClip[];
|
|
92
|
+
//# sourceMappingURL=automation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.d.ts","sourceRoot":"","sources":["../src/automation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,g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CAAC,MAAM,CAAC,GACxB,eAAe,EAAE,CAGnB;AAED,sEAAsE;AACtE,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,eAAe,EAAE,CAEnB;AAED,yDAAyD;AACzD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,MAAM,EAAE,CAMV;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAKD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,2BAAgC,GACxC,oBAAoB,EAAE,CAiCxB;AAOD,oDAAoD;AACpD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC,EAC9C,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAKT;AAED,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D;AAyDD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,KAAK,EAAE,SAAS,YAAY,EAAE,GAC7B,SAAS,YAAY,EAAE,CA2BzB"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track automation lanes: one curve per parameter, over document time, drawn
|
|
3
|
+
* under the track the way Ableton and Cubase draw them.
|
|
4
|
+
*
|
|
5
|
+
* A lane's points use the clip keyframe model: each point carries the easing
|
|
6
|
+
* of the segment that arrives at it, the value holds before the first point
|
|
7
|
+
* and after the last, and {@link curveValueAtT} evaluates both. Values are in
|
|
8
|
+
* the parameter's own unit, so a lane reads the same whether a mixer, a synth
|
|
9
|
+
* or a renderer plays it.
|
|
10
|
+
*
|
|
11
|
+
* Hosts apply lanes by target kind:
|
|
12
|
+
* - `mixer` and `device` lanes are audio. The browser audio graph schedules
|
|
13
|
+
* them on the context clock ({@link automationBreakpoints}).
|
|
14
|
+
* - `clip` lanes are picture. {@link applyTrackAutomation} turns them into
|
|
15
|
+
* one clip-spanning animation per clip, so every renderer that samples
|
|
16
|
+
* clip animations plays them with no code of its own.
|
|
17
|
+
*
|
|
18
|
+
* These are pure functions; the store wraps the edits.
|
|
19
|
+
*/
|
|
20
|
+
import { ANIMATED_PROPERTY_FOLD } from "./animation/types.js";
|
|
21
|
+
import { ease } from "./animation/easing.js";
|
|
22
|
+
import { createTimeOrderedUuid } from "./defaults.js";
|
|
23
|
+
import { curveValueAtT } from "./keyframes.js";
|
|
24
|
+
/** The `deviceId` of a `device` target that names the track's instrument. */
|
|
25
|
+
export const INSTRUMENT_DEVICE_ID = "instrument";
|
|
26
|
+
/** The marker on an animation {@link applyTrackAutomation} synthesized. */
|
|
27
|
+
export const TRACK_AUTOMATION_PARAM = "trackAutomation";
|
|
28
|
+
/** Two points closer than this (ms) are the same point. */
|
|
29
|
+
const SAME_POINT_MS = 0.5;
|
|
30
|
+
/** One string per target, equal exactly when two targets drive the same control. */
|
|
31
|
+
export function automationTargetKey(target) {
|
|
32
|
+
switch (target.kind) {
|
|
33
|
+
case "mixer":
|
|
34
|
+
return `mixer:${target.param}`;
|
|
35
|
+
case "device":
|
|
36
|
+
return `device:${target.deviceId}:${target.param}`;
|
|
37
|
+
case "clip":
|
|
38
|
+
return `clip:${target.property}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function sameAutomationTarget(a, b) {
|
|
42
|
+
return automationTargetKey(a) === automationTargetKey(b);
|
|
43
|
+
}
|
|
44
|
+
/** Whether a lane plays: enabled and holding at least one point. */
|
|
45
|
+
export function isAutomationLaneActive(lane) {
|
|
46
|
+
return lane.enabled !== false && lane.points.length > 0;
|
|
47
|
+
}
|
|
48
|
+
/** The track's lane for `target`, if it has one. */
|
|
49
|
+
export function findAutomationLane(track, target) {
|
|
50
|
+
const key = automationTargetKey(target);
|
|
51
|
+
return track.automation?.find((lane) => automationTargetKey(lane.target) === key);
|
|
52
|
+
}
|
|
53
|
+
/** A new lane with no points. */
|
|
54
|
+
export function createAutomationLane(target) {
|
|
55
|
+
return { id: createTimeOrderedUuid(), target, points: [] };
|
|
56
|
+
}
|
|
57
|
+
function asKeyframes(points) {
|
|
58
|
+
return points.map((p) => p.easing === undefined
|
|
59
|
+
? { t: p.timeMs, value: p.value }
|
|
60
|
+
: { t: p.timeMs, value: p.value, easing: p.easing });
|
|
61
|
+
}
|
|
62
|
+
/** The lane's value at `timeMs`, or `fallback` when it has no points. */
|
|
63
|
+
export function automationValueAt(points, timeMs, fallback = 0) {
|
|
64
|
+
if (points.length === 0)
|
|
65
|
+
return fallback;
|
|
66
|
+
return curveValueAtT(asKeyframes(points), timeMs);
|
|
67
|
+
}
|
|
68
|
+
function sortPoints(points) {
|
|
69
|
+
return points.sort((a, b) => a.timeMs - b.timeMs);
|
|
70
|
+
}
|
|
71
|
+
function cleanPoint(point) {
|
|
72
|
+
const next = {
|
|
73
|
+
timeMs: Math.max(0, point.timeMs),
|
|
74
|
+
value: point.value
|
|
75
|
+
};
|
|
76
|
+
if (point.easing !== undefined && point.easing !== "linear")
|
|
77
|
+
next.easing = point.easing;
|
|
78
|
+
return next;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add a point, or replace the one already at its time. Returns the new points
|
|
82
|
+
* and the index the point landed on.
|
|
83
|
+
*/
|
|
84
|
+
export function addAutomationPoint(points, point) {
|
|
85
|
+
const clean = cleanPoint(point);
|
|
86
|
+
const replaced = points.find((p) => Math.abs(p.timeMs - clean.timeMs) < SAME_POINT_MS);
|
|
87
|
+
// Re-setting a point keeps the easing chosen for its segment.
|
|
88
|
+
if (replaced?.easing !== undefined && point.easing === undefined)
|
|
89
|
+
clean.easing = replaced.easing;
|
|
90
|
+
const next = sortPoints([...points.filter((p) => p !== replaced), clean]);
|
|
91
|
+
return { points: next, index: next.indexOf(clean) };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Move the point at `index` to a new time and value. It cannot pass its
|
|
95
|
+
* neighbours, so the indices of every other point stay where they were.
|
|
96
|
+
*/
|
|
97
|
+
export function moveAutomationPoint(points, index, timeMs, value) {
|
|
98
|
+
const current = points[index];
|
|
99
|
+
if (!current)
|
|
100
|
+
return [...points];
|
|
101
|
+
const lo = index > 0 ? points[index - 1].timeMs : 0;
|
|
102
|
+
const hi = index < points.length - 1 ? points[index + 1].timeMs : Number.POSITIVE_INFINITY;
|
|
103
|
+
const next = [...points];
|
|
104
|
+
next[index] = { ...current, timeMs: Math.min(hi, Math.max(lo, timeMs)), value };
|
|
105
|
+
return next;
|
|
106
|
+
}
|
|
107
|
+
/** Remove the points at `indices`. */
|
|
108
|
+
export function removeAutomationPoints(points, indices) {
|
|
109
|
+
const drop = new Set(indices);
|
|
110
|
+
return points.filter((_, i) => !drop.has(i));
|
|
111
|
+
}
|
|
112
|
+
/** Set the easing of the segment arriving at the point at `index`. */
|
|
113
|
+
export function setAutomationPointEasing(points, index, easing) {
|
|
114
|
+
return points.map((p, i) => (i === index ? cleanPoint({ ...p, easing }) : p));
|
|
115
|
+
}
|
|
116
|
+
/** The point indices with `fromMs <= timeMs <= toMs`. */
|
|
117
|
+
export function automationPointsInRange(points, fromMs, toMs) {
|
|
118
|
+
const out = [];
|
|
119
|
+
points.forEach((p, i) => {
|
|
120
|
+
if (p.timeMs >= fromMs && p.timeMs <= toMs)
|
|
121
|
+
out.push(i);
|
|
122
|
+
});
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
const DEFAULT_STEP_MS = 10;
|
|
126
|
+
const MAX_STEPS_PER_SEGMENT = 512;
|
|
127
|
+
/**
|
|
128
|
+
* The lane as straight ramps from `fromMs` on: the value at `fromMs`, then
|
|
129
|
+
* every point after it, with eased segments cut into pieces no longer than
|
|
130
|
+
* `maxStepMs`. A host plays it by setting the first value and ramping
|
|
131
|
+
* linearly to each next one. A `hold` segment comes out as two breakpoints
|
|
132
|
+
* at the same time, the jump. Empty without points.
|
|
133
|
+
*/
|
|
134
|
+
export function automationBreakpoints(points, fromMs, options = {}) {
|
|
135
|
+
if (points.length === 0)
|
|
136
|
+
return [];
|
|
137
|
+
const step = Math.max(1, options.maxStepMs ?? DEFAULT_STEP_MS);
|
|
138
|
+
const out = [
|
|
139
|
+
{ timeMs: fromMs, value: automationValueAt(points, fromMs) }
|
|
140
|
+
];
|
|
141
|
+
for (let i = 0; i < points.length; i++) {
|
|
142
|
+
const b = points[i];
|
|
143
|
+
if (b.timeMs <= fromMs)
|
|
144
|
+
continue;
|
|
145
|
+
const a = out[out.length - 1];
|
|
146
|
+
const easing = b.easing ?? "linear";
|
|
147
|
+
const span = b.timeMs - a.timeMs;
|
|
148
|
+
if (easing === "hold") {
|
|
149
|
+
out.push({ timeMs: b.timeMs, value: a.value }, { timeMs: b.timeMs, value: b.value });
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const curved = easing !== "linear" || options.subdivideLinear === true;
|
|
153
|
+
if (curved && span > step) {
|
|
154
|
+
// The segment started at the previous point, which may lie before
|
|
155
|
+
// `fromMs`: its easing runs over the whole segment, not the visible part.
|
|
156
|
+
const segStart = i > 0 ? Math.min(points[i - 1].timeMs, a.timeMs) : a.timeMs;
|
|
157
|
+
const segValue = i > 0 && points[i - 1].timeMs <= fromMs ? points[i - 1].value : a.value;
|
|
158
|
+
const segSpan = b.timeMs - segStart;
|
|
159
|
+
const steps = Math.min(MAX_STEPS_PER_SEGMENT, Math.ceil(span / step));
|
|
160
|
+
for (let s = 1; s < steps; s++) {
|
|
161
|
+
const t = a.timeMs + (span * s) / steps;
|
|
162
|
+
const f = segSpan > 0 ? ease(easing, (t - segStart) / segSpan) : 1;
|
|
163
|
+
out.push({ timeMs: t, value: segValue + (b.value - segValue) * f });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
out.push({ timeMs: b.timeMs, value: b.value });
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
// ── Picture lanes ───────────────────────────────────────────────────────────
|
|
171
|
+
/** Track types whose clips draw picture, and so take `clip` lanes. */
|
|
172
|
+
const PICTURE_TRACK_TYPES = new Set(["video", "overlay"]);
|
|
173
|
+
/** Whether `track` can hold a lane for `target`. */
|
|
174
|
+
export function trackAcceptsAutomationTarget(track, target) {
|
|
175
|
+
if (target.kind === "clip")
|
|
176
|
+
return PICTURE_TRACK_TYPES.has(track.type);
|
|
177
|
+
if (target.kind === "mixer")
|
|
178
|
+
return track.type === "audio" || track.type === "midi";
|
|
179
|
+
if (target.deviceId === INSTRUMENT_DEVICE_ID)
|
|
180
|
+
return track.type === "midi";
|
|
181
|
+
return track.effects?.some((effect) => effect.id === target.deviceId) ?? false;
|
|
182
|
+
}
|
|
183
|
+
/** The value a picture lane starts at: the one that changes nothing. */
|
|
184
|
+
export function clipAutomationIdentity(property) {
|
|
185
|
+
return ANIMATED_PROPERTY_FOLD[property] === "multiply" ? 1 : 0;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* One clip-spanning custom animation that plays a track's picture lanes over
|
|
189
|
+
* `clip`: each lane cut to the clip's window, with an interpolated keyframe on
|
|
190
|
+
* each edge, in the clip's 0..1 `t`.
|
|
191
|
+
*/
|
|
192
|
+
function clipAutomationAnimation(track, lanes, clip) {
|
|
193
|
+
const start = clip.startMs;
|
|
194
|
+
const end = clip.startMs + clip.durationMs;
|
|
195
|
+
if (clip.durationMs <= 0)
|
|
196
|
+
return null;
|
|
197
|
+
const curves = [];
|
|
198
|
+
for (const lane of lanes) {
|
|
199
|
+
if (lane.target.kind !== "clip")
|
|
200
|
+
continue;
|
|
201
|
+
const toT = (ms) => (ms - start) / clip.durationMs;
|
|
202
|
+
const keyframes = [
|
|
203
|
+
{ t: 0, value: automationValueAt(lane.points, start) }
|
|
204
|
+
];
|
|
205
|
+
for (const p of lane.points) {
|
|
206
|
+
if (p.timeMs <= start || p.timeMs >= end)
|
|
207
|
+
continue;
|
|
208
|
+
keyframes.push(p.easing === undefined
|
|
209
|
+
? { t: toT(p.timeMs), value: p.value }
|
|
210
|
+
: { t: toT(p.timeMs), value: p.value, easing: p.easing });
|
|
211
|
+
}
|
|
212
|
+
const tail = {
|
|
213
|
+
t: 1,
|
|
214
|
+
value: automationValueAt(lane.points, end)
|
|
215
|
+
};
|
|
216
|
+
const after = lane.points.find((p) => p.timeMs >= end);
|
|
217
|
+
if (after?.easing !== undefined)
|
|
218
|
+
tail.easing = after.easing;
|
|
219
|
+
keyframes.push(tail);
|
|
220
|
+
curves.push({ property: lane.target.property, keyframes });
|
|
221
|
+
}
|
|
222
|
+
if (curves.length === 0)
|
|
223
|
+
return null;
|
|
224
|
+
return {
|
|
225
|
+
id: `automation:${track.id}`,
|
|
226
|
+
role: "emphasis",
|
|
227
|
+
preset: "custom",
|
|
228
|
+
durationMs: clip.durationMs,
|
|
229
|
+
delayMs: 0,
|
|
230
|
+
enabled: true,
|
|
231
|
+
params: { [TRACK_AUTOMATION_PARAM]: true },
|
|
232
|
+
custom: { curves }
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
const automatedCache = new WeakMap();
|
|
236
|
+
/**
|
|
237
|
+
* `clips` with every picture track's `clip` lanes added to each clip on that
|
|
238
|
+
* track as one more animation. Clips on tracks without such lanes are
|
|
239
|
+
* returned as they are, and so is `clips` itself when no track has any.
|
|
240
|
+
*
|
|
241
|
+
* Cached by the identity of both arrays, which a document replaces rather than
|
|
242
|
+
* edits, so the scene model's per-clip caches keep hitting between frames.
|
|
243
|
+
*/
|
|
244
|
+
export function applyTrackAutomation(tracks, clips) {
|
|
245
|
+
let byClips = automatedCache.get(tracks);
|
|
246
|
+
const hit = byClips?.get(clips);
|
|
247
|
+
if (hit)
|
|
248
|
+
return hit;
|
|
249
|
+
const lanesByTrack = new Map();
|
|
250
|
+
for (const track of tracks) {
|
|
251
|
+
if (!PICTURE_TRACK_TYPES.has(track.type))
|
|
252
|
+
continue;
|
|
253
|
+
const lanes = (track.automation ?? []).filter((lane) => lane.target.kind === "clip" && isAutomationLaneActive(lane));
|
|
254
|
+
if (lanes.length > 0)
|
|
255
|
+
lanesByTrack.set(track.id, { track, lanes });
|
|
256
|
+
}
|
|
257
|
+
if (lanesByTrack.size === 0)
|
|
258
|
+
return clips;
|
|
259
|
+
const result = clips.map((clip) => {
|
|
260
|
+
const entry = lanesByTrack.get(clip.trackId);
|
|
261
|
+
if (!entry || clip.mediaType === "group" || clip.mediaType === "audio" || clip.mediaType === "midi") {
|
|
262
|
+
return clip;
|
|
263
|
+
}
|
|
264
|
+
const animation = clipAutomationAnimation(entry.track, entry.lanes, clip);
|
|
265
|
+
return animation ? { ...clip, animations: [...(clip.animations ?? []), animation] } : clip;
|
|
266
|
+
});
|
|
267
|
+
if (!byClips) {
|
|
268
|
+
byClips = new WeakMap();
|
|
269
|
+
automatedCache.set(tracks, byClips);
|
|
270
|
+
}
|
|
271
|
+
byClips.set(clips, result);
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=automation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.js","sourceRoot":"","sources":["../src/automation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,sBAAsB,EAAyB,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CA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d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* - **overwrite** — the moved clip replaces what it covers on its track. A
|
|
9
9
|
* clip fully under it goes, a clip it partly covers is trimmed back, and a
|
|
10
|
-
* clip that spans it is cut in two around it.
|
|
10
|
+
* clip that spans it is cut in two around it. The clip's linked partners
|
|
11
|
+
* (its audio) get the same cut.
|
|
11
12
|
* - **insert** — the moved clip pushes everything from its start onward to
|
|
12
13
|
* the right by its length, on every unlocked track, cutting a clip on its
|
|
13
14
|
* own track that straddles the insert point (and that clip's linked
|
|
@@ -24,12 +25,15 @@ export declare const DROP_MODES: readonly ["overwrite", "insert", "overlap"];
|
|
|
24
25
|
export type DropMode = (typeof DROP_MODES)[number];
|
|
25
26
|
/**
|
|
26
27
|
* Cut back, split or remove the clips that `movedIds` now cover on their own
|
|
27
|
-
* tracks
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
28
|
+
* tracks, and the same window out of each victim's linked partners, so a
|
|
29
|
+
* video and its audio stay in sync. A cut that leaves a link group with a head
|
|
30
|
+
* and a tail links the heads together and the tails together. Linked siblings
|
|
31
|
+
* and group children of a moved clip moved with it, so each clears its own
|
|
32
|
+
* track and none is a victim. A group clip is never a victim either: removing
|
|
33
|
+
* or trimming it as media would strand its children. A link group with a
|
|
34
|
+
* member that refuses a trim or split (a time-remapped one) is left whole
|
|
35
|
+
* rather than half-edited, and a locked clip or one on a locked track keeps
|
|
36
|
+
* its place: the mover overlaps it instead.
|
|
33
37
|
*/
|
|
34
38
|
export declare function resolveOverwrite(clips: readonly TimelineClip[], movedIds: ReadonlySet<string>, options?: RippleOptions): TimelineClip[];
|
|
35
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropResolve.d.ts","sourceRoot":"","sources":["../src/dropResolve.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dropResolve.d.ts","sourceRoot":"","sources":["../src/dropResolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,UAAU,YAAI,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AACtE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AA6DnD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,OAAO,GAAE,aAAkB,GAC1B,YAAY,EAAE,CA6DhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,OAAO,GAAE,aAAkB,GAC1B,YAAY,EAAE,CAmEhB;AAED,uCAAuC;AACvC,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,aAAkB,GAC1B,YAAY,EAAE,CAShB"}
|