(value: string)
| 125 | try { |
| 126 | return decodePcm16Base64(base64); |
| 127 | } catch { |
| 128 | return null; |
| 129 | } |
| 130 | }; |
| 131 | |
| 132 | export const decodePcm16Base64 = (base64: string): Int16Array => { |
| 133 | const binary = atob(base64.replace(/\s+/g, "")); |
| 134 | const samples = new Int16Array(Math.floor(binary.length / 2)); |
| 135 | for (let index = 0; index < samples.length; index += 1) { |
| 136 | const value = (binary.charCodeAt(index * 2) & 0xff) | ((binary.charCodeAt(index * 2 + 1) & 0xff) << 8); |
| 137 | samples[index] = value >= 0x8000 ? value - 0x10000 : value; |
no outgoing calls
no test coverage detected