Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 530 Bytes

README.md

File metadata and controls

20 lines (17 loc) · 530 Bytes

Deeply Audio Utils

val sampleRate = 16000
val audioSamples: ShortArray = AudioUtils.generateToneSamples(
    freqHz = 400.0,
    durationMs = 1000,
    sampleRate = sampleRate
)

// play the raw audio samples
val audioTrack = RawAudio.from(audioSamples, sampleRate, AudioChannel.MONO, AudioEncoding.PCM_16BIT)
    .toAudioTrack()
audioTrack.play()

// export to a wav file
val wavFile = File("hello.wav")
RawAudio.from(audioSamples, sampleRate, AudioChannel.MONO, AudioEncoding.PCM_16BIT)
    .toWavFile(wavFile)