Class Audioeffectcapture - RST
Class Audioeffectcapture - RST
.. _class_AudioEffectCapture:
AudioEffectCapture
==================
**Inherits:** :ref:`AudioEffect<class_AudioEffect>`
**<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>`
**<** :ref:`Object<class_Object>`
.. rst-class:: classref-introduction-group
Description
-----------
Application code should consume these audio frames from this ring buffer
using :ref:`get_buffer<class_AudioEffectCapture_method_get_buffer>` and process it
as needed, for example to capture data from
an :ref:`AudioStreamMicrophone<class_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.
.. rst-class:: classref-introduction-group
Tutorials
---------
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+---------------------------
+-----------------------------------------------------------------------+---------+
| :ref:`float<class_float>`
| :ref:`buffer_length<class_AudioEffectCapture_property_buffer_length>` | ``0.1`` |
+---------------------------
+-----------------------------------------------------------------------+---------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
| :ref:`bool<class_bool>`
| :ref:`can_get_buffer<class_AudioEffectCapture_method_can_get_buffer>`\ (\
frames\: :ref:`int<class_int>`\ ) |const| |
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
| |void|
| :ref:`clear_buffer<class_AudioEffectCapture_method_clear_buffer>`\ (\ )
|
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
| :ref:`PackedVector2Array<class_PackedVector2Array>`
| :ref:`get_buffer<class_AudioEffectCapture_method_get_buffer>`\ (\
frames\: :ref:`int<class_int>`\ ) |
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
| :ref:`int<class_int>`
| :ref:`get_buffer_length_frames<class_AudioEffectCapture_method_get_buffer_length_
frames>`\ (\ ) |const| |
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
| :ref:`int<class_int>`
| :ref:`get_discarded_frames<class_AudioEffectCapture_method_get_discarded_frames>`
\ (\ ) |const| |
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
| :ref:`int<class_int>`
| :ref:`get_frames_available<class_AudioEffectCapture_method_get_frames_available>`
\ (\ ) |const| |
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
| :ref:`int<class_int>`
| :ref:`get_pushed_frames<class_AudioEffectCapture_method_get_pushed_frames>`\ (\ )
|const| |
+-----------------------------------------------------
+----------------------------------------------------------------------------------
-----------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_AudioEffectCapture_property_buffer_length:
.. rst-class:: classref-property
:ref:`float<class_float>` **buffer_length** =
``0.1`` :ref:`🔗<class_AudioEffectCapture_property_buffer_length>`
.. rst-class:: classref-property-setget
Length of the internal ring buffer, in seconds. Setting the buffer length will have
no effect if already initialized.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_AudioEffectCapture_method_can_get_buffer:
.. rst-class:: classref-method
Returns ``true`` if at least ``frames`` audio frames are available to read in the
internal ring buffer.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCapture_method_clear_buffer:
.. rst-class:: classref-method
|void| **clear_buffer**\
(\ ) :ref:`🔗<class_AudioEffectCapture_method_clear_buffer>`
\ **Note:** Calling this during a capture can cause the loss of samples which
causes popping in the playback.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCapture_method_get_buffer:
.. rst-class:: classref-method
:ref:`PackedVector2Array<class_PackedVector2Array>` **get_buffer**\ (\
frames\: :ref:`int<class_int>`\ ) :ref:`🔗<class_AudioEffectCapture_method_get_buffe
r>`
Gets the next ``frames`` audio samples from the internal ring buffer.
The samples are signed floating-point PCM between ``-1`` and ``1``. You will have
to scale them if you want to use them as 8 or 16-bit integer samples. (``v = 0x7fff
* samples[0].x``)
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCapture_method_get_buffer_length_frames:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_buffer_length_frames**\ (\ ) |
const| :ref:`🔗<class_AudioEffectCapture_method_get_buffer_length_frames>`
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCapture_method_get_discarded_frames:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_discarded_frames**\ (\ ) |
const| :ref:`🔗<class_AudioEffectCapture_method_get_discarded_frames>`
Returns the number of audio frames discarded from the audio bus due to full buffer.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCapture_method_get_frames_available:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_frames_available**\ (\ ) |
const| :ref:`🔗<class_AudioEffectCapture_method_get_frames_available>`
Returns the number of frames available to read
using :ref:`get_buffer<class_AudioEffectCapture_method_get_buffer>`.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCapture_method_get_pushed_frames:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_pushed_frames**\ (\ ) |
const| :ref:`🔗<class_AudioEffectCapture_method_get_pushed_frames>`
Returns the number of audio frames inserted from the audio bus.