WavFile

class WavFile(file: File, bufferSize: Int) : AutoCloseable

Class for reading WAV audio files. The file opened as WAV file can be read only once and the following reading procedures will result in reading empty buffer.

Based on code written by Andrew Greensted but modified to more Kotlin idiomatic way with only read option for simplicity.

Parameters

file

to read the WAV file data from

Constructors

WavFile
Link copied to clipboard
fun WavFile(file: File, bufferSize: Int = 4096)

creates WavFile

Functions

close
Link copied to clipboard
open override fun close()
readFrames
Link copied to clipboard
fun readFrames(returnBuffer: Array<FloatArray>, count: Int, offset: Int = 0): Int

Read some number of frames from a specific offset in the buffer into a multi-dimensional float array.

readRemainingFrames
Link copied to clipboard
fun readRemainingFrames(): Array<FloatArray>

Read all remaining frames from WAV file and return them as an array of results for each of the channels of input file.

Properties

format
Link copied to clipboard
val format: WavFileFormat

File format specification with values from WavFileFormat

frames
Link copied to clipboard
val frames: Long

Number of frames present in full WAV file

remainingFrames
Link copied to clipboard
val remainingFrames: Long

Remaining frames that can be read to some external buffer from WAV file