MCPcopy Create free account
hub / github.com/akdeb/ElatoAI / constructor

Method constructor

server/cloudflare/src/opus.ts:72–89  ·  view source on GitHub ↗
(wasm: OpusExports)

Source from the content-addressed store, hash-verified

70 private closed = false;
71
72 constructor(wasm: OpusExports) {
73 this.wasm = wasm;
74 this.memory = new Uint8Array(wasm.memory.buffer);
75 this.packetPtr = wasm.malloc(MAX_PACKET_SIZE);
76 this.pcmPtr = wasm.malloc(PCM_BUFFER_SIZE);
77 this.encoderPtr = wasm.malloc(wasm.opus_encoder_get_size(CHANNELS));
78
79 ensureOk(
80 wasm.opus_encoder_init(this.encoderPtr, SAMPLE_RATE, CHANNELS, 2048),
81 this.memory,
82 wasm,
83 );
84
85 // The 120ms packet duration is determined by the PCM frame size we pass to
86 // opus_encode(). Avoid low-level CTL tuning here because incorrect request
87 // codes/enum values in the wasm build surface as "invalid argument" during
88 // session startup.
89 }
90
91 private refreshMemory() {
92 if (this.memory.buffer !== this.wasm.memory.buffer) {

Callers

nothing calls this directly

Calls 4

ensureOkFunction · 0.85
mallocMethod · 0.80
opus_encoder_get_sizeMethod · 0.80
opus_encoder_initMethod · 0.80

Tested by

no test coverage detected