@tongue-core/engine 0.1.0-rc.7 → 0.1.0-rc.9

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.
@@ -65,6 +65,8 @@ export declare class FilmRenderer {
65
65
  /** Puts an image in the raster now (decoded, mip-mapped), so the first frame that shows it doesn't
66
66
  * wait for that: what a player does with an image as it arrives. */
67
67
  preloadImage(name: string): void;
68
+ /** Releases the raster's decoded copy when a host evicts a remote image. */
69
+ forgetImage(name: string): void;
68
70
  /** Keeps only the images `out` draws in the raster and returns their names. Decoded images are
69
71
  * the raster's biggest cost, so a host with little memory (a Worker) calls this before drawing,
70
72
  * and drops the files of everything else. A later frame that shows one loads it again. */
@@ -172,6 +172,12 @@ export class FilmRenderer {
172
172
  this.backend.loadImage(id, image.qoi);
173
173
  this.loaded.set(id, "image");
174
174
  }
175
+ /** Releases the raster's decoded copy when a host evicts a remote image. */
176
+ forgetImage(name) {
177
+ const id = this.imageIds.get(`${IMAGE_KEY}${name}`);
178
+ if (id !== undefined && this.loaded.delete(id))
179
+ this.backend.loadImage(id, NOTHING);
180
+ }
175
181
  /** Keeps only the images `out` draws in the raster and returns their names. Decoded images are
176
182
  * the raster's biggest cost, so a host with little memory (a Worker) calls this before drawing,
177
183
  * and drops the files of everything else. A later frame that shows one loads it again. */
@@ -9,4 +9,7 @@ export declare function collectSounds(plan: FilmPlan, range?: {
9
9
  readonly to: number;
10
10
  }): ReadonlyArray<SoundEvent>;
11
11
  /** The film's audio clips with their decoded audio (clips whose audio isn't loaded are left out). */
12
- export declare function audioClips(plan: FilmPlan, assets: LoadedAssets): ReadonlyArray<ClipAudio>;
12
+ export declare function audioClips(plan: FilmPlan, assets: LoadedAssets, range?: {
13
+ readonly from: number;
14
+ readonly to: number;
15
+ }): ReadonlyArray<ClipAudio>;
@@ -34,12 +34,16 @@ export function collectSounds(plan, range) {
34
34
  return [...seen.values()].sort((a, b) => a.at - b.at);
35
35
  }
36
36
  /** The film's audio clips with their decoded audio (clips whose audio isn't loaded are left out). */
37
- export function audioClips(plan, assets) {
37
+ export function audioClips(plan, assets, range) {
38
38
  return plan.tracks.filter((t) => t.kind === "audio").flatMap((t) => t.clips).flatMap((clip) => {
39
39
  const s = clip.source;
40
40
  if (s.kind !== "audio")
41
41
  return [];
42
- const pcm = assets.audio.get(s.asset.name);
42
+ if (range && (clip.end <= range.from || clip.start >= range.to))
43
+ return [];
44
+ const from = range ? s.in + Math.max(0, (range.from - clip.start) / plan.fps) * s.speed : s.in;
45
+ const to = range ? s.in + Math.min(clip.duration / plan.fps, (range.to - clip.start) / plan.fps) * s.speed : s.out;
46
+ const pcm = assets.audioWindow?.(s.asset.name, Math.max(s.in, from - 0.2 * s.speed), to + 0.2 * s.speed) ?? assets.audio.get(s.asset.name);
43
47
  return pcm ? [{ pcm, start: clip.start, end: clip.end, in: s.in, speed: s.speed, gain: s.gain, fadeIn: s.fadeIn, fadeOut: s.fadeOut }] : [];
44
48
  });
45
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tongue-core/engine",
3
- "version": "0.1.0-rc.7",
3
+ "version": "0.1.0-rc.9",
4
4
  "description": "Frame to pixels for Tongue films: evaluate, layout, paint and rasterize, deterministic everywhere.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "README.md"
27
27
  ],
28
28
  "dependencies": {
29
- "@tongue-core/film": "0.1.0-rc.7"
29
+ "@tongue-core/film": "0.1.0-rc.9"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
package/raster.wasm CHANGED
Binary file