git-subtree-dir: engine git-subtree-mainline:b74841629egit-subtree-split:a8e37fc010
69 lines
3.6 KiB
XML
69 lines
3.6 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="AudioEffectCapture" inherits="AudioEffect" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
|
<brief_description>
|
|
Exposes audio samples from an audio bus in real-time, such that it can be accessed as data.
|
|
</brief_description>
|
|
<description>
|
|
Copies all audio frames, also known as "samples" or "audio samples", from the attached audio bus into its internal ring buffer. This effect does not alter the audio. Can be used for storing real-time audio data for playback, and for creating real-time audio visualizations, like an oscilloscope.
|
|
Application code should consume these audio frames from this ring buffer using [method get_buffer] and process it as needed, for example to capture data from an [AudioStreamMicrophone], 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.
|
|
Unlike [AudioEffectRecord], this effect only returns the raw audio samples instead of encoding them into an [AudioStream].
|
|
</description>
|
|
<tutorials>
|
|
<link title="Audio buses">$DOCS_URL/tutorials/audio/audio_buses.html</link>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="can_get_buffer" qualifiers="const">
|
|
<return type="bool" />
|
|
<param index="0" name="frames" type="int" />
|
|
<description>
|
|
Returns [code]true[/code] if at least [param frames] samples are available to read in the internal ring buffer.
|
|
</description>
|
|
</method>
|
|
<method name="clear_buffer">
|
|
<return type="void" />
|
|
<description>
|
|
Clears the internal ring buffer.
|
|
[b]Note:[/b] Calling this during a capture can cause the loss of samples which causes popping in the playback.
|
|
</description>
|
|
</method>
|
|
<method name="get_buffer">
|
|
<return type="PackedVector2Array" />
|
|
<param index="0" name="frames" type="int" />
|
|
<description>
|
|
Gets the next [param frames] samples from the internal ring buffer.
|
|
Returns a [PackedVector2Array] containing exactly [param frames] samples if available, or an empty [PackedVector2Array] if insufficient data was available.
|
|
The samples are signed floating-point PCM between [code]-1[/code] and [code]1[/code]. You will have to scale them if you want to use them as 8 or 16-bit integer samples. ([code]v = 0x7fff * samples[0].x[/code])
|
|
</description>
|
|
</method>
|
|
<method name="get_buffer_length_frames" qualifiers="const">
|
|
<return type="int" />
|
|
<description>
|
|
Returns the total size of the internal ring buffer in number of samples.
|
|
</description>
|
|
</method>
|
|
<method name="get_discarded_frames" qualifiers="const">
|
|
<return type="int" />
|
|
<description>
|
|
Returns the number of samples discarded from the audio bus due to full buffer.
|
|
</description>
|
|
</method>
|
|
<method name="get_frames_available" qualifiers="const">
|
|
<return type="int" />
|
|
<description>
|
|
Returns the number of samples available to read using [method get_buffer].
|
|
</description>
|
|
</method>
|
|
<method name="get_pushed_frames" qualifiers="const">
|
|
<return type="int" />
|
|
<description>
|
|
Returns the number of samples inserted from the audio bus.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="buffer_length" type="float" setter="set_buffer_length" getter="get_buffer_length" default="0.1">
|
|
Length of the internal ring buffer, in seconds. Higher values keep data around for longer, but require more memory. Value can range from 0.01 to 10.
|
|
[b]Note:[/b] Setting the buffer length will have no effect if already initialized.
|
|
</member>
|
|
</members>
|
|
</class>
|