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

Method encode

server/cloudflare/src/opus.ts:97–118  ·  view source on GitHub ↗
(frame: Uint8Array)

Source from the content-addressed store, hash-verified

95 }
96
97 encode(frame: Uint8Array): Uint8Array {
98 if (this.closed) {
99 throw new Error("Opus encoder is closed");
100 }
101
102 this.refreshMemory();
103 this.memory.set(frame, this.pcmPtr);
104 const size = ensureOk(
105 this.wasm.opus_encode(
106 this.encoderPtr,
107 this.pcmPtr,
108 frame.byteLength / BYTES_PER_SAMPLE / CHANNELS,
109 this.packetPtr,
110 MAX_PACKET_SIZE,
111 ),
112 this.memory,
113 this.wasm,
114 );
115
116 this.refreshMemory();
117 return this.memory.slice(this.packetPtr, this.packetPtr + size);
118 }
119
120 close() {
121 if (this.closed) {

Callers 3

pushFunction · 0.45
flushFunction · 0.45
verifyAuthTokenFunction · 0.45

Calls 3

refreshMemoryMethod · 0.95
ensureOkFunction · 0.85
opus_encodeMethod · 0.80

Tested by

no test coverage detected