Skip to main content

SoundModule

Description:

  This module is responsible for decoding sound files. It can't play the sounds, see love.audio for that.

newDecoder

Type: Function.

Description:

  Attempts to find a decoder for the encoded sound data in the specified file.

Signature:

newDecoder: function(filename: string, buffer_size?: integer): Decoder

Parameters:

ParameterTypeDescription
filenamestringThe filename of the file with encoded sound data.
buffer_sizeintegerThe size of each decoded chunk, in bytes. (Default: 2048.)

Returns:

Return TypeDescription
Decoderdecoder — A new Decoder object.

newDecoder

Type: Function.

Description:

  Attempts to find a decoder for the encoded sound data in the specified file.

Signature:

newDecoder: function(data: FileData, buffer_size?: integer): Decoder

Parameters:

ParameterTypeDescription
dataFileDataThe filename of the file with encoded sound data.
buffer_sizeintegerThe size of each decoded chunk, in bytes. (Default: 2048.)

Returns:

Return TypeDescription
Decoderdecoder — A new Decoder object.

newSoundData

Type: Function.

Description:

  Creates new SoundData from a filepath, File, or Decoder. It's also possible to create SoundData with a custom sample rate, channel and bit depth.

-- The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way.

Signature:

newSoundData: function(samples: number, sample_rate?: integer, bit_depth?: integer, channels?: integer): SoundData

Parameters:

ParameterTypeDescription
samplesnumberTotal number of samples.
sample_rateintegerNumber of samples per second (Default: 44100.)
bit_depthintegerBits per sample (8 or 16). (Default: 16.)
channelsintegerEither 1 for mono or 2 for stereo. (Default: 2.)

Returns:

Return TypeDescription
SoundDatasoundData — A new SoundData object.

newSoundData

Type: Function.

Description:

  Creates new SoundData from a filepath, File, or Decoder. It's also possible to create SoundData with a custom sample rate, channel and bit depth.

-- The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way.

Signature:

newSoundData: function(filename: string, buffer_size?: integer): SoundData

Parameters:

ParameterTypeDescription
filenamestringThe file name of the file to load.
buffer_sizeintegerNumber of samples per second (Default: 44100.)

Returns:

Return TypeDescription
SoundDatasoundData — A new SoundData object.

newSoundData

Type: Function.

Description:

  Creates new SoundData from a filepath, File, or Decoder. It's also possible to create SoundData with a custom sample rate, channel and bit depth.

-- The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way.

Signature:

newSoundData: function(data: FileData, buffer_size?: integer): SoundData

Parameters:

ParameterTypeDescription
dataFileDataDecode data from this Decoder until EOF.
buffer_sizeintegerNumber of samples per second (Default: 44100.)

Returns:

Return TypeDescription
SoundDatasoundData — A new SoundData object.

newSoundData

Type: Function.

Description:

  Creates new SoundData from a filepath, File, or Decoder. It's also possible to create SoundData with a custom sample rate, channel and bit depth.

-- The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way.

Signature:

newSoundData: function(decoder: Decoder): SoundData

Parameters:

ParameterTypeDescription
decoderDecoderDecode data from this Decoder until EOF.

Returns:

Return TypeDescription
SoundDatasoundData — A new SoundData object.