Android Audio - Streaming sine-tone generator odd behaviour

浪子不回头ぞ 提交于 2019-11-30 07:11:32

I've found it!

It turns out the problem has nothing to do with buffers or threading.

It sounds fine in the first couple of seconds, because the angle of the computation is relatively small. As the program runs and the angle grows, Math.sin(_currentAngle) begins to produce unreliable values.

So, I replaced Math.sin() with FloatMath.sin().

I also replaced _currentAngle = _currentAngle + _angleIncrement;

with

_currentAngle = ((_currentAngle + _angleIncrement) % (2.0f * (float) Math.PI));, so the angle is always < 2*PI.

Works like a charm! Thanks very much for your help, praetorian droid!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!