Spaces:
Building
Building
Update flare-ui/src/app/services/audio-stream.service.ts
Browse files
flare-ui/src/app/services/audio-stream.service.ts
CHANGED
@@ -222,19 +222,22 @@ export class AudioStreamService implements OnDestroy {
|
|
222 |
}
|
223 |
|
224 |
private float32ToInt16(buffer: Float32Array): Int16Array {
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
238 |
}
|
239 |
|
240 |
private arrayBufferToBase64(buffer: ArrayBuffer): string {
|
|
|
222 |
}
|
223 |
|
224 |
private float32ToInt16(buffer: Float32Array): Int16Array {
|
225 |
+
const l = buffer.length;
|
226 |
+
const result = new Int16Array(l);
|
227 |
+
|
228 |
+
// ✅ Gain artır - ses seviyesi çok düşük
|
229 |
+
const gain = 3.0; // 3x gain uygula
|
230 |
+
|
231 |
+
for (let i = 0; i < l; i++) {
|
232 |
+
// Apply gain and clamp to [-1, 1]
|
233 |
+
let amplified = buffer[i] * gain;
|
234 |
+
let clamped = Math.max(-1, Math.min(1, amplified));
|
235 |
+
|
236 |
+
// Convert float32 [-1, 1] to int16 [-32768, 32767]
|
237 |
+
result[i] = clamped < 0 ? clamped * 0x8000 : clamped * 0x7FFF;
|
238 |
+
}
|
239 |
+
|
240 |
+
return result;
|
241 |
}
|
242 |
|
243 |
private arrayBufferToBase64(buffer: ArrayBuffer): string {
|