Audio Format
The AudioFormat class defines technical specifications for audio data.
AudioFormat
data class AudioFormat(
val sampleRate: Int, // Hz
val channels: Channels, // Mono or Stereo
val encoding: SampleEncoding
)
Creating custom formats
val format = AudioFormat(
sampleRate = 48000,
channels = Channels.Stereo,
encoding = SampleEncoding.PcmInt(IntBitDepth.Sixteen)
)
Channels
MonoSingle channel (1)
StereoLeft and right (2)
Bit depths
Eight8-bit (48 dB range)
Sixteen16-bit (96 dB range) - standard
TwentyFour24-bit (144 dB range) - professional
ThirtyTwo32-bit (192 dB range)
Computed properties
bytesPerSampleBytes for one sample
bytesPerFrameBytes for one frame (all channels)
Last modified: 13 January 2026