Mixing 16 bit linear PCM streams and avoiding clipping/overflow

前端 未结 6 551
逝去的感伤
逝去的感伤 2021-01-31 12:45

I\'ve trying to mix together 2 16bit linear PCM audio streams and I can\'t seem to overcome the noise issues. I think they are coming from overflow when mixing samples together.

6条回答
  •  一个人的身影
    2021-01-31 13:30

    I think they should be functions mapping [MIN_SHORT, MAX_SHORT] -> [MIN_SHORT, MAX_SHORT] and they are clearly not (besides first one), so overflows occurs.

    If unwind's proposition won't work you can also try:

    ((long int)(sample1) + sample2) / 2
    

提交回复
热议问题