@effetune/dsp 0.4.0 → 0.6.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/dist/index.d.ts CHANGED
@@ -16,12 +16,15 @@ export type {
16
16
  DelayOptions,
17
17
  TimeAlignmentOptions,
18
18
  AMRadioSimulatorOptions,
19
+ AutoFilterOptions,
19
20
  AutoLevelerOptions,
21
+ AutoPanOptions,
20
22
  BandPassFilterOptions,
21
23
  BitCrusherOptions,
22
24
  BluetoothSBCSimulatorOptions,
23
25
  BrickwallLimiterOptions,
24
26
  CassetteArtifactsOptions,
27
+ ChorusOptions,
25
28
  CombFilterOptions,
26
29
  CommonEffectOptions,
27
30
  CompressorOptions,
@@ -40,6 +43,7 @@ export type {
40
43
  ExpanderOptions,
41
44
  FDNReverbOptions,
42
45
  FMRadioSimulatorOptions,
46
+ FrequencyShifterOptions,
43
47
  FifteenBandGEQOptions,
44
48
  FifteenBandPEQOptions,
45
49
  FiveBandDynamicEQOptions,
@@ -49,6 +53,7 @@ export type {
49
53
  GSMFullRateSimulatorOptions,
50
54
  GateOptions,
51
55
  GroupDelayEQOptions,
56
+ GroupDelayPEQOptions,
52
57
  HardClippingOptions,
53
58
  HarmonicDistortionOptions,
54
59
  HiPassFilterOptions,
@@ -59,6 +64,7 @@ export type {
59
64
  IRReverbOptions,
60
65
  LoPassFilterOptions,
61
66
  LoudnessEqualizerOptions,
67
+ MDSimulatorOptions,
62
68
  MP3CodecSimulatorOptions,
63
69
  MSMatrixOptions,
64
70
  ModalResonatorOptions,
@@ -70,8 +76,11 @@ export type {
70
76
  NarrowRangeOptions,
71
77
  NoiseBlenderOptions,
72
78
  OscillatorOptions,
79
+ PhaserOptions,
80
+ PhaseSelectEQOptions,
73
81
  PitchShifterOptions,
74
82
  PowerAmpSagOptions,
83
+ RotarySpeakerOptions,
75
84
  RSReverbOptions,
76
85
  RoomEQOptions,
77
86
  SaturationOptions,
@@ -107,12 +116,15 @@ export {
107
116
  Delay,
108
117
  TimeAlignment,
109
118
  AMRadioSimulator,
119
+ AutoFilter,
110
120
  AutoLeveler,
121
+ AutoPan,
111
122
  BandPassFilter,
112
123
  BitCrusher,
113
124
  BluetoothSBCSimulator,
114
125
  BrickwallLimiter,
115
126
  CassetteArtifacts,
127
+ Chorus,
116
128
  CombFilter,
117
129
  Compressor,
118
130
  CrossfeedFilter,
@@ -129,6 +141,7 @@ export {
129
141
  Expander,
130
142
  FDNReverb,
131
143
  FMRadioSimulator,
144
+ FrequencyShifter,
132
145
  FifteenBandGEQ,
133
146
  FifteenBandPEQ,
134
147
  FiveBandDynamicEQ,
@@ -138,6 +151,7 @@ export {
138
151
  GSMFullRateSimulator,
139
152
  Gate,
140
153
  GroupDelayEQ,
154
+ GroupDelayPEQ,
141
155
  HardClipping,
142
156
  HarmonicDistortion,
143
157
  HiPassFilter,
@@ -147,6 +161,7 @@ export {
147
161
  IRReverb,
148
162
  LoPassFilter,
149
163
  LoudnessEqualizer,
164
+ MDSimulator,
150
165
  MP3CodecSimulator,
151
166
  MSMatrix,
152
167
  ModalResonator,
@@ -158,8 +173,11 @@ export {
158
173
  NarrowRange,
159
174
  NoiseBlender,
160
175
  Oscillator,
176
+ Phaser,
177
+ PhaseSelectEQ,
161
178
  PitchShifter,
162
179
  PowerAmpSag,
180
+ RotarySpeaker,
163
181
  RSReverb,
164
182
  RoomEQ,
165
183
  Saturation,
@@ -193,12 +211,15 @@ export {
193
211
  createDelay,
194
212
  createTimeAlignment,
195
213
  createAMRadioSimulator,
214
+ createAutoFilter,
196
215
  createAutoLeveler,
216
+ createAutoPan,
197
217
  createBandPassFilter,
198
218
  createBitCrusher,
199
219
  createBluetoothSBCSimulator,
200
220
  createBrickwallLimiter,
201
221
  createCassetteArtifacts,
222
+ createChorus,
202
223
  createCombFilter,
203
224
  createCompressor,
204
225
  createCrossfeedFilter,
@@ -213,6 +234,7 @@ export {
213
234
  createExpander,
214
235
  createFDNReverb,
215
236
  createFMRadioSimulator,
237
+ createFrequencyShifter,
216
238
  createFifteenBandGEQ,
217
239
  createFifteenBandPEQ,
218
240
  createFiveBandDynamicEQ,
@@ -222,6 +244,7 @@ export {
222
244
  createGSMFullRateSimulator,
223
245
  createGate,
224
246
  createGroupDelayEQ,
247
+ createGroupDelayPEQ,
225
248
  createHardClipping,
226
249
  createHarmonicDistortion,
227
250
  createHiPassFilter,
@@ -231,6 +254,7 @@ export {
231
254
  createIRReverb,
232
255
  createLoPassFilter,
233
256
  createLoudnessEqualizer,
257
+ createMDSimulator,
234
258
  createMP3CodecSimulator,
235
259
  createMSMatrix,
236
260
  createModalResonator,
@@ -242,8 +266,11 @@ export {
242
266
  createNarrowRange,
243
267
  createNoiseBlender,
244
268
  createOscillator,
269
+ createPhaser,
270
+ createPhaseSelectEQ,
245
271
  createPitchShifter,
246
272
  createPowerAmpSag,
273
+ createRotarySpeaker,
247
274
  createRSReverb,
248
275
  createRoomEQ,
249
276
  createSaturation,
@@ -267,7 +294,12 @@ export type { EffectDefinition } from './effect.js';
267
294
  import type { Effect } from './effect.js';
268
295
  import type { EffectChannel, EffectType } from './generated-effects.js';
269
296
 
270
- export declare class EffeTuneError extends Error {}
297
+ export declare class EffeTuneError extends Error {
298
+ readonly code?: string;
299
+ readonly path?: string;
300
+ readonly nodeId?: string;
301
+ readonly edgeId?: string;
302
+ }
271
303
  export declare class ValidationError extends EffeTuneError {}
272
304
  export declare class EffectError extends EffeTuneError {}
273
305
  export declare class AssetError extends EffeTuneError {}
@@ -519,6 +551,226 @@ export declare function createChain(
519
551
  options?: CreateChainOptions
520
552
  ): Promise<Chain>;
521
553
 
554
+ export interface GraphEndpoint {
555
+ readonly id: string;
556
+ }
557
+
558
+ export interface GraphNode extends ChainEffect {}
559
+
560
+ export interface GraphNodeInput extends ChainEffectInput {
561
+ readonly id: string;
562
+ }
563
+
564
+ export interface GraphEdge {
565
+ readonly id: string;
566
+ readonly source: string;
567
+ readonly destination: string;
568
+ readonly gain: number;
569
+ readonly mute: boolean;
570
+ readonly pan?: number;
571
+ readonly mixGroup: string;
572
+ readonly solo: boolean;
573
+ }
574
+
575
+ export interface GraphEdgeInput {
576
+ readonly id: string;
577
+ readonly source: string;
578
+ readonly destination: string;
579
+ readonly gain?: number;
580
+ readonly mute?: boolean;
581
+ readonly pan?: number;
582
+ readonly mixGroup?: string;
583
+ readonly solo?: boolean;
584
+ }
585
+
586
+ export interface GraphDocument {
587
+ readonly version: 1;
588
+ readonly input: GraphEndpoint;
589
+ readonly output: GraphEndpoint;
590
+ readonly nodes: readonly GraphNode[];
591
+ readonly edges: readonly GraphEdge[];
592
+ }
593
+
594
+ export interface GraphDocumentInput {
595
+ readonly version: 1;
596
+ readonly input: GraphEndpoint;
597
+ readonly output: GraphEndpoint;
598
+ readonly nodes: readonly GraphNodeInput[];
599
+ readonly edges: readonly GraphEdgeInput[];
600
+ }
601
+
602
+ export interface GraphCompileSnapshot {
603
+ readonly version: 1;
604
+ readonly identity: boolean;
605
+ readonly silence: boolean;
606
+ readonly effectiveSchedule: readonly string[];
607
+ readonly nodes: readonly GraphCompileNodeSnapshot[];
608
+ readonly edges: readonly GraphCompileEdgeSnapshot[];
609
+ readonly outputLatency: readonly number[];
610
+ readonly outputCompensation: readonly number[];
611
+ readonly latencySamples: number;
612
+ readonly capacity: Readonly<{ bufferSlots: number; workspaceBytes: number }>;
613
+ }
614
+
615
+ export interface GraphCompileNodeSnapshot {
616
+ readonly id: string;
617
+ readonly effective: boolean;
618
+ readonly dormant: boolean;
619
+ readonly enabled: boolean;
620
+ readonly disabledBypass: boolean;
621
+ readonly scheduleIndex: number | null;
622
+ readonly bufferSlot: number | null;
623
+ readonly processingGroup: Readonly<{ firstChannel: number; channelCount: number }>;
624
+ readonly kernelLatency: number;
625
+ readonly inputLatency: readonly number[];
626
+ readonly outputLatency: readonly number[];
627
+ readonly preNodeCompensation: readonly number[];
628
+ }
629
+
630
+ export interface GraphCompileEdgeSnapshot {
631
+ readonly id: string;
632
+ readonly active: boolean;
633
+ readonly suppressed: boolean;
634
+ readonly dormant: boolean;
635
+ readonly fanInCompensation: readonly number[];
636
+ }
637
+
638
+ export type GraphVisualizationState =
639
+ | 'structural'
640
+ | 'effective'
641
+ | 'dormant'
642
+ | 'disabled-bypass'
643
+ | 'suppressed';
644
+
645
+ export interface GraphVisualizationEndpoint {
646
+ readonly id: string;
647
+ readonly kind: 'input' | 'output';
648
+ }
649
+
650
+ export interface GraphVisualizationEffectNode {
651
+ readonly id: string;
652
+ readonly kind: 'effect';
653
+ readonly effectType: EffectType;
654
+ readonly enabled: boolean;
655
+ readonly effective?: boolean;
656
+ readonly dormant?: boolean;
657
+ readonly disabledBypass?: boolean;
658
+ readonly state: GraphVisualizationState;
659
+ }
660
+
661
+ export interface GraphVisualizationEdge {
662
+ readonly id: string;
663
+ readonly source: string;
664
+ readonly destination: string;
665
+ readonly active?: boolean;
666
+ readonly suppressed?: boolean;
667
+ readonly dormant?: boolean;
668
+ readonly state: GraphVisualizationState;
669
+ }
670
+
671
+ export interface GraphVisualizationSnapshot {
672
+ readonly version: 1;
673
+ readonly nodes: readonly (GraphVisualizationEndpoint | GraphVisualizationEffectNode)[];
674
+ readonly edges: readonly GraphVisualizationEdge[];
675
+ }
676
+
677
+ export interface GraphStructuralSnapshot {
678
+ readonly document: GraphDocument;
679
+ readonly topologicalOrder: readonly string[];
680
+ readonly incoming: Readonly<Record<string, readonly string[]>>;
681
+ readonly outgoing: Readonly<Record<string, readonly string[]>>;
682
+ }
683
+
684
+ export interface CreateGraphOptions extends ArtifactOptions {
685
+ readonly assetResolver?: AssetResolver | { resolve: AssetResolver };
686
+ }
687
+
688
+ export interface GraphProcessOptions {
689
+ readonly sampleRate: number;
690
+ readonly seed?: number;
691
+ readonly blockSize?: number;
692
+ }
693
+
694
+ export interface GraphStreamOptions extends GraphProcessOptions {
695
+ readonly channels?: number;
696
+ }
697
+
698
+ export interface GraphRecipeOptions {
699
+ readonly nodeId?: string;
700
+ readonly inputId?: string;
701
+ readonly outputId?: string;
702
+ }
703
+
704
+ export interface WetDryGraphOptions extends GraphRecipeOptions {
705
+ readonly wet?: number;
706
+ readonly dry?: number;
707
+ }
708
+
709
+ export interface SendReturnGraphOptions extends GraphRecipeOptions {
710
+ readonly send?: number;
711
+ readonly returnGain?: number;
712
+ }
713
+
714
+ export declare class Graph {
715
+ private constructor();
716
+ static load(input: string | GraphDocumentInput, options?: CreateGraphOptions): Promise<Graph>;
717
+ static fromChain(
718
+ chain: Chain | ChainDocumentInput | readonly (Effect | ChainEffectInput)[],
719
+ options?: CreateGraphOptions
720
+ ): Promise<Graph>;
721
+ static wetDry(effect: Effect | ChainEffectInput, options?: WetDryGraphOptions): GraphDocument;
722
+ static sendReturn(effect: Effect | ChainEffectInput, options?: SendReturnGraphOptions): GraphDocument;
723
+ readonly nodes: readonly GraphNode[];
724
+ readonly edges: readonly GraphEdge[];
725
+ toJSON(): GraphDocument;
726
+ toChain(): ChainDocument;
727
+ serialize(space?: number): string;
728
+ getNode(id: string): GraphNode | null;
729
+ getEdge(id: string): GraphEdge | null;
730
+ incoming(id: string): readonly GraphEdge[];
731
+ outgoing(id: string): readonly GraphEdge[];
732
+ structuralSnapshot(): GraphStructuralSnapshot;
733
+ visualizationSnapshot(): GraphVisualizationSnapshot;
734
+ stream(options: GraphStreamOptions): Promise<GraphStream>;
735
+ latencySamples(options: LatencyOptions): Promise<number>;
736
+ process(audio: readonly Float32Array[], options: GraphProcessOptions): Promise<Float32Array[]>;
737
+ close(): void;
738
+ }
739
+
740
+ export declare class GraphStream {
741
+ readonly graph: GraphDocument;
742
+ readonly latencySamples: number;
743
+ readonly compileSnapshot: GraphCompileSnapshot;
744
+ visualizationSnapshot(): GraphVisualizationSnapshot;
745
+ setParam(nodeId: string, parameterName: string, value: unknown): this;
746
+ reset(): this;
747
+ process(audio: readonly Float32Array[]): Promise<Float32Array[]>;
748
+ close(): void;
749
+ }
750
+
751
+ export declare function createGraph(
752
+ input: string | GraphDocumentInput,
753
+ options?: CreateGraphOptions
754
+ ): Promise<Graph>;
755
+
756
+ export declare function normalizeGraphDocument(
757
+ input: string | GraphDocumentInput
758
+ ): GraphDocument;
759
+ export declare function graphDocumentFromChain(
760
+ input: ChainDocumentInput | readonly (Effect | ChainEffectInput)[]
761
+ ): GraphDocument;
762
+ export declare function chainDocumentFromGraph(
763
+ input: GraphDocumentInput
764
+ ): ChainDocument;
765
+ export declare function createWetDryGraphDocument(
766
+ effect: Effect | ChainEffectInput,
767
+ options?: WetDryGraphOptions
768
+ ): GraphDocument;
769
+ export declare function createSendReturnGraphDocument(
770
+ effect: Effect | ChainEffectInput,
771
+ options?: SendReturnGraphOptions
772
+ ): GraphDocument;
773
+
522
774
  export declare function parsePreset(
523
775
  input: string | ChainDocumentInput | readonly (Effect | ChainEffectInput)[]
524
776
  ): ChainDocument;
package/dist/index.js CHANGED
@@ -25,12 +25,15 @@ export {
25
25
  Delay,
26
26
  TimeAlignment,
27
27
  AMRadioSimulator,
28
+ AutoFilter,
28
29
  AutoLeveler,
30
+ AutoPan,
29
31
  BitCrusher,
30
32
  BluetoothSBCSimulator,
31
33
  BrickwallLimiter,
32
34
  BandPassFilter,
33
35
  CassetteArtifacts,
36
+ Chorus,
34
37
  CombFilter,
35
38
  Compressor,
36
39
  CrossfeedFilter,
@@ -47,6 +50,7 @@ export {
47
50
  Expander,
48
51
  FDNReverb,
49
52
  FMRadioSimulator,
53
+ FrequencyShifter,
50
54
  FifteenBandGEQ,
51
55
  FifteenBandPEQ,
52
56
  FiveBandDynamicEQ,
@@ -56,6 +60,7 @@ export {
56
60
  GSMFullRateSimulator,
57
61
  Gate,
58
62
  GroupDelayEQ,
63
+ GroupDelayPEQ,
59
64
  HardClipping,
60
65
  HarmonicDistortion,
61
66
  HiPassFilter,
@@ -65,6 +70,7 @@ export {
65
70
  IRReverb,
66
71
  LoPassFilter,
67
72
  LoudnessEqualizer,
73
+ MDSimulator,
68
74
  MP3CodecSimulator,
69
75
  MSMatrix,
70
76
  ModalResonator,
@@ -76,8 +82,11 @@ export {
76
82
  NarrowRange,
77
83
  NoiseBlender,
78
84
  Oscillator,
85
+ Phaser,
86
+ PhaseSelectEQ,
79
87
  PitchShifter,
80
88
  PowerAmpSag,
89
+ RotarySpeaker,
81
90
  RSReverb,
82
91
  RoomEQ,
83
92
  Saturation,
@@ -111,12 +120,15 @@ export {
111
120
  createDelay,
112
121
  createTimeAlignment,
113
122
  createAMRadioSimulator,
123
+ createAutoFilter,
114
124
  createAutoLeveler,
125
+ createAutoPan,
115
126
  createBandPassFilter,
116
127
  createBitCrusher,
117
128
  createBluetoothSBCSimulator,
118
129
  createBrickwallLimiter,
119
130
  createCassetteArtifacts,
131
+ createChorus,
120
132
  createCombFilter,
121
133
  createCompressor,
122
134
  createCrossfeedFilter,
@@ -131,6 +143,7 @@ export {
131
143
  createExpander,
132
144
  createFDNReverb,
133
145
  createFMRadioSimulator,
146
+ createFrequencyShifter,
134
147
  createFifteenBandGEQ,
135
148
  createFifteenBandPEQ,
136
149
  createFiveBandDynamicEQ,
@@ -140,6 +153,7 @@ export {
140
153
  createGSMFullRateSimulator,
141
154
  createGate,
142
155
  createGroupDelayEQ,
156
+ createGroupDelayPEQ,
143
157
  createHardClipping,
144
158
  createHarmonicDistortion,
145
159
  createHiPassFilter,
@@ -149,6 +163,7 @@ export {
149
163
  createIRReverb,
150
164
  createLoPassFilter,
151
165
  createLoudnessEqualizer,
166
+ createMDSimulator,
152
167
  createMP3CodecSimulator,
153
168
  createMSMatrix,
154
169
  createModalResonator,
@@ -160,8 +175,11 @@ export {
160
175
  createNarrowRange,
161
176
  createNoiseBlender,
162
177
  createOscillator,
178
+ createPhaser,
179
+ createPhaseSelectEQ,
163
180
  createPitchShifter,
164
181
  createPowerAmpSag,
182
+ createRotarySpeaker,
165
183
  createRSReverb,
166
184
  createRoomEQ,
167
185
  createSaturation,
@@ -182,6 +200,14 @@ export {
182
200
  export { getEffectCatalog } from './catalog.js';
183
201
  export { encodeEta1 } from './assets.js';
184
202
  export { Chain, createChain, isBundleDocument } from './runtime.js';
203
+ export { Graph, GraphStream, createGraph } from './graph.js';
204
+ export {
205
+ chainDocumentFromGraph,
206
+ createSendReturnGraphDocument,
207
+ createWetDryGraphDocument,
208
+ graphDocumentFromChain,
209
+ normalizeGraphDocument
210
+ } from './graph-document.js';
185
211
  export { importLegacyPreset, parsePreset } from './preset.js';
186
212
 
187
213
  import { getEffectCatalog } from './catalog.js';
@@ -36,6 +36,7 @@ const REQUIRED_FUNCTION_EXPORTS = [
36
36
  'et_telemetry_capacity',
37
37
  'et_telemetry_read',
38
38
  'et_pipeline_configure',
39
+ 'et_pipeline_latency',
39
40
  'et_pipeline_process'
40
41
  ];
41
42
 
@@ -811,7 +812,21 @@ export class DspEngineBinding {
811
812
  this._refreshViews();
812
813
  this._assertRange(ptr, bytes.byteLength, 'Pipeline descriptor');
813
814
  this.u8.set(bytes, ptr);
814
- return this.exports.et_pipeline_configure(this.engine, ptr, bytes.byteLength);
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;
815
830
  }
816
831
 
817
832
  pipelineProcess(channelCount, frameCount, timeSeconds, masterBypass = false) {
@@ -826,6 +841,132 @@ export class DspEngineBinding {
826
841
  );
827
842
  }
828
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
+
829
970
  markFailed() {
830
971
  this.failed = true;
831
972
  }