AUKit
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | List of all members
aukit Class Reference

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.
 

Detailed Description

The main AUKit module.

Member Function Documentation

◆ adpcm()

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.

Parameters
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)
Returns
(aukit.Audio) A new audio object containing the decoded data

◆ aiff()

aukit Audio aukit::aiff ( string data,
boolean head )

Creates a new audio object from an AIFF or AIFC file.

Parameters
data(string) The AIFF data to load
head(boolean) Whether to only load metadata (header data) - this will not decode the audio
Returns
(aukit.Audio) A new audio object with the contents of the AIFF file

◆ au()

aukit Audio aukit::au ( string data)

Creates a new audio object from an AU file.

Parameters
data(string) The AU data to load
Returns
(aukit.Audio) A new audio object with the contents of the AU file

◆ detect()

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.

Parameters
data(string) The audio file to check
Returns
(string ¦ nil) The type of audio file detected‚ or nil if none could be found ("pcm" ¦ "dfpwm" ¦ "mdfpwm" ¦ "wav" ¦ "aiff" ¦ "au" ¦ "flac")
(number ¦ nil) The bit depth for PCM data‚ if the type is "pcm" and the bit depth can be detected
(string ¦ nil) The data type for PCM data‚ if the type is "pcm" and the type can be detected ("signed" ¦ "unsigned" ¦ "float")

◆ dfpwm()

aukit Audio aukit::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.

Parameters
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
Returns
(aukit.Audio) A new audio object containing the decoded data

◆ flac()

aukit Audio aukit::flac ( string data,
boolean head )

Creates a new audio object from a FLAC file.

Parameters
data(string) The FLAC data to load
head(boolean) Whether to only load metadata (header data) - this will not decode the audio
Returns
(aukit.Audio) A new audio object with the contents of the FLAC file

◆ g711()

aukit Audio aukit::g711 ( string data,
boolean ulaw,
number? channels,
number? sampleRate )

Creates a new audio object from G.711 u-law/A-law data.

Parameters
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
Returns
(aukit.Audio) A new audio object containing the decoded data

◆ mdfpwm()

aukit Audio aukit::mdfpwm ( string data,
boolean head )

Creates a new audio object from MDFPWMv3 data.

Parameters
data(string) The audio data as a raw string
head(boolean) Whether to only load metadata (header data) - this will not decode the audio
Returns
(aukit.Audio) A new audio object containing the decoded data

◆ msadpcm()

aukit Audio aukit::msadpcm ( string data,
number blockAlign,
number? channels,
number? sampleRate,
table? coefficients )

Creates a new audio object from Microsoft ADPCM data.

Parameters
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
Returns
(aukit.Audio) A new audio object containing the decoded data

◆ new()

aukit Audio aukit::new ( number duration,
number? channels,
number? sampleRate )

Creates a new empty audio object with the specified duration.

Parameters
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
Returns
(aukit.Audio) The new empty audio object

◆ noise()

aukit Audio aukit::noise ( number duration,
number? amplitude,
number? channels,
number? sampleRate )

Creates a new audio object with white noise for the specified duration.

Parameters
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
Returns
(aukit.Audio) A new audio object with noise

◆ pack()

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.

dataType:
| "signed"
| "unsigned"
| "float"
Parameters
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
Returns
(string) The packed PCM data

◆ pcm()

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)

dataType:
| "signed"
| "unsigned"
| "float"
Parameters
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
Returns
(aukit.Audio) A new audio object containing the specified data

◆ play()

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)

Parameters
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

◆ player()

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)

Parameters
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
Returns
(aukit.Player) The player object to control playback with

◆ tone()

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.

waveType:
| "sine"
| "triangle"
| "sawtooth"
| "square"
Parameters
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
Returns
(aukit.Audio) A new audio object with the tone

◆ wav()

aukit Audio aukit::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.

Parameters
data(string) The WAV data to load
head(boolean) Whether to only load metadata (header data) - this will not decode the audio
Returns
(aukit.Audio) A new audio object with the contents of the WAV file

The documentation for this class was generated from the following file: