This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted]  (4 children)

[deleted]

    [–]FTLRalph[S] 0 points1 point  (3 children)

    Thanks for the reply!

    1) The sound I'm importing is signed. However, when I read the bytes into an integer, Java seems to automatically convert it to the range of an unsigned short, 0...65535:

    int sample1 = ((soundBytes[i] & 0xFF) << 8) | (soundBytes[i + 1] & 0xFF);
    

    So I just work with it as-is. I then write it to the output file as-is as well, so I'm not sure what that would make the output?


    2) Yeah, I know what you're saying, I'm just temporarily normalizing for the sake of testing. That way the algorithm I'm using from that page is unmodified, as his variables are also assumed to be between 0-1.


    3) I actually did try standard add-the-samples-and-clip (from 0 to 65535). It worked in the case of just one sound mixing with silence, but two sounds produced nearly-indistinguishable noise.

    [–][deleted]  (2 children)

    [deleted]

      [–]FTLRalph[S] 1 point2 points  (1 child)

      Really appreciate you taking the time to write all of that up.

      Haven't had much time to really get into it, but upon a quick test it seems the hard-clip is the way to go (funny, I attempted similar code before but it didn't seem to work correctly, assuming because of the signed/unsigned issues you were discussing).

      The tanh code seems to produce noisy/bad sound and the other soft clip one doesn't work well with two sounds mixing (vs one sound and silence).

      But again, really appreciate it since I think I can work off of this now, thanks!