Playing an arbitrary tone with Android

后端 未结 10 2270
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 10:38

Is there any way to make Android emit a sound of arbitrary frequency (meaning, I don\'t want to have pre-recorded sound files)?

I\'ve looked around and ToneGenerator

10条回答
  •  星月不相逢
    2020-11-22 10:47

    see this helpful library

    https://github.com/karlotoy/perfectTune

    it's easy to use

    add this to your dependencies

     compile 'com.github.karlotoy:perfectTune:1.0.2'
    

    And you use it like this:

    PerfectTune perfectTune = new PerfectTune();
    perfectTune.setTuneFreq(desire_freq);
    perfectTune.playTune();
    

    to stop the tune:

    perfectTune.stopTune();
    

提交回复
热议问题