Noise in background when generating sine wave in Java

后端 未结 2 591
孤城傲影
孤城傲影 2021-01-03 03:10

I\'m getting a slight distortion (sounds like buzzing) in the background when I run the following code. Because of its subtle nature it makes believe there is some sort of a

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-03 03:58

    I assume you are calling this code repeatedly to play a long sound.

    Is there a chance that the wave you are generating is not getting to complete a full period before it is written?

    If the wave gets "cut-off" before it completes a full period and then the next wave is written to the output, you will certainly hear something strange and I assume that may be what is causing the buzzing.

    For example:

            /-------\              /-------\              /-------\
      -----/         \       -----/         \       -----/         \
                      \                      \                      \
                       \-----                 \-----                 \-----
    

    Notice the disconnect between parts of this wave. That might be causing the buzzing.

提交回复
热议问题