From 074f62bf6cb55f93bee6fe2b4972c0481ccf49e3 Mon Sep 17 00:00:00 2001 From: Andrey Danilov Date: Mon, 18 Mar 2024 08:21:13 +0300 Subject: [PATCH] Add stereo separation factor --- .../src/main/java/com/danand/juicynoise/AudioOutput.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/juicy-noise-android/app/src/main/java/com/danand/juicynoise/AudioOutput.kt b/juicy-noise-android/app/src/main/java/com/danand/juicynoise/AudioOutput.kt index 084b948..e667276 100644 --- a/juicy-noise-android/app/src/main/java/com/danand/juicynoise/AudioOutput.kt +++ b/juicy-noise-android/app/src/main/java/com/danand/juicynoise/AudioOutput.kt @@ -100,9 +100,14 @@ class AudioOutput( var sampleIndexStereo = 0 + val channelMergeFactor = 0.125f + for (sampleIndexMono in bufferMonoLeft.indices) { - bufferStereo[sampleIndexStereo] = bufferMonoLeft[sampleIndexMono] - bufferStereo[sampleIndexStereo + 1] = bufferMonoRight[sampleIndexMono] + val sampleLeft = bufferMonoLeft[sampleIndexMono] + val sampleRight = bufferMonoRight[sampleIndexMono] + + bufferStereo[sampleIndexStereo] = (sampleLeft * (1 - channelMergeFactor)) + (sampleRight * channelMergeFactor) + bufferStereo[sampleIndexStereo + 1] = (sampleRight * (1 - channelMergeFactor)) + (sampleLeft * channelMergeFactor) sampleIndexStereo += 2 }