Android: Sine Wave Generation

前端 未结 3 1277
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 10:39

I\'m trying to use AudioTrack to generate sine, square, and sawtooth waves. However, the audio this is creating doesn\'t sound like a pure sine wave, but like it has some kind o

3条回答
  •  故里飘歌
    2021-02-08 11:22

    Try to optimise your code by

    1. increase buffer size
    2. prepare the buffer once, and keep rewriting it to the output stream (this will require some math calculating the perfect size for the buffer to make sure that the whole sine wave fits perfectly in it).

    Why? Because I suspect the buffer to taking to long to prepare, what causes a lag between two buffer pushes to big, which might be causing the noise.

提交回复
热议问题