Skip to main content

Decoder

Description:

  An object which can gradually decode a sound file.

type

Type: Function.

Description:

  Gets the type of the object as a string.

Signature:

type: function(self: Decoder): string

Returns:

Return TypeDescription
stringThe type as a string.

Of

Type: Function.

Description:

  Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.

Signature:

typeOf: function(self: Decoder, type_name: string): boolean

Parameters:

ParameterTypeDescription
type_namestringThe name of the type to check for.

Returns:

Return TypeDescription
booleanTrue if the object is of the specified type, false otherwise.

release

Type: Function.

Description:

  Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector.

Signature:

release: function(self: Decoder): boolean

Returns:

Return TypeDescription
booleanTrue if the object was released by this call, false if it had been previously released.

clone

Type: Function.

Description:

  Creates a new copy of current decoder. The new decoder will start decoding from the beginning of the audio stream.

Signature:

clone: function(self: Decoder): Decoder

Returns:

Return TypeDescription
DecoderNew copy of the decoder.

getChannelCount

Type: Function.

Description:

  Returns the number of channels in the stream.

Signature:

getChannelCount: function(self: Decoder): integer
getChannels: function(self: Decoder): integer

Returns:

Return TypeDescription
integer1 for mono, 2 for stereo.

getBitDepth

Type: Function.

Description:

  Returns the number of bits per sample.

Signature:

getBitDepth: function(self: Decoder): integer

Returns:

Return TypeDescription
integerEither 8, or 16.

getSampleRate

Type: Function.

Description:

  Returns the sample rate of the Decoder.

Signature:

getSampleRate: function(self: Decoder): integer

Returns:

Return TypeDescription
integerNumber of samples per second.

getDuration

Type: Function.

Description:

  Gets the duration of the sound file. It may not always be sample-accurate, and it may return -1 if the duration cannot be determined at all.

Signature:

getDuration: function(self: Decoder): number

Returns:

Return TypeDescription
numberThe duration of the sound file in seconds, or -1 if it cannot be determined.

decode

Type: Function.

Description:

  Decodes the audio and returns a SoundData object containing the decoded audio data.

Signature:

decode: function(self: Decoder): SoundData | nil

Returns:

Return TypeDescription
SoundData or nilDecoded audio data.

seek

Type: Function.

Description:

  Sets the currently playing position of the Decoder.

Signature:

seek: function(self: Decoder, offset: number)

Parameters:

ParameterTypeDescription
offsetnumberThe position to seek to, in seconds.