Android Audio - Streaming Sine-tone Generator Odd Behaviour
first time poster here. I usually like to find the answer myself (be it through research or trial-and-error), but I'm stumped here. What I'm trying to do: I'm building a simple and
Solution 1:
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!
Post a Comment for "Android Audio - Streaming Sine-tone Generator Odd Behaviour"