I’m mixing 2 audio bytes arrays getting the mix with some white noise.
for (int i=0;i<bytes1.getB1().length;i++){
mixBytes[i]=(byte) (bytes1[i]+bytes2[i]);
}
Anyone knows how to solve the white noise problem ?
I’m getting the bytes with this method, removing the 44 first bytes as wav header.
private byte[] getISByteArray(InputStream is){
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int length;
try {
while ((length = is.read()) != -1) {
stream.write(length);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] b=stream.toByteArray();
byte[] b2=new byte[b.length-44];
//System.arraycopy(b, 44, b2, 0, b2.length);
for (int i=0;i<b.length;i++){
if (i>44) b2[i-44]=b[i];
}
return b2;
}
I can see two potential problems immediately:
For the latter, this might help – although it depends on whether the bytes are really linear amplitude etc, just by taking the average:
I suspect that will make it slightly better, but it’s still not a great mixing function…