I am trying to mix multiple WAV files into one using mixing algorithms I found in chatGPT answers and other websites.
I tried with simple step of mixing audio using the below code:
double mixingRatio = 0.5;
Uint8List? list = fileData1;
for(int i = 0; i < fileData1.length; i++) {
int mixedValue = ((1 - mixingRatio) * fileData1[i] + mixingRatio * fileData2[i]).round().clamp(0, 255);
list[i] = mixedValue;
}
return list;
}
There are too many clips and even though I am clamping (0-255). It still clips as seen in the picture. The input files are all normalized and confirmed from Audacity.
Looking for a mathematical solution to this simple problem. I don't want to use FFmpeg because it does not work with realtime data.
Thanks
EDIT:
This is how i am importing Raw Audio.