Skip to main content

RecordingDevice

Description:

  Represents an audio input device capable of recording sounds.

type

Type: Function.

Description:

  Gets the type of the object as a string.

Signature:

type: function(self: RecordingDevice): 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: RecordingDevice, 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: RecordingDevice): boolean

Returns:

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

start

Type: Function.

Description:

  Begins recording audio using this device. Overload details:

  1. A ring buffer is used internally to store recorded data before RecordingDevice:getData or RecordingDevice:stop are called – the former clears the buffer. If the buffer completely fills up before getData or stop are called, the oldest data that doesn't fit into the buffer will be lost.

Signature:

start: function(self: RecordingDevice, samples?: integer, sample_rate?: integer, bit_depth?: integer, channels?: integer): boolean

Parameters:

ParameterTypeDescription
samplesintegerThe maximum number of samples to store in an internal ring buffer when recording.
sample_rateintegerThe number of samples per second to store when recording. (Default: 8000.)
bit_depthintegerThe number of bits per sample. (Default: 16.)
channelsintegerWhether to record in mono or stereo. Most microphones don't support more than 1 channel. (Default: 1.)

Returns:

Return TypeDescription
booleanTrue if the device successfully began recording using the specified parameters, false if not.

stop

Type: Function.

Description:

  Stops recording audio from this device. Any sound data currently in the device's buffer will be returned.

Signature:

stop: function(self: RecordingDevice): SoundData | nil

Returns:

Return TypeDescription
SoundData or nilThe sound data currently in the device's buffer, or nil if the device wasn't recording.

getData

Type: Function.

Description:

  Gets all recorded audio SoundData stored in the device's internal ring buffer. The internal ring buffer is cleared when this function is called, so calling it again will only get audio recorded after the previous call. If the device's internal ring buffer completely fills up before getData is called, the oldest data that doesn't fit into the buffer will be lost.

Signature:

getData: function(self: RecordingDevice): SoundData | nil

Returns:

Return TypeDescription
SoundData or nilThe recorded audio data, or nil if the device isn't recording.

getSampleCount

Type: Function.

Description:

  Gets the number of currently recorded samples.

Signature:

getSampleCount: function(self: RecordingDevice): integer

Returns:

Return TypeDescription
integerThe number of samples that have been recorded so far.

getSampleRate

Type: Function.

Description:

  Gets the number of samples per second currently being recorded.

Signature:

getSampleRate: function(self: RecordingDevice): integer

Returns:

Return TypeDescription
integerThe number of samples being recorded per second (sample rate).

getBitDepth

Type: Function.

Description:

  Gets the number of bits per sample in the data currently being recorded.

Signature:

getBitDepth: function(self: RecordingDevice): integer

Returns:

Return TypeDescription
integerThe number of bits per sample in the data that's currently being recorded.

getChannelCount

Type: Function.

Description:

  Gets the number of channels currently being recorded (mono or stereo).

Signature:

getChannelCount: function(self: RecordingDevice): integer

Returns:

Return TypeDescription
integerThe number of channels being recorded (1 for mono, 2 for stereo).

getName

Type: Function.

Description:

  Gets the name of the recording device.

Signature:

getName: function(self: RecordingDevice): string

Returns:

Return TypeDescription
stringThe name of the device.

isRecording

Type: Function.

Description:

  Gets whether the device is currently recording.

Signature:

isRecording: function(self: RecordingDevice): boolean

Returns:

Return TypeDescription
booleanTrue if the recording, false otherwise.