@effetune/dsp 0.1.0 → 0.5.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 +106 -5
- package/dist/assets/effetune-dsp.meta.json +491 -7
- package/dist/assets/effetune-dsp.simd.wasm +0 -0
- package/dist/assets/effetune-dsp.wasm +0 -0
- package/dist/catalog/effects-v1.json +1778 -242
- package/dist/errors.js +21 -0
- package/dist/generated-effects.d.ts +317 -1
- package/dist/generated-effects.js +185 -3
- package/dist/generated-graph-contract.js +8 -0
- package/dist/graph-document.js +644 -0
- package/dist/graph-engine.js +493 -0
- package/dist/graph.js +467 -0
- package/dist/index.d.ts +268 -1
- package/dist/index.js +36 -0
- package/dist/internal/dsp-engine-binding.js +162 -1
- package/dist/internal/dsp-params.generated.js +537 -70
- package/dist/internal/dsp-wasm-loader.js +2 -0
- package/dist/preset.js +29 -0
- package/dist/runtime.js +73 -5
- package/dist/schemas/chain-v1.schema.json +1740 -167
- package/dist/schemas/graph-v1.schema.json +8208 -0
- package/dist/semantics.js +88 -30
- package/dist/worklet-processor.js +8 -1
- package/dist/worklet.d.ts +1 -0
- package/dist/worklet.js +15 -0
- package/package.json +2 -1
|
@@ -27,6 +27,7 @@ const REQUIRED_FUNCTION_EXPORTS = [
|
|
|
27
27
|
'et_instance_asset_abort',
|
|
28
28
|
'et_instance_asset_state',
|
|
29
29
|
'et_instance_process',
|
|
30
|
+
'et_instance_runtime_event',
|
|
30
31
|
'et_arena_combined_ptr',
|
|
31
32
|
'et_arena_bus_ptr',
|
|
32
33
|
'et_arena_scratch_ptr',
|
|
@@ -35,6 +36,7 @@ const REQUIRED_FUNCTION_EXPORTS = [
|
|
|
35
36
|
'et_telemetry_capacity',
|
|
36
37
|
'et_telemetry_read',
|
|
37
38
|
'et_pipeline_configure',
|
|
39
|
+
'et_pipeline_latency',
|
|
38
40
|
'et_pipeline_process'
|
|
39
41
|
];
|
|
40
42
|
|
|
@@ -552,6 +554,25 @@ export class DspEngineBinding {
|
|
|
552
554
|
);
|
|
553
555
|
}
|
|
554
556
|
|
|
557
|
+
instanceRuntimeEvent(instanceId) {
|
|
558
|
+
if (!this.engine || !this.prepared) return null;
|
|
559
|
+
const ptr = this.exports.et_scratch_ptr(this.engine) >>> 0;
|
|
560
|
+
this._refreshViews();
|
|
561
|
+
this._assertRange(ptr, 12, 'Runtime event state');
|
|
562
|
+
if (this.exports.et_instance_runtime_event(
|
|
563
|
+
this.engine,
|
|
564
|
+
instanceId,
|
|
565
|
+
ptr
|
|
566
|
+
) !== ET_OK) {
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
return {
|
|
570
|
+
generation: this.dataView.getUint32(ptr, true),
|
|
571
|
+
latched: this.dataView.getUint32(ptr + 4, true) !== 0,
|
|
572
|
+
cause: this.dataView.getUint32(ptr + 8, true)
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
|
|
555
576
|
instanceSetParamBytes(instanceId, packed, paramsHash, offsetFrames = 0) {
|
|
556
577
|
if (!this.engine || !this.prepared) return ET_ERR_STATE;
|
|
557
578
|
const values = toUint8View(packed, 'Structured parameter block');
|
|
@@ -791,7 +812,21 @@ export class DspEngineBinding {
|
|
|
791
812
|
this._refreshViews();
|
|
792
813
|
this._assertRange(ptr, bytes.byteLength, 'Pipeline descriptor');
|
|
793
814
|
this.u8.set(bytes, ptr);
|
|
794
|
-
|
|
815
|
+
this._preparing = true;
|
|
816
|
+
let status = ET_ERR_STATE;
|
|
817
|
+
try {
|
|
818
|
+
status = this.exports.et_pipeline_configure(this.engine, ptr, bytes.byteLength);
|
|
819
|
+
} finally {
|
|
820
|
+
this._refreshViews();
|
|
821
|
+
this._preparing = false;
|
|
822
|
+
}
|
|
823
|
+
this.getArenaViews();
|
|
824
|
+
return status;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
pipelineLatency() {
|
|
828
|
+
if (!this.engine) return 0;
|
|
829
|
+
return this.exports.et_pipeline_latency(this.engine) >>> 0;
|
|
795
830
|
}
|
|
796
831
|
|
|
797
832
|
pipelineProcess(channelCount, frameCount, timeSeconds, masterBypass = false) {
|
|
@@ -806,6 +841,132 @@ export class DspEngineBinding {
|
|
|
806
841
|
);
|
|
807
842
|
}
|
|
808
843
|
|
|
844
|
+
graphCapabilities() {
|
|
845
|
+
if (typeof this.exports.et_graph_capabilities !== 'function') return 0;
|
|
846
|
+
return this.exports.et_graph_capabilities() >>> 0;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
get graphSupported() {
|
|
850
|
+
return Boolean(
|
|
851
|
+
(this.graphCapabilities() & 1) !== 0 &&
|
|
852
|
+
typeof this.exports.et_graph_configure === 'function' &&
|
|
853
|
+
typeof this.exports.et_graph_latency === 'function' &&
|
|
854
|
+
typeof this.exports.et_graph_process === 'function' &&
|
|
855
|
+
typeof this.exports.et_graph_snapshot_size === 'function' &&
|
|
856
|
+
typeof this.exports.et_graph_snapshot_copy === 'function' &&
|
|
857
|
+
typeof this.exports.et_graph_read_diagnostic === 'function' &&
|
|
858
|
+
typeof this.exports.et_graph_set_instance_params === 'function' &&
|
|
859
|
+
typeof this.exports.et_graph_reset === 'function'
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
graphConfigure(descriptor) {
|
|
864
|
+
if (!this.engine || !this.prepared || !this.graphSupported) return ET_ERR_STATE;
|
|
865
|
+
const bytes = toUint8View(descriptor, 'Graph descriptor');
|
|
866
|
+
if (bytes.byteLength === 0) return ET_ERR_STATE;
|
|
867
|
+
this._preparing = true;
|
|
868
|
+
let ptr = 0;
|
|
869
|
+
try {
|
|
870
|
+
ptr = this.exports.malloc(bytes.byteLength) >>> 0;
|
|
871
|
+
this._refreshViews();
|
|
872
|
+
if (!ptr) return ET_ERR_STATE;
|
|
873
|
+
this._assertRange(ptr, bytes.byteLength, 'Graph descriptor');
|
|
874
|
+
this.u8.set(bytes, ptr);
|
|
875
|
+
return this.exports.et_graph_configure(this.engine, ptr, bytes.byteLength);
|
|
876
|
+
} finally {
|
|
877
|
+
if (ptr) this.exports.free(ptr);
|
|
878
|
+
this._refreshViews();
|
|
879
|
+
this._preparing = false;
|
|
880
|
+
if (this.engine && this.prepared) this.getArenaViews();
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
graphLatency() {
|
|
885
|
+
if (!this.engine || !this.graphSupported) return 0;
|
|
886
|
+
return this.exports.et_graph_latency(this.engine) >>> 0;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
graphProcess(channelCount, frameCount, timeSeconds) {
|
|
890
|
+
if (!this.engine || !this.graphSupported) return ET_ERR_STATE;
|
|
891
|
+
this._refreshViews();
|
|
892
|
+
return this.exports.et_graph_process(
|
|
893
|
+
this.engine,
|
|
894
|
+
channelCount >>> 0,
|
|
895
|
+
frameCount >>> 0,
|
|
896
|
+
timeSeconds
|
|
897
|
+
);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
graphSetInstanceParams(instanceId, packed, paramsHash, changedIndex) {
|
|
901
|
+
if (!this.engine || !this.graphSupported) return ET_ERR_STATE;
|
|
902
|
+
const values = packed instanceof Float32Array ? packed : Float32Array.from(packed || []);
|
|
903
|
+
const byteLength = values.length * Float32Array.BYTES_PER_ELEMENT;
|
|
904
|
+
if (byteLength > SCRATCH_BYTES) {
|
|
905
|
+
throw new DspBindingError('Packed Graph parameters exceed the scratch-buffer capacity');
|
|
906
|
+
}
|
|
907
|
+
const ptr = this.exports.et_scratch_ptr(this.engine) >>> 0;
|
|
908
|
+
this._refreshViews();
|
|
909
|
+
this._assertRange(ptr, byteLength, 'Packed Graph parameter block');
|
|
910
|
+
new Float32Array(this._memoryBuffer, ptr, values.length).set(values);
|
|
911
|
+
return this.exports.et_graph_set_instance_params(
|
|
912
|
+
this.engine,
|
|
913
|
+
instanceId,
|
|
914
|
+
ptr,
|
|
915
|
+
values.length,
|
|
916
|
+
paramsHash >>> 0,
|
|
917
|
+
changedIndex >>> 0
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
graphReset() {
|
|
922
|
+
if (!this.engine || !this.graphSupported) return ET_ERR_STATE;
|
|
923
|
+
return this.exports.et_graph_reset(this.engine);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
graphSnapshot() {
|
|
927
|
+
if (!this.engine || !this.graphSupported) return null;
|
|
928
|
+
const byteLength = this.exports.et_graph_snapshot_size(this.engine) >>> 0;
|
|
929
|
+
if (byteLength === 0) return new Uint8Array();
|
|
930
|
+
let ptr = 0;
|
|
931
|
+
this._preparing = true;
|
|
932
|
+
try {
|
|
933
|
+
ptr = this.exports.malloc(byteLength) >>> 0;
|
|
934
|
+
this._refreshViews();
|
|
935
|
+
if (!ptr) throw new DspBindingError('Unable to allocate the Graph snapshot buffer');
|
|
936
|
+
this._assertRange(ptr, byteLength, 'Graph snapshot');
|
|
937
|
+
const status = this.exports.et_graph_snapshot_copy(
|
|
938
|
+
this.engine,
|
|
939
|
+
ptr,
|
|
940
|
+
byteLength
|
|
941
|
+
);
|
|
942
|
+
if (status !== ET_OK) {
|
|
943
|
+
throw new DspBindingError('DSP Graph snapshot could not be read');
|
|
944
|
+
}
|
|
945
|
+
return new Uint8Array(this.u8.slice(ptr, ptr + byteLength));
|
|
946
|
+
} finally {
|
|
947
|
+
if (ptr) this.exports.free(ptr);
|
|
948
|
+
this._refreshViews();
|
|
949
|
+
this._preparing = false;
|
|
950
|
+
if (this.engine && this.prepared) this.getArenaViews();
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
graphDiagnostic() {
|
|
955
|
+
if (!this.engine || !this.graphSupported) return null;
|
|
956
|
+
const ptr = this.exports.et_scratch_ptr(this.engine) >>> 0;
|
|
957
|
+
this._refreshViews();
|
|
958
|
+
this._assertRange(ptr, 24, 'Graph diagnostic');
|
|
959
|
+
if (this.exports.et_graph_read_diagnostic(this.engine, ptr) !== ET_OK) return null;
|
|
960
|
+
return {
|
|
961
|
+
status: this.dataView.getInt32(ptr, true),
|
|
962
|
+
kind: this.dataView.getUint32(ptr + 4, true),
|
|
963
|
+
index: this.dataView.getUint32(ptr + 8, true),
|
|
964
|
+
path: this.dataView.getUint32(ptr + 12, true),
|
|
965
|
+
required: this.dataView.getUint32(ptr + 16, true),
|
|
966
|
+
capacity: this.dataView.getUint32(ptr + 20, true)
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
|
|
809
970
|
markFailed() {
|
|
810
971
|
this.failed = true;
|
|
811
972
|
}
|