Skip to content

Commit

Permalink
Add stereo separation factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Danand committed Mar 18, 2024
1 parent fdbe0fb commit 074f62b
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 074f62b

Please sign in to comment.