AudioClip

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstancenot creatablecomingAudio

Up and coming

Sound in memory as samples: crop it, resample it, draw its waveform and save it for upload.

AudioService's LoadAsync and CreateClip give one, at the file's own sample rate, channels and bit depth. Samples run from -1 to 1 with 1-based indexes, channel 1 by default. SaveAsync writes .wav directly and .ogg and .mp3 through ffmpeg, whose exit code is always checked.

Properties

NameTypeDefaultDescription
SampleRatenumberSamples per second, kept from the file.
Channelsnumber
SampleCountnumberread-only
TimeLengthnumberread-onlyLength in seconds.

Methods

NameArgumentsReturnsDescription
GetSample(index: number, channel: number?)numberOne sample from -1 to 1, by 1-based index; channel 1 by default.
SetSample(index: number, value: number, channel: number?)()
ReadSamplesBuffer(channel: number, first: number, count: number)bufferReads count samples of the channel from first into a buffer of 32-bit floats.
WriteSamplesBuffer(channel: number, first: number, samples: buffer)()
GetValueAtTime(time: number, channel: number?)numberThe value at a time in seconds, linear between samples.
Crop(first: number, last: number)AudioClip
CropTime(startTime: number, endTime: number)AudioClip
Resample(sampleRate: number)AudioClip
GetPeaks(buckets: number, channel: number?)bufferThe min and max of each bucket as 32-bit floats, for drawing a waveform.
EncodeWav(bits: number?)bufferThe clip as WAV bytes, at 16 or 32 bits.
SaveAsync
yields
(path: string)(boolean, string?)Writes .wav directly, and .ogg and .mp3 through ffmpeg.
From ShotInstance 33