Usage¶
Create an instance of ZenTone
:¶
ZenTone
accepts 3 arguments, each having a sensible default:
sampleRate
: Int = 44100encoding
: Int = AudioFormat.ENCODING_PCM_16BITchannelMask
: Int = AudioFormat.CHANNEL_OUT_MONO
based on your requirement, you can pass a different value when instantiating ZenTone
i.e
Start playing audio with a frequency and volume:¶
play()
accepts 3 arguments:
frequency
: Floatvolume
: Int. It ranges from 0 to 100, where 0 is no audio and 100 is full volume.waveByteArrayGenerator
: WaveByteArrayGenerator = SineWaveGenerator, hereSineWaveGenerator
is a sensible default.- POssible options are
SineWaveGenerator
,SquareWaveGenerator
andTriangleWaveGenerator
based on your requirement, you can pass a different value when calling play()
i.e
Stop playing audio:¶
To release resources held by ZenTone
i.e release mic, you can call release()
function.
Usually you'll need to call this in onDestroy()
: