AudioClip
classin packageklyn.audio
public class AudioClip
AudioClip

Finite, interleaved Float32 PCM, independent of any audio device or AI engine. Samples are retained, not copied; modifying the supplied array modifies this clip. Sample values need not be in [-1, 1]; playback may clip, WAV saving does not.

Example

clip = AudioClip.load(FilePath("speech.wav")); clip.play()

Properties
Modifier and Type Member Description
public readonly property channels
channels as Int
Samples per frame.
public readonly property duration
duration as Double
Duration in seconds.
public readonly property frames
frames as ULong
Number of complete frames, not interleaved scalar samples.
public readonly property sampleRate
sampleRate as Int
Frames per second, in Hz.
public readonly property samples
samples as Float[]
Interleaved Float32 samples; no implicit channel mixing.
Constructors
Modifier and Type Member Description
public AudioClip
AudioClip(notnull samples as Float[], sampleRate as Int, channels as Int = 1)
Retains an interleaved PCM buffer without copying.
Methods
Modifier and Type Member Description
public static load
load(notnull path as FilePath) as AudioClip
Reads RIFF/RF64 WAVE PCM8/16/24/32 or IEEE Float32; does not play it.
public play
play() as Void
Plays on the OS default output (speakers, headphones or configured device).
public save
save(notnull path as FilePath) as Void
Saves lossless IEEE Float32 WAV; no resampling, clipping or normalization.