@automovie/ingest 0.3.3 → 0.4.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/README.md +9 -29
- package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.d.ts +4 -1
- package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js +4 -1
- package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js.map +1 -1
- package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.d.ts +4 -1
- package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js +4 -1
- package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js.map +1 -1
- package/lib/adoptAutoMovieExternalMotion.d.ts +21 -11
- package/lib/adoptAutoMovieExternalMotion.js +26 -12
- package/lib/adoptAutoMovieExternalMotion.js.map +1 -1
- package/lib/audio/admitProductionTtsReceipt.d.ts +25 -0
- package/lib/audio/admitProductionTtsReceipt.js +166 -0
- package/lib/audio/admitProductionTtsReceipt.js.map +1 -0
- package/lib/audio/decodeProductionAudioAsset.d.ts +42 -14
- package/lib/audio/decodeProductionAudioAsset.js +53 -30
- package/lib/audio/decodeProductionAudioAsset.js.map +1 -1
- package/lib/audio/index.d.ts +1 -0
- package/lib/audio/index.js +1 -0
- package/lib/audio/index.js.map +1 -1
- package/lib/audio/resampleProductionAudio.d.ts +22 -0
- package/lib/audio/resampleProductionAudio.js +103 -0
- package/lib/audio/resampleProductionAudio.js.map +1 -0
- package/lib/decodeAutoMoviePpmImage.d.ts +10 -18
- package/lib/decodeAutoMoviePpmImage.js +10 -18
- package/lib/decodeAutoMoviePpmImage.js.map +1 -1
- package/lib/font/TrueTypeByteReader.d.ts +34 -0
- package/lib/font/TrueTypeByteReader.js +67 -0
- package/lib/font/TrueTypeByteReader.js.map +1 -0
- package/lib/font/decodeAutoMovieTrueTypeFont.d.ts +31 -0
- package/lib/font/decodeAutoMovieTrueTypeFont.js +168 -0
- package/lib/font/decodeAutoMovieTrueTypeFont.js.map +1 -0
- package/lib/font/index.d.ts +1 -0
- package/lib/font/index.js +18 -0
- package/lib/font/index.js.map +1 -0
- package/lib/font/readTrueTypeCharacterMap.d.ts +23 -0
- package/lib/font/readTrueTypeCharacterMap.js +98 -0
- package/lib/font/readTrueTypeCharacterMap.js.map +1 -0
- package/lib/font/readTrueTypeGlyphOutline.d.ts +45 -0
- package/lib/font/readTrueTypeGlyphOutline.js +275 -0
- package/lib/font/readTrueTypeGlyphOutline.js.map +1 -0
- package/lib/font/readTrueTypeKerning.d.ts +19 -0
- package/lib/font/readTrueTypeKerning.js +63 -0
- package/lib/font/readTrueTypeKerning.js.map +1 -0
- package/lib/font/readTrueTypeNames.d.ts +20 -0
- package/lib/font/readTrueTypeNames.js +75 -0
- package/lib/font/readTrueTypeNames.js.map +1 -0
- package/lib/humanoidSkeleton.d.ts +28 -15
- package/lib/humanoidSkeleton.js +28 -15
- package/lib/humanoidSkeleton.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/ingestDocument.d.ts +25 -12
- package/lib/ingestDocument.js +25 -12
- package/lib/ingestDocument.js.map +1 -1
- package/lib/inspectAutoMovieExternalModelBytes.d.ts +24 -12
- package/lib/inspectAutoMovieExternalModelBytes.js +24 -12
- package/lib/inspectAutoMovieExternalModelBytes.js.map +1 -1
- package/lib/internal/IAccessorSource.d.ts +11 -8
- package/lib/internal/IExternalModelAccessorReader.d.ts +1 -8
- package/lib/internal/IHumanoidSlot.d.ts +9 -10
- package/lib/internal/IParsedContainer.d.ts +10 -8
- package/lib/internal/SHAPE_COMPONENTS.d.ts +4 -1
- package/lib/internal/SHAPE_COMPONENTS.js +4 -1
- package/lib/internal/SHAPE_COMPONENTS.js.map +1 -1
- package/lib/internal/accessorElementByteLength.d.ts +1 -11
- package/lib/internal/accessorElementByteLength.js +1 -11
- package/lib/internal/accessorElementByteLength.js.map +1 -1
- package/lib/internal/accessorReader.d.ts +5 -9
- package/lib/internal/accessorReader.js +5 -9
- package/lib/internal/accessorReader.js.map +1 -1
- package/lib/internal/accessorValues.d.ts +10 -10
- package/lib/internal/accessorValues.js +10 -10
- package/lib/internal/collectExternalResources.d.ts +1 -11
- package/lib/internal/collectExternalResources.js +1 -11
- package/lib/internal/collectExternalResources.js.map +1 -1
- package/lib/internal/compareCodeUnits.d.ts +1 -11
- package/lib/internal/compareCodeUnits.js +1 -11
- package/lib/internal/compareCodeUnits.js.map +1 -1
- package/lib/internal/composeLocalTransform.d.ts +13 -10
- package/lib/internal/composeLocalTransform.js +13 -10
- package/lib/internal/composeLocalTransform.js.map +1 -1
- package/lib/internal/decodeDataUri.d.ts +4 -9
- package/lib/internal/decodeDataUri.js +4 -9
- package/lib/internal/decodeDataUri.js.map +1 -1
- package/lib/internal/decodeGlb.d.ts +1 -11
- package/lib/internal/decodeGlb.js +1 -11
- package/lib/internal/decodeGlb.js.map +1 -1
- package/lib/internal/decodeJson.d.ts +1 -11
- package/lib/internal/decodeJson.js +10 -12
- package/lib/internal/decodeJson.js.map +1 -1
- package/lib/internal/fileExtension.d.ts +2 -9
- package/lib/internal/fileExtension.js +2 -9
- package/lib/internal/fileExtension.js.map +1 -1
- package/lib/internal/finiteTuple.d.ts +4 -9
- package/lib/internal/finiteTuple.js +4 -9
- package/lib/internal/finiteTuple.js.map +1 -1
- package/lib/internal/gltfHumanoidBones.d.ts +5 -9
- package/lib/internal/gltfHumanoidBones.js +5 -9
- package/lib/internal/gltfHumanoidBones.js.map +1 -1
- package/lib/internal/humanoidBoneOfName.d.ts +7 -9
- package/lib/internal/humanoidBoneOfName.js +7 -9
- package/lib/internal/humanoidBoneOfName.js.map +1 -1
- package/lib/internal/inspectExternalModelHierarchy.d.ts +1 -11
- package/lib/internal/inspectExternalModelHierarchy.js +1 -11
- package/lib/internal/inspectExternalModelHierarchy.js.map +1 -1
- package/lib/internal/inspectExternalMotion.d.ts +8 -9
- package/lib/internal/inspectExternalMotion.js +8 -9
- package/lib/internal/inspectExternalMotion.js.map +1 -1
- package/lib/internal/inspectExternalMotionNodes.d.ts +6 -9
- package/lib/internal/inspectExternalMotionNodes.js +6 -9
- package/lib/internal/inspectExternalMotionNodes.js.map +1 -1
- package/lib/internal/integerIndex.d.ts +1 -11
- package/lib/internal/integerIndex.js +1 -11
- package/lib/internal/integerIndex.js.map +1 -1
- package/lib/internal/integerIndices.d.ts +1 -11
- package/lib/internal/integerIndices.js +1 -11
- package/lib/internal/integerIndices.js.map +1 -1
- package/lib/internal/nonNegativeInteger.d.ts +1 -11
- package/lib/internal/nonNegativeInteger.js +1 -11
- package/lib/internal/nonNegativeInteger.js.map +1 -1
- package/lib/internal/object.d.ts +1 -11
- package/lib/internal/object.js +1 -11
- package/lib/internal/object.js.map +1 -1
- package/lib/internal/optionalArray.d.ts +1 -11
- package/lib/internal/optionalArray.js +1 -11
- package/lib/internal/optionalArray.js.map +1 -1
- package/lib/internal/optionalObject.d.ts +1 -11
- package/lib/internal/optionalObject.js +1 -11
- package/lib/internal/optionalObject.js.map +1 -1
- package/lib/internal/optionalStringArray.d.ts +1 -11
- package/lib/internal/optionalStringArray.js +1 -11
- package/lib/internal/optionalStringArray.js.map +1 -1
- package/lib/internal/positiveInteger.d.ts +1 -11
- package/lib/internal/positiveInteger.js +1 -11
- package/lib/internal/positiveInteger.js.map +1 -1
- package/lib/internal/readMotionAccessor.d.ts +5 -9
- package/lib/internal/readMotionAccessor.js +5 -9
- package/lib/internal/readMotionAccessor.js.map +1 -1
- package/lib/internal/requiredArray.d.ts +1 -11
- package/lib/internal/requiredArray.js +1 -11
- package/lib/internal/requiredArray.js.map +1 -1
- package/lib/internal/uniqueStrings.d.ts +1 -11
- package/lib/internal/uniqueStrings.js +1 -11
- package/lib/internal/uniqueStrings.js.map +1 -1
- package/lib/internal/validNodeIndex.d.ts +1 -11
- package/lib/internal/validNodeIndex.js +1 -11
- package/lib/internal/validNodeIndex.js.map +1 -1
- package/lib/internal/validateAccessorRange.d.ts +6 -9
- package/lib/internal/validateAccessorRange.js +6 -9
- package/lib/internal/validateAccessorRange.js.map +1 -1
- package/lib/internal/validateHumanoidSkinning.d.ts +8 -10
- package/lib/internal/validateHumanoidSkinning.js +8 -10
- package/lib/internal/validateHumanoidSkinning.js.map +1 -1
- package/lib/internal/validatePayloadClosure.d.ts +8 -9
- package/lib/internal/validatePayloadClosure.js +8 -9
- package/lib/internal/validatePayloadClosure.js.map +1 -1
- package/lib/internal/validateSparseAccessor.d.ts +6 -9
- package/lib/internal/validateSparseAccessor.js +6 -9
- package/lib/internal/validateSparseAccessor.js.map +1 -1
- package/lib/internal/vrmHumanoidBones.d.ts +7 -9
- package/lib/internal/vrmHumanoidBones.js +12 -10
- package/lib/internal/vrmHumanoidBones.js.map +1 -1
- package/lib/isAutoMovieExternalModelIngestProfile.d.ts +4 -10
- package/lib/isAutoMovieExternalModelIngestProfile.js +4 -10
- package/lib/isAutoMovieExternalModelIngestProfile.js.map +1 -1
- package/package.json +7 -7
- package/src/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.ts +4 -1
- package/src/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.ts +4 -1
- package/src/adoptAutoMovieExternalMotion.ts +26 -12
- package/src/audio/admitProductionTtsReceipt.ts +262 -0
- package/src/audio/decodeProductionAudioAsset.ts +54 -39
- package/src/audio/index.ts +1 -0
- package/src/audio/resampleProductionAudio.ts +114 -0
- package/src/decodeAutoMoviePpmImage.ts +10 -18
- package/src/font/TrueTypeByteReader.ts +80 -0
- package/src/font/decodeAutoMovieTrueTypeFont.ts +217 -0
- package/src/font/index.ts +1 -0
- package/src/font/readTrueTypeCharacterMap.ts +115 -0
- package/src/font/readTrueTypeGlyphOutline.ts +375 -0
- package/src/font/readTrueTypeKerning.ts +73 -0
- package/src/font/readTrueTypeNames.ts +74 -0
- package/src/humanoidSkeleton.ts +28 -15
- package/src/index.ts +1 -0
- package/src/ingestDocument.ts +25 -12
- package/src/inspectAutoMovieExternalModelBytes.ts +24 -12
- package/src/internal/IAccessorSource.ts +11 -8
- package/src/internal/IExternalModelAccessorReader.ts +1 -8
- package/src/internal/IHumanoidSlot.ts +9 -10
- package/src/internal/IParsedContainer.ts +10 -8
- package/src/internal/SHAPE_COMPONENTS.ts +4 -1
- package/src/internal/accessorElementByteLength.ts +1 -11
- package/src/internal/accessorReader.ts +5 -9
- package/src/internal/accessorValues.ts +10 -10
- package/src/internal/collectExternalResources.ts +1 -11
- package/src/internal/compareCodeUnits.ts +1 -11
- package/src/internal/composeLocalTransform.ts +13 -10
- package/src/internal/decodeDataUri.ts +4 -9
- package/src/internal/decodeGlb.ts +1 -11
- package/src/internal/decodeJson.ts +10 -12
- package/src/internal/fileExtension.ts +2 -9
- package/src/internal/finiteTuple.ts +4 -9
- package/src/internal/gltfHumanoidBones.ts +5 -9
- package/src/internal/humanoidBoneOfName.ts +7 -9
- package/src/internal/inspectExternalModelHierarchy.ts +1 -11
- package/src/internal/inspectExternalMotion.ts +8 -9
- package/src/internal/inspectExternalMotionNodes.ts +6 -9
- package/src/internal/integerIndex.ts +1 -11
- package/src/internal/integerIndices.ts +1 -11
- package/src/internal/nonNegativeInteger.ts +1 -11
- package/src/internal/object.ts +1 -11
- package/src/internal/optionalArray.ts +1 -11
- package/src/internal/optionalObject.ts +1 -11
- package/src/internal/optionalStringArray.ts +1 -11
- package/src/internal/positiveInteger.ts +1 -11
- package/src/internal/readMotionAccessor.ts +5 -9
- package/src/internal/requiredArray.ts +1 -11
- package/src/internal/uniqueStrings.ts +1 -11
- package/src/internal/validNodeIndex.ts +1 -11
- package/src/internal/validateAccessorRange.ts +6 -9
- package/src/internal/validateHumanoidSkinning.ts +8 -10
- package/src/internal/validatePayloadClosure.ts +8 -9
- package/src/internal/validateSparseAccessor.ts +6 -9
- package/src/internal/vrmHumanoidBones.ts +12 -10
- package/src/isAutoMovieExternalModelIngestProfile.ts +4 -10
package/README.md
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
# @automovie/ingest
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Decode external media into AutoMovie data. Use it to inspect glTF, GLB or VRM assets, decode WAVE audio or read a P6 PPM image. Your application reads the files and passes in the bytes.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Start
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```bash
|
|
7
|
+
```powershell
|
|
10
8
|
npm install @automovie/ingest
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
import { decodeAutoMoviePpmImage } from "@automovie/ingest";
|
|
15
|
-
|
|
16
|
-
declare const bytes: Uint8Array;
|
|
17
|
-
|
|
18
|
-
const image = decodeAutoMoviePpmImage(bytes, {
|
|
19
|
-
maxPixels: 1920 * 1080,
|
|
20
|
-
maxHeaderBytes: 100,
|
|
21
|
-
transfer: "srgb",
|
|
22
|
-
});
|
|
23
|
-
// image.width, image.height and image.rgb8
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Entry points
|
|
27
|
-
|
|
28
|
-
| Export | Purpose |
|
|
11
|
+
| Entry | Use |
|
|
29
12
|
| --- | --- |
|
|
30
|
-
| `inspectAutoMovieExternalModelBytes` | Check
|
|
31
|
-
| `adoptAutoMovieExternalMotion` | Check
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `decodeAutoMoviePpmImage` | Decode one bounded P6 RGB8 image under an explicit `srgb`, `bt709` or `linear` convention |
|
|
35
|
-
|
|
36
|
-
Nothing is guessed or repaired. A defect such as an unknown attached bone, an unsupported WAVE layout or a truncated raster is refused with its cause.
|
|
13
|
+
| `inspectAutoMovieExternalModelBytes` | Check a model against a named asset profile |
|
|
14
|
+
| `adoptAutoMovieExternalMotion` | Check whether a motion take can be used or retargeted |
|
|
15
|
+
| `decodeProductionAudioAsset` | Decode WAVE audio into mono samples |
|
|
16
|
+
| `decodeAutoMoviePpmImage` | Decode P6 pixels under explicit size and transfer limits |
|
|
37
17
|
|
|
38
|
-
|
|
18
|
+
Each function's JSDoc lists supported formats and failure results. [API reference](https://samchon.github.io/automovie/api/).
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { AutoMovieGltfMotionInterpretationProfile } from "@automovie/interface";
|
|
2
2
|
/**
|
|
3
|
-
* Runtime identity of the fixed glTF motion spatial interpretation. This typed
|
|
3
|
+
* Runtime identity of the fixed glTF motion spatial interpretation. This typed
|
|
4
|
+
* literal defines metres, right-handed coordinates and Y-up without implicit
|
|
5
|
+
* conversion; inspection and adoption share it, and no geometry-validity claim
|
|
6
|
+
* follows from the label.
|
|
4
7
|
*/
|
|
5
8
|
export declare const AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE: AutoMovieGltfMotionInterpretationProfile;
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Runtime identity of the fixed glTF motion spatial interpretation. This typed
|
|
5
|
+
* Runtime identity of the fixed glTF motion spatial interpretation. This typed
|
|
6
|
+
* literal defines metres, right-handed coordinates and Y-up without implicit
|
|
7
|
+
* conversion; inspection and adoption share it, and no geometry-validity claim
|
|
8
|
+
* follows from the label.
|
|
6
9
|
*/
|
|
7
10
|
exports.AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE = "gltf-2.0-meter-right-handed-y-up";
|
|
8
11
|
//# sourceMappingURL=AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js","sourceRoot":"","sources":["../src/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.ts"],"names":[],"mappings":";;;AAEA
|
|
1
|
+
{"version":3,"file":"AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js","sourceRoot":"","sources":["../src/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACU,QAAA,4CAA4C,GACvD,kCAA2C,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { AutoMovieExternalModelIngestProfile } from "@automovie/interface";
|
|
2
2
|
/**
|
|
3
|
-
* Every supported ingest profile literal, frozen in declaration order. The
|
|
3
|
+
* Every supported ingest profile literal, frozen in declaration order. The
|
|
4
|
+
* complete Record over the closed union supplies exactly four own keys; the
|
|
5
|
+
* profile guard reuses this bounded module-lifetime inventory without deriving
|
|
6
|
+
* another list.
|
|
4
7
|
*/
|
|
5
8
|
export declare const AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES: readonly AutoMovieExternalModelIngestProfile[];
|
|
@@ -9,7 +9,10 @@ const INGEST_PROFILE_REGISTRY = {
|
|
|
9
9
|
"vrm-humanoid-v1": true,
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* Every supported ingest profile literal, frozen in declaration order. The
|
|
12
|
+
* Every supported ingest profile literal, frozen in declaration order. The
|
|
13
|
+
* complete Record over the closed union supplies exactly four own keys; the
|
|
14
|
+
* profile guard reuses this bounded module-lifetime inventory without deriving
|
|
15
|
+
* another list.
|
|
13
16
|
*/
|
|
14
17
|
exports.AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES = Object.freeze(Object.keys(INGEST_PROFILE_REGISTRY));
|
|
15
18
|
//# sourceMappingURL=AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js","sourceRoot":"","sources":["../src/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.ts"],"names":[],"mappings":";;;AAEA,8EAA8E;AAC9E,MAAM,uBAAuB,GAEzB;IACF,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;IACtB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js","sourceRoot":"","sources":["../src/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.ts"],"names":[],"mappings":";;;AAEA,8EAA8E;AAC9E,MAAM,uBAAuB,GAEzB;IACF,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;IACtB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEF;;;;;GAKG;AACU,QAAA,yCAAyC,GACpD,MAAM,CAAC,MAAM,CACX,MAAM,CAAC,IAAI,CACT,uBAAuB,CACiB,CAC3C,CAAC"}
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import type { IAutoMovieExternalMotionAdoptionReceipt } from "@automovie/interface";
|
|
2
2
|
/**
|
|
3
|
-
* Select one inspected take and validate the author's native or retarget
|
|
3
|
+
* Select one inspected take and validate the author's native or retarget
|
|
4
|
+
* decision without fetching bytes, choosing a provider or inferring a rig.
|
|
4
5
|
*
|
|
5
|
-
* The inspection must come from the `gltf-motion-v1` profile under the glTF
|
|
6
|
+
* The inspection must come from the `gltf-motion-v1` profile under the glTF
|
|
7
|
+
* meter, right-handed, Y-up interpretation, and the source must repeat its path
|
|
8
|
+
* and byte length with a lowercase SHA-256 digest. Every track of the selected
|
|
9
|
+
* take must target a mapped node, translation only on the node mapped to
|
|
10
|
+
* `hips`, and never scale or weights, because humanoid motion carries neither.
|
|
11
|
+
* Each mapped bone's parent and rest in the declared source rig must equal what
|
|
12
|
+
* the inspected hierarchy implies: the nearest mapped ancestor and the node's
|
|
13
|
+
* local TRS composed through every unmapped helper between them. The comparison
|
|
14
|
+
* is exact, so an author computes the rest from the inspected transforms rather
|
|
15
|
+
* than retyping rounded values. The first violation throws with the field it
|
|
16
|
+
* concerns.
|
|
6
17
|
*
|
|
7
|
-
* The caller supplies an unmodified inspector result and binds the digest to
|
|
18
|
+
* The caller supplies an unmodified inspector result and binds the digest to
|
|
19
|
+
* the resident bytes; adoption checks digest spelling, not a hash. Rig
|
|
20
|
+
* admission here requires a non-blank id, unique bone names and `hips`, but
|
|
21
|
+
* basis comparisons cover only mapped bones and do not validate constraints or
|
|
22
|
+
* unmapped rests. Helper TRS composition follows fixed floating-point
|
|
23
|
+
* arithmetic and drops shear when a helper's non-uniform scale does not commute
|
|
24
|
+
* with a child rotation; exact agreement proves agreement with that
|
|
25
|
+
* representation, not exact affine geometry.
|
|
8
26
|
*
|
|
9
27
|
* @param props.inspection Inspection of the exact source bytes.
|
|
10
28
|
* @param props.source Manifest identity of those bytes.
|
|
11
29
|
* @param props.decision The author's use of one take.
|
|
12
30
|
* @returns A receipt that shares no objects with its inputs.
|
|
13
|
-
*
|
|
14
|
-
* @evidence contracts/development/implementation.md#principled-implementation Path and byte length compare with caller-supplied inspected facts, while the digest is checked only for spelling. Sets establish mapping uniqueness, and each mapped basis is recomputed by nearest-mapped-ancestor walks, which refuse an ancestor met twice so an edited inspection's parent cycle throws instead of looping, and fixed-order `composeLocalTransform` arithmetic; binary64 rounding and discarded shear remain, and constraints and unmapped rests receive no basis check.
|
|
15
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure Identity/selection, rig binding and retarget-only fields have separate local owners; humanoid import shares transform composition and the engine validation owner supplies the common SHA-256 spelling predicate.
|
|
16
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No take, rig, bone or path is special-cased; the runtime mode check exists for untyped callers, and the digest regular expression is the manifest's documented `sha256:` format rather than a fixture value.
|
|
17
|
-
* @evidence contracts/development/common.md#meaningful-documentation The documentation distinguishes digest spelling from byte authentication, mapped-basis checks from complete rig admission, and exact arithmetic agreement from affine exactness; it also gives supported channels, first-refusal behavior and ownership of receipt copies.
|
|
18
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms Copy cost follows the selected take's tracks/keyframes and source-rig size; hash-map setup follows the mapping and node counts. Mapping size M adds O(M log M) prefix-scanning node-id comparisons plus text-dependent identity/hash work; mapped bones times helper-chain lengths drive basis walks, and take lookup scans the declared take inventory without an assumed population bound.
|
|
19
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Adoption validates one decision against one inspection per call and shares no work across calls; the inspection it reads is already the caller's reused result.
|
|
20
|
-
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The temporary maps and sets die with the call; the receipt retains copies of the take, rig and mapping proportional to their size and is owned by the caller, with no handle or task.
|
|
21
31
|
*/
|
|
22
32
|
export declare const adoptAutoMovieExternalMotion: (props: IAutoMovieExternalMotionAdoptionReceipt.IProps) => IAutoMovieExternalMotionAdoptionReceipt;
|
|
@@ -6,24 +6,34 @@ const AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE_1 = require("./AUTOMOVIE_GLTF
|
|
|
6
6
|
const compareCodeUnits_1 = require("./internal/compareCodeUnits");
|
|
7
7
|
const composeLocalTransform_1 = require("./internal/composeLocalTransform");
|
|
8
8
|
/**
|
|
9
|
-
* Select one inspected take and validate the author's native or retarget
|
|
9
|
+
* Select one inspected take and validate the author's native or retarget
|
|
10
|
+
* decision without fetching bytes, choosing a provider or inferring a rig.
|
|
10
11
|
*
|
|
11
|
-
* The inspection must come from the `gltf-motion-v1` profile under the glTF
|
|
12
|
+
* The inspection must come from the `gltf-motion-v1` profile under the glTF
|
|
13
|
+
* meter, right-handed, Y-up interpretation, and the source must repeat its path
|
|
14
|
+
* and byte length with a lowercase SHA-256 digest. Every track of the selected
|
|
15
|
+
* take must target a mapped node, translation only on the node mapped to
|
|
16
|
+
* `hips`, and never scale or weights, because humanoid motion carries neither.
|
|
17
|
+
* Each mapped bone's parent and rest in the declared source rig must equal what
|
|
18
|
+
* the inspected hierarchy implies: the nearest mapped ancestor and the node's
|
|
19
|
+
* local TRS composed through every unmapped helper between them. The comparison
|
|
20
|
+
* is exact, so an author computes the rest from the inspected transforms rather
|
|
21
|
+
* than retyping rounded values. The first violation throws with the field it
|
|
22
|
+
* concerns.
|
|
12
23
|
*
|
|
13
|
-
* The caller supplies an unmodified inspector result and binds the digest to
|
|
24
|
+
* The caller supplies an unmodified inspector result and binds the digest to
|
|
25
|
+
* the resident bytes; adoption checks digest spelling, not a hash. Rig
|
|
26
|
+
* admission here requires a non-blank id, unique bone names and `hips`, but
|
|
27
|
+
* basis comparisons cover only mapped bones and do not validate constraints or
|
|
28
|
+
* unmapped rests. Helper TRS composition follows fixed floating-point
|
|
29
|
+
* arithmetic and drops shear when a helper's non-uniform scale does not commute
|
|
30
|
+
* with a child rotation; exact agreement proves agreement with that
|
|
31
|
+
* representation, not exact affine geometry.
|
|
14
32
|
*
|
|
15
33
|
* @param props.inspection Inspection of the exact source bytes.
|
|
16
34
|
* @param props.source Manifest identity of those bytes.
|
|
17
35
|
* @param props.decision The author's use of one take.
|
|
18
36
|
* @returns A receipt that shares no objects with its inputs.
|
|
19
|
-
*
|
|
20
|
-
* @evidence contracts/development/implementation.md#principled-implementation Path and byte length compare with caller-supplied inspected facts, while the digest is checked only for spelling. Sets establish mapping uniqueness, and each mapped basis is recomputed by nearest-mapped-ancestor walks, which refuse an ancestor met twice so an edited inspection's parent cycle throws instead of looping, and fixed-order `composeLocalTransform` arithmetic; binary64 rounding and discarded shear remain, and constraints and unmapped rests receive no basis check.
|
|
21
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure Identity/selection, rig binding and retarget-only fields have separate local owners; humanoid import shares transform composition and the engine validation owner supplies the common SHA-256 spelling predicate.
|
|
22
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No take, rig, bone or path is special-cased; the runtime mode check exists for untyped callers, and the digest regular expression is the manifest's documented `sha256:` format rather than a fixture value.
|
|
23
|
-
* @evidence contracts/development/common.md#meaningful-documentation The documentation distinguishes digest spelling from byte authentication, mapped-basis checks from complete rig admission, and exact arithmetic agreement from affine exactness; it also gives supported channels, first-refusal behavior and ownership of receipt copies.
|
|
24
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms Copy cost follows the selected take's tracks/keyframes and source-rig size; hash-map setup follows the mapping and node counts. Mapping size M adds O(M log M) prefix-scanning node-id comparisons plus text-dependent identity/hash work; mapped bones times helper-chain lengths drive basis walks, and take lookup scans the declared take inventory without an assumed population bound.
|
|
25
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Adoption validates one decision against one inspection per call and shares no work across calls; the inspection it reads is already the caller's reused result.
|
|
26
|
-
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The temporary maps and sets die with the call; the receipt retains copies of the take, rig and mapping proportional to their size and is owned by the caller, with no handle or task.
|
|
27
37
|
*/
|
|
28
38
|
const adoptAutoMovieExternalMotion = (props) => {
|
|
29
39
|
if (props.inspection.profile !== "gltf-motion-v1")
|
|
@@ -132,7 +142,11 @@ const validateMotionBinding = (props) => {
|
|
|
132
142
|
.sort((left, right) => (0, compareCodeUnits_1.compareCodeUnits)(left.node, right.node)),
|
|
133
143
|
};
|
|
134
144
|
};
|
|
135
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* The parent and rest a mapped node implies: walk to the nearest mapped
|
|
147
|
+
* ancestor, then fold every unmapped helper's TRS into the node's own, nearest
|
|
148
|
+
* helper first. A node without a mapped ancestor keeps its local TRS.
|
|
149
|
+
*/
|
|
136
150
|
const inspectedBoneBasis = (node, nodes, nodeToBone) => {
|
|
137
151
|
const helpers = [];
|
|
138
152
|
// An inspector's hierarchy is an acyclic forest, so the walk meets each
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adoptAutoMovieExternalMotion.js","sourceRoot":"","sources":["../src/adoptAutoMovieExternalMotion.ts"],"names":[],"mappings":";;;AAAA,8CAA0D;AAmB1D,iHAA8G;AAC9G,k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AAE,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;gBACpC,SAAS,EACP,IAAI,CAAC,UAAU,CAAC,SAAS,KAAK,IAAI;oBAChC,CAAC,CAAC,IAAI;oBACN,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;gBACtC,KAAK,EACH,IAAI,CAAC,UAAU,CAAC,KAAK,KAAK,IAAI;oBAC5B,CAAC,CAAC,IAAI;oBACN,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;aACnC;KACR,CAAC,CACH;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IAutoMovieAdmitProductionTtsReceipt } from "@automovie/interface";
|
|
2
|
+
/**
|
|
3
|
+
* Admit one generated line's receipt against its line and its bytes, and decode
|
|
4
|
+
* the line at the requested rate.
|
|
5
|
+
*
|
|
6
|
+
* The receipt is parsed as UTF-8 JSON and must be a version 7 receipt whose
|
|
7
|
+
* required fields carry their declared types. It is refused, naming the field,
|
|
8
|
+
* when its `line` or `text` differs from the line; when the WAVE file is not
|
|
9
|
+
* mono 32-bit IEEE float at `sourceSampleRate`; when `sourceSamples` differs
|
|
10
|
+
* from the file's sample count; when `pcmDigest` differs from the SHA-256 of
|
|
11
|
+
* the file's samples as little-endian Float32 bytes; when a phoneme chunk is
|
|
12
|
+
* empty, leaves `[0, sourceSamples]`, or overlaps or precedes the previous
|
|
13
|
+
* chunk; and when `cacheKey` differs from the digest recomputed from `text`,
|
|
14
|
+
* `model`, `modelRevision`, `conditioning` and `inferenceArguments`. Refusals
|
|
15
|
+
* throw `Dialogue receipt "<path>" [<field>] <message>`; WAVE container
|
|
16
|
+
* refusals keep the decoder's own form.
|
|
17
|
+
*
|
|
18
|
+
* Ingest owns this admission because it reads external media bytes, and engine,
|
|
19
|
+
* which ingest depends on, cannot call it.
|
|
20
|
+
*
|
|
21
|
+
* @param props The line, its WAVE and receipt bytes with their paths, and the
|
|
22
|
+
* output rate.
|
|
23
|
+
* @returns The admitted receipt and the line's samples at `props.sampleRate`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function admitProductionTtsReceipt(props: IAutoMovieAdmitProductionTtsReceipt.IProps): IAutoMovieAdmitProductionTtsReceipt.IResult;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.admitProductionTtsReceipt = admitProductionTtsReceipt;
|
|
4
|
+
const engine_1 = require("@automovie/engine");
|
|
5
|
+
const decodeProductionAudioAsset_1 = require("./decodeProductionAudioAsset");
|
|
6
|
+
const resampleProductionAudio_1 = require("./resampleProductionAudio");
|
|
7
|
+
/**
|
|
8
|
+
* Admit one generated line's receipt against its line and its bytes, and decode
|
|
9
|
+
* the line at the requested rate.
|
|
10
|
+
*
|
|
11
|
+
* The receipt is parsed as UTF-8 JSON and must be a version 7 receipt whose
|
|
12
|
+
* required fields carry their declared types. It is refused, naming the field,
|
|
13
|
+
* when its `line` or `text` differs from the line; when the WAVE file is not
|
|
14
|
+
* mono 32-bit IEEE float at `sourceSampleRate`; when `sourceSamples` differs
|
|
15
|
+
* from the file's sample count; when `pcmDigest` differs from the SHA-256 of
|
|
16
|
+
* the file's samples as little-endian Float32 bytes; when a phoneme chunk is
|
|
17
|
+
* empty, leaves `[0, sourceSamples]`, or overlaps or precedes the previous
|
|
18
|
+
* chunk; and when `cacheKey` differs from the digest recomputed from `text`,
|
|
19
|
+
* `model`, `modelRevision`, `conditioning` and `inferenceArguments`. Refusals
|
|
20
|
+
* throw `Dialogue receipt "<path>" [<field>] <message>`; WAVE container
|
|
21
|
+
* refusals keep the decoder's own form.
|
|
22
|
+
*
|
|
23
|
+
* Ingest owns this admission because it reads external media bytes, and engine,
|
|
24
|
+
* which ingest depends on, cannot call it.
|
|
25
|
+
*
|
|
26
|
+
* @param props The line, its WAVE and receipt bytes with their paths, and the
|
|
27
|
+
* output rate.
|
|
28
|
+
* @returns The admitted receipt and the line's samples at `props.sampleRate`.
|
|
29
|
+
*/
|
|
30
|
+
function admitProductionTtsReceipt(props) {
|
|
31
|
+
const fail = (field, message) => {
|
|
32
|
+
throw new Error(`Dialogue receipt "${props.receiptPath}" [${field}] ${message}`);
|
|
33
|
+
};
|
|
34
|
+
const receipt = parseReceipt(props.receipt, fail);
|
|
35
|
+
if (receipt.line !== props.line.id)
|
|
36
|
+
fail("line", `belongs to line "${receipt.line}", not to line "${props.line.id}".`);
|
|
37
|
+
if (receipt.text !== props.line.text)
|
|
38
|
+
fail("text", `records the text ${JSON.stringify(receipt.text)}, but line "${props.line.id}" says ${JSON.stringify(props.line.text)}.`);
|
|
39
|
+
// The file is decoded at its own rate, so the samples read are its bytes.
|
|
40
|
+
const native = (0, decodeProductionAudioAsset_1.decodeProductionAudioAsset)({
|
|
41
|
+
path: props.pcmPath,
|
|
42
|
+
bytes: props.pcm,
|
|
43
|
+
sampleRate: receipt.sourceSampleRate,
|
|
44
|
+
});
|
|
45
|
+
if (native.sourceFormat.encoding !== "float-f32le" ||
|
|
46
|
+
native.sourceChannels !== 1 ||
|
|
47
|
+
native.sourceSampleRate !== receipt.sourceSampleRate)
|
|
48
|
+
fail("sourceSampleRate", `requires "${props.pcmPath}" to be mono 32-bit float at ${receipt.sourceSampleRate} Hz, but it is ${native.sourceChannels}-channel ${native.sourceFormat.encoding} at ${native.sourceSampleRate} Hz.`);
|
|
49
|
+
if (native.sourceFrames !== receipt.sourceSamples)
|
|
50
|
+
fail("sourceSamples", `records ${receipt.sourceSamples} samples, but "${props.pcmPath}" holds ${native.sourceFrames}.`);
|
|
51
|
+
const bytes = new Uint8Array(native.samples.length * 4);
|
|
52
|
+
const view = new DataView(bytes.buffer);
|
|
53
|
+
native.samples.forEach((sample, index) => view.setFloat32(index * 4, sample, true));
|
|
54
|
+
const digest = (0, engine_1.digestAutoMovieBytes)(bytes);
|
|
55
|
+
if (digest !== receipt.pcmDigest)
|
|
56
|
+
fail("pcmDigest", `records ${receipt.pcmDigest}, but the samples of "${props.pcmPath}" digest to ${digest}.`);
|
|
57
|
+
let previousEnd = 0;
|
|
58
|
+
receipt.phonemeChunks?.forEach((chunk, index) => {
|
|
59
|
+
if (Number.isSafeInteger(chunk.startSample) === false ||
|
|
60
|
+
Number.isSafeInteger(chunk.endSample) === false ||
|
|
61
|
+
chunk.startSample < previousEnd ||
|
|
62
|
+
chunk.endSample <= chunk.startSample ||
|
|
63
|
+
chunk.endSample > receipt.sourceSamples ||
|
|
64
|
+
chunk.phonemes.trim().length === 0)
|
|
65
|
+
fail(`phonemeChunks[${index}]`, `spans samples ${chunk.startSample} to ${chunk.endSample} with phonemes ${JSON.stringify(chunk.phonemes)}; a chunk carries phonemes over a nonempty interval inside [0, ${receipt.sourceSamples}] that starts at or after the previous chunk's end ${previousEnd}.`);
|
|
66
|
+
previousEnd = chunk.endSample;
|
|
67
|
+
});
|
|
68
|
+
const cacheKey = (0, engine_1.autoMovieRenderDigest)((0, engine_1.canonicalizeAutoMovieJson)([
|
|
69
|
+
receipt.text,
|
|
70
|
+
receipt.model,
|
|
71
|
+
receipt.modelRevision,
|
|
72
|
+
receipt.conditioning,
|
|
73
|
+
receipt.inferenceArguments,
|
|
74
|
+
]));
|
|
75
|
+
if (cacheKey !== receipt.cacheKey)
|
|
76
|
+
fail("cacheKey", `records ${receipt.cacheKey}, but its request recomputes to ${cacheKey}.`);
|
|
77
|
+
const resampling = receipt.sourceSampleRate !== props.sampleRate;
|
|
78
|
+
return {
|
|
79
|
+
receipt,
|
|
80
|
+
audio: {
|
|
81
|
+
...native,
|
|
82
|
+
processing: {
|
|
83
|
+
...native.processing,
|
|
84
|
+
kind: resampling ? "resample" : "copy",
|
|
85
|
+
outputSampleRate: props.sampleRate,
|
|
86
|
+
},
|
|
87
|
+
samples: resampling
|
|
88
|
+
? (0, resampleProductionAudio_1.resampleProductionAudio)(native.samples, receipt.sourceSampleRate, props.sampleRate)
|
|
89
|
+
: native.samples,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parse the receipt bytes and check the type of every field admission reads or
|
|
95
|
+
* the receipt requires.
|
|
96
|
+
*/
|
|
97
|
+
const parseReceipt = (bytes, fail) => {
|
|
98
|
+
let value;
|
|
99
|
+
try {
|
|
100
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
101
|
+
}
|
|
102
|
+
catch (cause) {
|
|
103
|
+
return fail("json", `is not UTF-8 JSON: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
104
|
+
}
|
|
105
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
106
|
+
return fail("json", "is not a JSON object.");
|
|
107
|
+
const record = value;
|
|
108
|
+
if (record.version !== 7)
|
|
109
|
+
fail("version", `is version ${JSON.stringify(record.version)}; only version 7 receipts are admitted, and an older receipt lacks the text and inference arguments its line needs, so record the line again.`);
|
|
110
|
+
for (const field of [
|
|
111
|
+
"line",
|
|
112
|
+
"text",
|
|
113
|
+
"cacheKey",
|
|
114
|
+
"model",
|
|
115
|
+
"modelRevision",
|
|
116
|
+
"generatedAt",
|
|
117
|
+
"pcmDigest",
|
|
118
|
+
])
|
|
119
|
+
if (typeof record[field] !== "string" || record[field] === "")
|
|
120
|
+
fail(field, "must be a nonempty string.");
|
|
121
|
+
for (const field of ["sourceSampleRate", "sourceSamples"]) {
|
|
122
|
+
const count = record[field];
|
|
123
|
+
if (typeof count !== "number" || !Number.isSafeInteger(count) || count <= 0)
|
|
124
|
+
fail(field, "must be a positive safe integer.");
|
|
125
|
+
}
|
|
126
|
+
const conditioning = record.conditioning;
|
|
127
|
+
const mode = typeof conditioning === "object" && conditioning !== null
|
|
128
|
+
? conditioning.mode
|
|
129
|
+
: undefined;
|
|
130
|
+
const voice = mode === "voice"
|
|
131
|
+
? conditioning.voice
|
|
132
|
+
: mode === "reference-audio"
|
|
133
|
+
? conditioning.referenceDigest
|
|
134
|
+
: undefined;
|
|
135
|
+
if (typeof voice !== "string" || voice === "")
|
|
136
|
+
fail("conditioning", 'must be { mode: "voice", voice } or { mode: "reference-audio", referenceDigest } with a nonempty string.');
|
|
137
|
+
const argumentsRecord = record.inferenceArguments;
|
|
138
|
+
if (typeof argumentsRecord !== "object" ||
|
|
139
|
+
argumentsRecord === null ||
|
|
140
|
+
Array.isArray(argumentsRecord) ||
|
|
141
|
+
Object.values(argumentsRecord).some((argument) => typeof argument !== "string" &&
|
|
142
|
+
typeof argument !== "boolean" &&
|
|
143
|
+
(typeof argument !== "number" || Number.isFinite(argument) === false)))
|
|
144
|
+
fail("inferenceArguments", "must be an object of string, finite number and boolean values.");
|
|
145
|
+
if (typeof record.generatorProvenance !== "object" ||
|
|
146
|
+
record.generatorProvenance === null)
|
|
147
|
+
fail("generatorProvenance", "must be an object.");
|
|
148
|
+
if (Array.isArray(record.runtimeAssets) === false)
|
|
149
|
+
fail("runtimeAssets", "must be an array.");
|
|
150
|
+
if (record.phonemeChunks !== undefined &&
|
|
151
|
+
(Array.isArray(record.phonemeChunks) === false ||
|
|
152
|
+
record.phonemeChunks.some((chunk) => typeof chunk !== "object" ||
|
|
153
|
+
chunk === null ||
|
|
154
|
+
typeof chunk.phonemes !== "string")))
|
|
155
|
+
fail("phonemeChunks", "must be an array of { phonemes, startSample, endSample } records.");
|
|
156
|
+
const aligner = record.aligner;
|
|
157
|
+
if (aligner !== undefined &&
|
|
158
|
+
(typeof aligner !== "object" ||
|
|
159
|
+
aligner === null ||
|
|
160
|
+
typeof aligner.model !== "string" ||
|
|
161
|
+
typeof aligner.revision !== "string"))
|
|
162
|
+
fail("aligner", "must be { model, revision } with string values.");
|
|
163
|
+
// Every field read above has its declared type, so the record is the receipt.
|
|
164
|
+
return record;
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=admitProductionTtsReceipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admitProductionTtsRece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B,EAAE,oBAAoB,CAAC,CAAC;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,KAAK;QAC/C,IAAI,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;IAC7C,IACE,MAAM,CAAC,aAAa,KAAK,SAAS;QAClC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,KAAK;YAC5C,MAAM,CAAC,aAAa,CAAC,IAAI,CACvB,CAAC,KAAc,EAAW,EAAE,CAC1B,OAAO,KAAK,KAAK,QAAQ;gBACzB,KAAK,KAAK,IAAI;gBACd,OAAQ,KAAiC,CAAC,QAAQ,KAAK,QAAQ,CAClE,CAAC;QAEJ,IAAI,CACF,eAAe,EACf,mEAAmE,CACpE,CAAC;IACJ,MAAM,OAAO,GAAY,MAAM,CAAC,OAAO,CAAC;IACxC,IACE,OAAO,KAAK,SAAS;QACrB,CAAC,OAAO,OAAO,KAAK,QAAQ;YAC1B,OAAO,KAAK,IAAI;YAChB,OAAQ,OAAmC,CAAC,KAAK,KAAK,QAAQ;YAC9D,OAAQ,OAAmC,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAEpE,IAAI,CAAC,SAAS,EAAE,iDAAiD,CAAC,CAAC;IAErE,8EAA8E;IAC9E,OAAO,MAAmD,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
import type { IAutoMovieDecodedProductionAudioAsset } from "@automovie/interface";
|
|
2
2
|
/**
|
|
3
|
-
* Decode one complete supported RIFF/WAVE file into finite mono samples at a
|
|
3
|
+
* Decode one complete supported RIFF/WAVE file into finite mono samples at a
|
|
4
|
+
* requested rate.
|
|
4
5
|
*
|
|
5
|
-
* The parser walks the RIFF chunks by id, requires the declared RIFF extent,
|
|
6
|
+
* The parser walks the RIFF chunks by id, requires the declared RIFF extent,
|
|
7
|
+
* `nBlockAlign`, and `nAvgBytesPerSec` to agree with the format fields, and
|
|
8
|
+
* refuses a duplicate `fmt ` or `data` chunk, an odd chunk without its pad
|
|
9
|
+
* byte, and terminal bytes too short for a chunk header. An extensible header
|
|
10
|
+
* follows the Microsoft WAVEFORMATEXTENSIBLE contract
|
|
11
|
+
* (https://learn.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-waveformatextensible):
|
|
12
|
+
* "The cbSize member must be at least 22", `wValidBitsPerSample` "can be any
|
|
13
|
+
* value not exceeding the container size", "the channels specified in
|
|
14
|
+
* dwChannelMask must be present in the prescribed order (from least significant
|
|
15
|
+
* bit up)" with SPEAKER_FRONT_LEFT `0x1`, SPEAKER_FRONT_RIGHT `0x2`, and
|
|
16
|
+
* SPEAKER_FRONT_CENTER `0x4`, and "the number of bits set in dwChannelMask
|
|
17
|
+
* should be the same as the number of channels". The SubFormat is admitted only
|
|
18
|
+
* when every byte after its leading 16-bit tag equals the
|
|
19
|
+
* `xxxxxxxx-0000-0010-8000-00aa00389b71` template that Ksmedia.h's
|
|
20
|
+
* `IS_VALID_WAVEFORMATEX_GUID` compares
|
|
21
|
+
* (https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/converting-between-format-tags-and-subformat-guids),
|
|
22
|
+
* so a vendor GUID whose low word happens to read as PCM is not decoded as
|
|
23
|
+
* PCM.
|
|
6
24
|
*
|
|
7
|
-
* The supported subset is deliberately narrow: 16-bit PCM in a 16-bit
|
|
25
|
+
* The supported subset is deliberately narrow: 16-bit PCM in a 16-bit
|
|
26
|
+
* container, 32-bit IEEE float in a 32-bit container, mono front-center, and
|
|
27
|
+
* stereo front-left/front-right. A legal declaration outside it, such as 20
|
|
28
|
+
* valid bits in a 24-bit container or a front-left/front-center pair, is
|
|
29
|
+
* refused as unsupported by field rather than misread as the nearest supported
|
|
30
|
+
* layout. Every decoded sample is checked finite before the mono fold and
|
|
31
|
+
* before any resampling, so a NaN or infinity in one channel refuses the whole
|
|
32
|
+
* asset at its frame and channel instead of averaging into a plausible number.
|
|
8
33
|
*
|
|
9
|
-
* PCM codes scale by 1/32768, so -32768 reads as exactly -1 and 32767 just
|
|
34
|
+
* PCM codes scale by 1/32768, so -32768 reads as exactly -1 and 32767 just
|
|
35
|
+
* under 1. Stereo folds to the mean of its two channels. A source at another
|
|
36
|
+
* rate is converted by band-limited windowed-sinc interpolation with fixed
|
|
37
|
+
* coefficients (`resampleProductionAudio`, after Smith and Gossett, ICASSP
|
|
38
|
+
* 1984) to `round(frames * rate / sourceRate)` samples, which may round to zero
|
|
39
|
+
* for a short source and a low target rate; its low-pass leaves no images when
|
|
40
|
+
* upsampling and folds no alias when downsampling.
|
|
10
41
|
*
|
|
11
|
-
* Field admission refusals throw `Audio asset "<path>" [<reason>] <message>`,
|
|
42
|
+
* Field admission refusals throw `Audio asset "<path>" [<reason>] <message>`,
|
|
43
|
+
* where the reason names the field, such as `riff-size`, `block-align`, or
|
|
44
|
+
* `unsupported-wave-layout`. Buffer size follows source frames and the
|
|
45
|
+
* requested rate ratio; this function imposes no product memory budget, so
|
|
46
|
+
* platform allocation errors may propagate outside that refusal format.
|
|
12
47
|
*
|
|
13
48
|
* @param props.path Asset path, used only in refusal messages.
|
|
14
49
|
* @param props.bytes Complete file bytes; they are only read.
|
|
15
|
-
* @param props.sampleRate Output rate in samples per second; a positive safe
|
|
50
|
+
* @param props.sampleRate Output rate in samples per second; a positive safe
|
|
51
|
+
* integer.
|
|
16
52
|
* @returns The source facts as declared and new mono samples the caller owns.
|
|
17
|
-
*
|
|
18
|
-
* @evidence contracts/development/implementation.md#principled-implementation Chunks are found by id in RIFF order with the even-byte pad rule, the format fields are checked against WAVEFORMATEXTENSIBLE's own consistency rules and the KSDATAFORMAT GUID template, samples scale by 1/32768 or read as IEEE floats, and resampling is two-tap linear interpolation; that interpolation has no anti-alias filter, which the documentation states as the remaining limitation when a source is downsampled.
|
|
19
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure One linear pass validates the container, a second folds frames to mono, and a third resamples only when the rates differ; private refusal, chunk and hex helpers keep WAVE parsing local, while production speech probes consume the public decoder's format facts and mono samples.
|
|
20
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No file, path or rate is special-cased: every unsupported declaration throws with a field-named reason instead of decoding as the nearest supported layout, and the only constants are the WAVE format tags, speaker masks and GUID tail the Microsoft contract defines.
|
|
21
|
-
* @evidence contracts/development/common.md#meaningful-documentation The documentation cites the WAVEFORMATEXTENSIBLE rules it enforces, lists the supported subset, gives the PCM scale, stereo fold, resampled length and aliasing limitation, and states the refusal message shape and parameter units.
|
|
22
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms Time follows RIFF chunk headers, source frames times channels and output samples; storage follows source and output frames, each encoded sample is read once through one DataView, and the mono buffer becomes the result when rates match.
|
|
23
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work The decoder is a pure function of one call's bytes and rate and coordinates no work across requests; any caching of decoded assets would belong to its caller.
|
|
24
|
-
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The call owns source-frame mono storage and, on resampling, rate-ratio-sized output storage; no product memory budget bounds a requested allocation. Temporary buffers become collectable on return/throw, the returned buffer transfers to its caller, and no raw bytes, handles or tasks are retained.
|
|
25
53
|
*/
|
|
26
54
|
export declare const decodeProductionAudioAsset: (props: IAutoMovieDecodedProductionAudioAsset.IProps) => IAutoMovieDecodedProductionAudioAsset;
|