AudioSamples

constructor(samples: FloatArray, channels: Int, sampleRate: Int)(source)

Creates audio from a copy of samples, interleaved by channel, that plays at sampleRate frames per second. Pass the Int parameters by name.

Throws

if channels is not 1 or 2, sampleRate is not positive, or the size of samples is not a multiple of channels.

Samples

// Two stereo frames: left then right for each.
val samples = AudioSamples(floatArrayOf(0.1f, -0.1f, 0.5f, -0.5f), channels = 2, sampleRate = 48000)
assertPrints(samples.frameCount, "2")
assertPrints(samples[1, 0], "0.5")
assertPrints(samples[1, 1], "-0.5")