ciyidogan commited on
Commit
f4e1b1f
·
verified ·
1 Parent(s): b3c207d

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
- const l = buffer.length;
226
- const result = new Int16Array(l);
227
-
228
- // ✅ Gain artır
229
- const gain = 2.0; // Sesi 2x yükselt
230
-
231
- for (let i = 0; i < l; i++) {
232
- // Convert float32 [-1, 1] to int16 [-32768, 32767]
233
- let s = Math.max(-1, Math.min(1, buffer[i] * gain));
234
- result[i] = s < 0 ? s * 0x8000 : s * 0x7FFF;
235
- }
236
-
237
- return result;
 
 
 
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 {