Search code examples
javaaudiopcm

avoid static and distortion when chaining together pcm samples


I have the problem of stitching together pcm audio samples from various parts of an audio recording. The idea is that it is audio feedback from a user seeking through a recording on a progress bar of sorts. They could be of an arbitrary length (say .1 to .5 seconds). My major problem is that when I play these samples back, they result in a significant amount of noise artifacts, distortions, etc.

I imagine this is a result of the amplitude jumps between samples. I have yet to come up with a good method of resolving this. The last thing I did was to try to truncate the samples at the point where they cross the origin (go from positive to negative or vice-versa), but that hasn't helped much. Anyone have any ideas?

THanks


Solution

  • the "zero-crossing" trick usually works well, as does a short linear or cosine fade (~1/30 second). If you are using fades, the fades have to be long enough to avoid pops, but still be significantly shorter than the audio segments you are dealing with. If you use zero-crossing, you have to ensure that the audio you are dealing with actually crosses zero (which can be a problem for low-frequencies, and signals that have become offset. To avoid offsets, both problems, you can high-pass filter the signal first).

    If your segments are frequently on the short end of the .1 to .5 ms range, various psycho-acoustic phenomenon might be getting in the way. You should start by limiting yourself to longer segments and seeing if that works, then see how short you can make it. That way you know if the problem is with your code or just making it short.