简体   繁体   English

白噪声混合2音频字节阵列

[英]White noise mixing 2 audio byte array

I'm mixing 2 audio bytes arrays getting the mix with some white noise. 我正在混合2个音频字节数组,使混合时带有一些白噪声。

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. 我通过这种方法获取字节,删除了44个头字节作为wav标头。

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: 我可以立即看到两个潜在的问题:

  • You're treating the inputs as if they were one-byte-per-sample streams. 您将输入视为每个样本一字节流。 Are they really? 是真的吗
  • You're not doing anything about overflow, which will take two bytes of value 100 and end up with a negative number for example. 您没有对溢出做任何事情,溢出将占用两个字节的值100,最后以负数结尾。

For the latter, this might help - although it depends on whether the bytes are really linear amplitude etc, just by taking the average: 对于后者,这可能会有所帮助-尽管仅取决于平均值,这取决于字节是否真的是线性幅度等。

mixBytes[i]=(byte) ((bytes1[i]+bytes2[i]) / 2);

I suspect that will make it slightly better, but it's still not a great mixing function... 我怀疑这会使它稍微好一点,但是它仍然不是很好的混合功能...

用低通高斯滤波器对原始信号进行卷积,将消除白噪声。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM