AUKit
|
The aukit.Audio class represents a chunk of audio with variable channels and sample rate. More...
Public Member Functions | |
number | channels () |
Returns the number of channels in the audio object. | |
aukit Audio | combine (aukit.Audio ...) |
Combines the channels of this audio object with another, adding the new channels on the end of the new object, resampling the new channels to match this one (if necessary), and extending any channels that are shorter than the longest channel with zeroes. | |
aukit Audio | concat (aukit.Audio ...) |
Concatenates this audio object with another, adding the contents of each new channel to the end of each old channel, resampling the new channels to match this one (if necessary), and inserting silence in any missing channels. | |
string | dfpwm (boolean? interleaved) |
Converts the audio data to DFPWM. All channels share the same encoder, and channels are stored sequentially uninterleaved if interleaved is false, or in one interleaved string if interleaved is true. if interleaved is true) | |
number | len () |
Returns the length of the audio object in seconds. | |
aukit Audio | mix (number ¦ Audio amplifier, aukit.Audio ...) |
Mixes two or more audio objects into a single object, amplifying each sample with a multiplier (before clipping) if desired, and clipping any values outside the audio range ([-1, 1]). Channels that are shorter are padded with zeroes at the end, and non-existent channels are replaced with all zeroes. Any audio objects with a different sample rate are resampled to match this one. | |
aukit Audio | mono () |
Mixes down all channels to a new mono-channel audio object. | |
number❲❳ ¦ nil | pcm (number? bitDepth,("float" ¦ "signed" ¦ "unsigned")? dataType, boolean? interleaved) |
Converts the audio data to raw PCM samples. | |
aukit Audio | rep (number count) |
Returns a new audio object that repeats this audio a number of times. | |
aukit Audio | resample (number sampleRate,("cubic" ¦ "linear" ¦ "none")? interpolation) |
Creates a new audio object with the data resampled to a different sample rate. If the target rate is the same, the object is copied without modification. | |
aukit Audio | reverse () |
Returns a reversed version of this audio. | |
aukit Audio | split (number❲❳ ...) |
Splits this audio object into one or more objects with the specified channels. Passing a channel that doesn't exist will throw an error. | |
function‚ number | stream (number? chunkSize, number? bitDepth,("float" ¦ "signed" ¦ "unsigned")? dataType) |
Returns a function that can be called to encode PCM samples in chunks. This is useful as a for iterator, and can be used with aukit.play . chunks of each channel's data as arrays of signed 8-bit 48kHz PCM, as well as the current position of the audio in seconds. | |
aukit Audio | sub (number? start, number? last) |
Takes a subregion of the audio and returns a new audio object with its contents. This takes the same arguments as string.sub , but positions start at 0. | |
string | wav (number? bitDepth) |
Coverts the audio data to a WAV file. | |
The aukit.Audio class represents a chunk of audio with variable channels and sample rate.
number aukit::Audio::channels | ( | ) |
Returns the number of channels in the audio object.
Combines the channels of this audio object with another, adding the new channels on the end of the new object, resampling the new channels to match this one (if necessary), and extending any channels that are shorter than the longest channel with zeroes.
... | (aukit.Audio) The audio objects to combine with |
Concatenates this audio object with another, adding the contents of each new channel to the end of each old channel, resampling the new channels to match this one (if necessary), and inserting silence in any missing channels.
... | (aukit.Audio) The audio objects to concatenate |
string aukit::Audio::dfpwm | ( | boolean? | interleaved | ) |
Converts the audio data to DFPWM. All channels share the same encoder, and channels are stored sequentially uninterleaved if interleaved
is false, or in one interleaved string if interleaved
is true. if interleaved
is true)
interleaved | (boolean?) Whether to interleave the channels |
number aukit::Audio::len | ( | ) |
Returns the length of the audio object in seconds.
Mixes two or more audio objects into a single object, amplifying each sample with a multiplier (before clipping) if desired, and clipping any values outside the audio range ([-1, 1]). Channels that are shorter are padded with zeroes at the end, and non-existent channels are replaced with all zeroes. Any audio objects with a different sample rate are resampled to match this one.
amplifier | (number ¦ Audio) The multiplier to apply, or the first audio object |
... | (aukit.Audio) The objects to mix with this one |
Mixes down all channels to a new mono-channel audio object.
number❲❳ ¦ nil aukit::Audio::pcm | ( | number? | bitDepth, |
("float" ¦ "signed" ¦ "unsigned")? | dataType, | ||
boolean? | interleaved ) |
Converts the audio data to raw PCM samples.
bitDepth | (number?) The bit depth of the audio (8, 16, 24, 32) |
dataType | (("float" ¦ "signed" ¦ "unsigned")?) The type of each sample |
interleaved | (boolean?) Whether to interleave each channel |
Returns a new audio object that repeats this audio a number of times.
count | (number) The number of times to play the audio |
aukit Audio aukit::Audio::resample | ( | number | sampleRate, |
("cubic" ¦ "linear" ¦ "none")? | interpolation ) |
Creates a new audio object with the data resampled to a different sample rate. If the target rate is the same, the object is copied without modification.
sampleRate | (number) The new sample rate in Hertz |
interpolation | (("cubic" ¦ "linear" ¦ "none")?) The interpolation mode to use |
Returns a reversed version of this audio.
Splits this audio object into one or more objects with the specified channels. Passing a channel that doesn't exist will throw an error.
local left, right = stereo:split({1}, {2})
... | (number❲❳) The lists of channels in each new object |
function‚ number aukit::Audio::stream | ( | number? | chunkSize, |
number? | bitDepth, | ||
("float" ¦ "signed" ¦ "unsigned")? | dataType ) |
Returns a function that can be called to encode PCM samples in chunks. This is useful as a for iterator, and can be used with aukit.play
. chunks of each channel's data as arrays of signed 8-bit 48kHz PCM, as well as the current position of the audio in seconds.
chunkSize | (number?) The size of each chunk |
bitDepth | (number?) The bit depth of the audio (8, 16, 24, 32) |
dataType | (("float" ¦ "signed" ¦ "unsigned")?) The type of each sample |
Takes a subregion of the audio and returns a new audio object with its contents. This takes the same arguments as string.sub
, but positions start at 0.
start | (number?) The start position of the audio in seconds |
last | (number?) The end position of the audio in seconds (0 means end of file) |
string aukit::Audio::wav | ( | number? | bitDepth | ) |
Coverts the audio data to a WAV file.
bitDepth | (number?) The bit depth of the audio (1 = DFPWM, 8, 16, 24, 32) |