Skip to content
Proyek

Tentang

:sound: [Android Library] Easily generate audio tone of a specific frequency and volume in Android.

Desain dan media

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
0
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Image

Maven Central GitHub stars GitHub forks GitHub watchers

Android Weekly - #675 Kotlin Weekly - #462

GitHub followers Follow me on Bluesky Share on Bluesky

Easily generate audio tone of a specific frequency and volume in Android.

Quick Start

val zenTone = ZenTone()

zenTone.play(frequency = 440f, volume = 10)

Use playbackCount = 0 for unlimited playback, or pass a positive number such as 1 or 2 to stop automatically after that many generated signal writes.

ZenTone accepts the following audio configuration parameters:

  • sampleRate: defaults to SampleRate.Hz44100; supported sample rates are exposed through the SampleRate enum
  • channelMask: defaults to AudioFormat.CHANNEL_OUT_MONO; supports AudioFormat.CHANNEL_OUT_MONO and AudioFormat.CHANNEL_OUT_STEREO

Example:

val zenTone = ZenTone(
    sampleRate = SampleRate.Hz48000,
    channelMask = AudioFormat.CHANNEL_OUT_STEREO
)

If you need to override the PCM encoding, use the advanced factory:

val zenTone = ZenTone.advanced(
    sampleRate = SampleRate.Hz44100,
    encoding = AudioFormat.ENCODING_PCM_8BIT,
    channelMask = AudioFormat.CHANNEL_OUT_MONO
)

encoding defaults to AudioFormat.ENCODING_PCM_16BIT; supported values are AudioFormat.ENCODING_PCM_8BIT and AudioFormat.ENCODING_PCM_16BIT.

Waveform generation honors the configured sample rate, PCM encoding, and channel layout.

Built-in wave generators are instantiated per playback, for example SineWaveGenerator(), SquareWaveGenerator(), TriangleWaveGenerator(), SawtoothWaveGenerator() and PulseWaveGenerator().

Checkout

Screenshot of Sample App

Sample App

Star History

License

Licensed under the Apache License, Version 2.0.

Copyright 2016 Nishant Srivastava

Logo

Credit: Audio icons created by Freepik - Flaticon

Jelajahi proyek terkait

Memuat…