AudioSamples
Decoded audio: frameCount frames of 32-bit float samples, each frame holding one value per channel, played at sampleRate frames per second. Samples are nominally in -1..1.
This constructor copies its samples, which must be interleaved by channel: for stereo, left then right for each frame. Decode a WAV or Ogg Vorbis file with AudioSamples.decode instead.
Throws
if channels is not 1 or 2, sampleRate is not positive, or the size of the 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")Constructors
Creates audio from a copy of samples, interleaved by channel, that plays at sampleRate frames per second. Pass the Int parameters by name.
Types
Properties
Returns how long the samples last when played at sampleRate, rounded down to the nanosecond.
Returns the number of frames, each holding one sample per channel.
Returns the number of frames per second the samples are meant to play at.
Functions
Returns a copy of the samples, interleaved by channel: frameCount frames of channels values each, meant to play at sampleRate. Changing the copy does not change the receiver.