File size: 370 Bytes
e079a73
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
/** 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)
}