AUKit
|
The main AUKit module. More...
Classes | |
class | Audio |
The aukit.Audio class represents a chunk of audio with variable channels and sample rate. More... | |
class | effects |
Effects that can modify audio chunks. More... | |
class | Player |
An asynchronous player created by aukit.player . More... | |
class | stream |
Loader functions for streaming audio from a remote resource. These are usually used with aukit.play . More... | |
Public Member Functions | |
aukit Audio | adpcm (string ¦ table data, number? channels, number? sampleRate, boolean? topFirst, boolean? interleaved,(number ¦ table)? predictor,(number ¦ table)? step_index) |
Creates a new audio object from IMA ADPCM data. (true) or last (false); ignored if data is a table. | |
aukit Audio | aiff (string data, boolean head) |
Creates a new audio object from an AIFF or AIFC file. | |
aukit Audio | au (string data) |
Creates a new audio object from an AU file. | |
string ¦ nil‚ number ¦ nil‚ string ¦ nil | detect (string data) |
Detect the type of audio file from the specified data. This uses heuristic detection methods to attempt to find the correct data type for files without headers. It is not recommended to rely on the data type/bit depth reported for PCM files - they are merely a suggestion. | |
aukit Audio | dfpwm (string data, number? channels, number? sampleRate) |
Creates a new audio object from DFPWM1a data. All channels are expected to share the same decoder, and are stored interleaved in a single stream. | |
aukit Audio | flac (string data, boolean head) |
Creates a new audio object from a FLAC file. | |
aukit Audio | g711 (string data, boolean ulaw, number? channels, number? sampleRate) |
Creates a new audio object from G.711 u-law/A-law data. | |
aukit Audio | mdfpwm (string data, boolean head) |
Creates a new audio object from MDFPWMv3 data. | |
aukit Audio | msadpcm (string data, number blockAlign, number? channels, number? sampleRate, table? coefficients) |
Creates a new audio object from Microsoft ADPCM data. | |
aukit Audio | new (number duration, number? channels, number? sampleRate) |
Creates a new empty audio object with the specified duration. | |
aukit Audio | noise (number duration, number? amplitude, number? channels, number? sampleRate) |
Creates a new audio object with white noise for the specified duration. | |
string | pack (number❲❳ data, number? bitDepth,("float" ¦ "signed" ¦ "unsigned")? dataType, boolean? bigEndian) |
Packs a table with PCM data into a string using the specified data type. | |
aukit Audio | pcm (string ¦ table data, number? bitDepth,("float" ¦ "signed" ¦ "unsigned")? dataType, number? channels, number? sampleRate, boolean? interleaved, boolean? bigEndian) |
Creates a new audio object from the specified raw PCM data. of values (in the format specified by bitDepth and dataType ) | |
play (fun() →number❲❳❲❳ ¦ nil callback, fun(pos→ number)? progress, number? volume, ❴ playAudio→ fun(samples→ number❲❳‚ volume?→ number) ❵ ...) | |
Plays back stream functions created by one of the aukit.stream functions or Audio.stream . the caller; if omitted then this argument is the first speaker this argument is the second speaker (if provided) | |
aukit Player | player (Taskmaster loop, fun() →number❲❳❲❳ ¦ nil callback, number? volume, ❴ playAudio→ fun(samples→ number❲❳‚ volume?→ number) ❵ ...) |
Creates a player object that runs asynchronously. This requires the Taskmaster library to function. this argument is the second speaker (if provided) | |
aukit Audio | tone (number frequency, number duration, number? amplitude,("sawtooth" ¦ "sine" ¦ "square" ¦ "triangle")? waveType, number? duty, number? channels, number? sampleRate) |
Creates a new audio object with a tone of the specified frequency and duration. | |
aukit Audio | wav (string data, boolean head) |
Creates a new audio object from a WAV file. This accepts PCM files up to 32 bits, including float data, as well as DFPWM files as specified here, plus IMA and Microsoft ADPCM formats and G.711 u-law/A-law. | |
Public Attributes | |
string | _VERSION |
The version of AUKit that is loaded. This follows SemVer format. | |
cubic ¦ linear ¦ none ¦ sinc | defaultInterpolation |
Default interpolation mode for Audio.resample and other functions that need to resample. | |
aukit effects | effects |
Effects that can modify audio chunks. | |
aukit stream | stream |
Loader functions for streaming audio from a remote resource. These are usually used with aukit.play . | |
The main AUKit module.
aukit Audio aukit::adpcm | ( | string ¦ table | data, |
number? | channels, | ||
number? | sampleRate, | ||
boolean? | topFirst, | ||
boolean? | interleaved, | ||
(number ¦ table)? | predictor, | ||
(number ¦ table)? | step_index ) |
Creates a new audio object from IMA ADPCM data. (true) or last (false); ignored if data
is a table.
data | (string ¦ table) The audio data, either as a raw string, or a table of nibbles |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
topFirst | (boolean?) Whether the top nibble is the first nibble |
interleaved | (boolean?) Whether each channel is interleaved or separate |
predictor | ((number ¦ table)?) The initial predictor value(s) |
step_index | ((number ¦ table)?) The initial step index(es) |
Creates a new audio object from an AIFF or AIFC file.
data | (string) The AIFF data to load |
head | (boolean) Whether to only load metadata (header data) - this will not decode the audio |
Creates a new audio object from an AU file.
data | (string) The AU data to load |
string ¦ nil‚ number ¦ nil‚ string ¦ nil aukit::detect | ( | string | data | ) |
Detect the type of audio file from the specified data. This uses heuristic detection methods to attempt to find the correct data type for files without headers. It is not recommended to rely on the data type/bit depth reported for PCM files - they are merely a suggestion.
data | (string) The audio file to check |
nil
if none could be found ("pcm" ¦ "dfpwm" ¦ "mdfpwm" ¦ "wav" ¦ "aiff" ¦ "au" ¦ "flac") Creates a new audio object from DFPWM1a data. All channels are expected to share the same decoder, and are stored interleaved in a single stream.
data | (string) The audio data as a raw string |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
Creates a new audio object from a FLAC file.
data | (string) The FLAC data to load |
head | (boolean) Whether to only load metadata (header data) - this will not decode the audio |
Creates a new audio object from G.711 u-law/A-law data.
data | (string) The audio data as a raw string |
ulaw | (boolean) Whether the audio uses u-law (true) or A-law (false). |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
Creates a new audio object from MDFPWMv3 data.
data | (string) The audio data as a raw string |
head | (boolean) Whether to only load metadata (header data) - this will not decode the audio |
aukit Audio aukit::msadpcm | ( | string | data, |
number | blockAlign, | ||
number? | channels, | ||
number? | sampleRate, | ||
table? | coefficients ) |
Creates a new audio object from Microsoft ADPCM data.
data | (string) The audio data as a raw string |
blockAlign | (number) The number of bytes in each block |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
coefficients | (table?) Two lists of coefficients to use |
Creates a new empty audio object with the specified duration.
duration | (number) The length of the audio in seconds |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
aukit Audio aukit::noise | ( | number | duration, |
number? | amplitude, | ||
number? | channels, | ||
number? | sampleRate ) |
Creates a new audio object with white noise for the specified duration.
duration | (number) The length of the audio in seconds |
amplitude | (number?) The amplitude of the audio from 0.0 to 1.0 |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
string aukit::pack | ( | number❲❳ | data, |
number? | bitDepth, | ||
("float" ¦ "signed" ¦ "unsigned")? | dataType, | ||
boolean? | bigEndian ) |
Packs a table with PCM data into a string using the specified data type.
data | (number❲❳) The PCM data to pack |
bitDepth | (number?) The bit depth of the audio (8, 16, 24, 32); if dataType is "float" then this must be 32 |
dataType | (("float" ¦ "signed" ¦ "unsigned")?) The type of each sample |
bigEndian | (boolean?) Whether the data should be big-endian or little-endian |
aukit Audio aukit::pcm | ( | string ¦ table | data, |
number? | bitDepth, | ||
("float" ¦ "signed" ¦ "unsigned")? | dataType, | ||
number? | channels, | ||
number? | sampleRate, | ||
boolean? | interleaved, | ||
boolean? | bigEndian ) |
Creates a new audio object from the specified raw PCM data. of values (in the format specified by bitDepth
and dataType
)
data | (string ¦ table) The audio data, either as a raw string, or a table |
bitDepth | (number?) The bit depth of the audio (8, 16, 24, 32); if dataType is "float" then this must be 32 |
dataType | (("float" ¦ "signed" ¦ "unsigned")?) The type of each sample |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
interleaved | (boolean?) Whether each channel is interleaved or separate |
bigEndian | (boolean?) Whether the audio is big-endian or little-endian; ignored if data is a table |
aukit::play | ( | fun() →number❲❳❲❳ ¦ nil | callback, |
fun(pos→ number)? | progress, | ||
number? | volume, | ||
❴ playAudio→ fun(samples→ number❲❳‚ volume?→ number) | ❵ ... ) |
Plays back stream functions created by one of the aukit.stream
functions or Audio.stream
. the caller; if omitted then this argument is the first speaker this argument is the second speaker (if provided)
callback | (fun()→number❲❳❲❳ ¦ nil) The iterator function that returns each chunk |
progress | (fun(pos→ number)?) A callback to report progress to |
volume | (number?) The volume to play the audio at; if omitted then |
... | (❴ playAudio→ fun(samples→ number❲❳‚ volume?→ number) ❵) The speakers to play on |
aukit Player aukit::player | ( | Taskmaster | loop, |
fun() →number❲❳❲❳ ¦ nil | callback, | ||
number? | volume, | ||
❴ playAudio→ fun(samples→ number❲❳‚ volume?→ number) | ❵ ... ) |
Creates a player object that runs asynchronously. This requires the Taskmaster library to function. this argument is the second speaker (if provided)
loop | (Taskmaster) The Taskmaster loop to start the player on |
callback | (fun()→number❲❳❲❳ ¦ nil) The iterator function that returns each chunk |
volume | (number?) The volume to play the audio at; if omitted then |
... | (❴ playAudio→ fun(samples→ number❲❳‚ volume?→ number) ❵) The speakers to play on |
aukit Audio aukit::tone | ( | number | frequency, |
number | duration, | ||
number? | amplitude, | ||
("sawtooth" ¦ "sine" ¦ "square" ¦ "triangle")? | waveType, | ||
number? | duty, | ||
number? | channels, | ||
number? | sampleRate ) |
Creates a new audio object with a tone of the specified frequency and duration.
frequency | (number) The frequency of the tone in Hertz |
duration | (number) The length of the audio in seconds |
amplitude | (number?) The amplitude of the audio from 0.0 to 1.0 |
waveType | (("sawtooth" ¦ "sine" ¦ "square" ¦ "triangle")?) The type of wave to generate |
duty | (number?) The duty cycle of the square wave if selected; ignored otherwise |
channels | (number?) The number of channels present in the audio |
sampleRate | (number?) The sample rate of the audio in Hertz |
Creates a new audio object from a WAV file. This accepts PCM files up to 32 bits, including float data, as well as DFPWM files as specified here, plus IMA and Microsoft ADPCM formats and G.711 u-law/A-law.
data | (string) The WAV data to load |
head | (boolean) Whether to only load metadata (header data) - this will not decode the audio |