AudioEffectCapture

Inherits:AudioEffect<Resource<RefCounted<Object

Captures audio from an audio bus in real-time.

Description

AudioEffectCapture is an AudioEffect which copies all audio frames from the attached audio effect bus into its internal ring buffer.

Application code should consume these audio frames from this ring buffer usingget_buffer() and process it as needed, for example to capture data from anAudioStreamMicrophone, implement application-defined effects, or to transmit audio over the network. When capturing audio data from a microphone, the format of the samples will be stereo 32-bit floating-point PCM.

UnlikeAudioEffectRecord, this effect only returns the raw audio samples instead of encoding them into anAudioStream.

Tutorials

Properties

float

buffer_length

0.1

Methods

bool

can_get_buffer(frames:int)const

void

clear_buffer()

PackedVector2Array

get_buffer(frames:int)

int

get_buffer_length_frames()const

int

get_discarded_frames()const

int

get_frames_available()const

int

get_pushed_frames()const


Property Descriptions

floatbuffer_length =0.1🔗

Length of the internal ring buffer, in seconds. Setting the buffer length will have no effect if already initialized.


Method Descriptions

boolcan_get_buffer(frames:int)const🔗

Returnstrue if at leastframes audio frames are available to read in the internal ring buffer.


voidclear_buffer()🔗

Clears the internal ring buffer.

Note: Calling this during a capture can cause the loss of samples which causes popping in the playback.


PackedVector2Arrayget_buffer(frames:int)🔗

Gets the nextframes audio samples from the internal ring buffer.

Returns aPackedVector2Array containing exactlyframes audio samples if available, or an emptyPackedVector2Array if insufficient data was available.

The samples are signed floating-point PCM between-1 and1. You will have to scale them if you want to use them as 8 or 16-bit integer samples. (v=0x7fff*samples[0].x)


intget_buffer_length_frames()const🔗

Returns the total size of the internal ring buffer in frames.


intget_discarded_frames()const🔗

Returns the number of audio frames discarded from the audio bus due to full buffer.


intget_frames_available()const🔗

Returns the number of frames available to read usingget_buffer().


intget_pushed_frames()const🔗

Returns the number of audio frames inserted from the audio bus.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.