MentraOS / mobile /modules /engine /src /utils /pcmToBase64.ts
Anirudh1950's picture
Add files using upload-large-folder tool
e079a73 verified
Raw History Blame Contribute Delete
370 Bytes
/** Encode decoded LC3 PCM for native sinks. Hermes has btoa, but no Node Buffer. */
export function pcmToBase64(pcm: ArrayBuffer): string {
const bytes = new Uint8Array(pcm)
let binary = ""
const step = 0x8000
for (let i = 0; i < bytes.length; i += step) {
binary += String.fromCharCode(...bytes.subarray(i, i + step))
}
return btoa(binary)
}