It's working for two prerecorded wav files of same characteristics(sample rate,channel,bitspersample etc) but with a recorded voice it creates white noises in output.
我们如何减少混合声音中的白噪声?
是否有任何本地图书馆可以做到这一点?
byte[] output = new byte[(music1.length > music2.length) ? music2.length
: music1.length];
for (int i = 0; i < output.length; i++) {
float samplef1 = music1[i] / 128.0f; // 2^7=128
float samplef2 = music2[i] / 128.0f;
float mixed = (samplef1 + samplef2) / 2;
if (mixed > 1.0f)
mixed = 1.0f;
if (mixed < -1.0f)
mixed = -1.0f;
byte outputSample = (byte) (mixed * 128.0f);
output[i] = outputSample;
}