mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
192 lines
11 KiB
ReStructuredText
192 lines
11 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. _class_AudioEffectCapture:
|
||
|
||
AudioEffectCapture
|
||
==================
|
||
|
||
**Наследует:** :ref:`AudioEffect<class_AudioEffect>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
||
|
||
Захватывает звук с аудио-шины в режиме реального времени.
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
Описание
|
||
----------------
|
||
|
||
AudioEffectCapture — это AudioEffect, который копирует все аудио-кадры из подключенной шины аудио-эффектов в свой внутренний кольцевой буфер.
|
||
|
||
Код приложения должен потреблять эти аудио-кадры из этого кольцевого буфера с помощью :ref:`get_buffer()<class_AudioEffectCapture_method_get_buffer>` и обрабатывать их по мере необходимости, например, для захвата данных из :ref:`AudioStreamMicrophone<class_AudioStreamMicrophone>`, реализации эффектов, определяемых приложением, или для передачи звука по сети. При захвате аудиоданных с микрофона формат сэмплов будет стерео PCM 32-бит с плавающей точкой.
|
||
|
||
В отличие от :ref:`AudioEffectRecord<class_AudioEffectRecord>`, этот эффект возвращает только необработанные аудио-сэмплы, а не кодирует их в :ref:`AudioStream<class_AudioStream>`.
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
Обучающие материалы
|
||
--------------------------------------
|
||
|
||
- :doc:`Аудиошины <../tutorials/audio/audio_buses>`
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
Свойства
|
||
----------------
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+---------------------------+-----------------------------------------------------------------------+---------+
|
||
| :ref:`float<class_float>` | :ref:`buffer_length<class_AudioEffectCapture_property_buffer_length>` | ``0.1`` |
|
||
+---------------------------+-----------------------------------------------------------------------+---------+
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
Методы
|
||
------------
|
||
|
||
.. 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
|
||
|
||
Описания свойств
|
||
--------------------------------
|
||
|
||
.. _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
|
||
|
||
- |void| **set_buffer_length**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_buffer_length**\ (\ )
|
||
|
||
Длина внутреннего кольцевого буфера в секундах. Установка длины буфера не даст никакого эффекта, если она уже инициализирована.
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
Описания метода
|
||
------------------------------
|
||
|
||
.. _class_AudioEffectCapture_method_can_get_buffer:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **can_get_buffer**\ (\ frames\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_AudioEffectCapture_method_can_get_buffer>`
|
||
|
||
Возвращает ``true``, если по крайней мере ``frames`` аудиокадров доступны для чтения во внутреннем кольцевом буфере.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioEffectCapture_method_clear_buffer:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **clear_buffer**\ (\ ) :ref:`🔗<class_AudioEffectCapture_method_clear_buffer>`
|
||
|
||
Очищает внутренний кольцевой буфер.
|
||
|
||
\ **Примечание:** Вызов этого во время захвата может привести к потере сэмплов, что приведет к хлопкам при воспроизведении.
|
||
|
||
.. 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_buffer>`
|
||
|
||
Получает следующие ``frames`` аудиосэмплов из внутреннего кольцевого буфера.
|
||
|
||
Возвращает :ref:`PackedVector2Array<class_PackedVector2Array>`, содержащий ровно ``frames`` аудиосэмплов, если они доступны, или пустой :ref:`PackedVector2Array<class_PackedVector2Array>`, если данных было недостаточно.
|
||
|
||
Сэмплы представляют собой PCM с плавающей точкой со знаком между ``-1`` и ``1``. Вам придется масштабировать их, если вы хотите использовать их как 8- или 16-битные целочисленные сэмплы. (``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>`
|
||
|
||
Возвращает количество аудио-кадров, отброшенных из аудио-шины из-за заполнения буфера.
|
||
|
||
.. 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>`
|
||
|
||
Возвращает количество кадров, доступных для чтения, с помощью :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>`
|
||
|
||
Возвращает количество аудиокадров, вставленных из аудиошины.
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (Этот метод обычно должен быть переопределен пользователем, чтобы иметь какой-либо эффект.)`
|
||
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
||
.. |const| replace:: :abbr:`const (Этот метод не имеет побочных эффектов. Он не изменяет ни одну из переменных-членов экземпляра.)`
|
||
.. |vararg| replace:: :abbr:`vararg (Этот метод принимает любое количество аргументов после описанных здесь.)`
|
||
.. |constructor| replace:: :abbr:`constructor (Этот метод используется для создания типа.)`
|
||
.. |static| replace:: :abbr:`static (Этот метод не нуждается в вызове экземпляра, поэтому его можно вызвать напрямую, используя имя класса.)`
|
||
.. |operator| replace:: :abbr:`operator (Этот метод описывает допустимый оператор для использования с этим типом в качестве левого операнда.)`
|
||
.. |bitfield| replace:: :abbr:`BitField (Это значение является целым числом, составленным как битовая маска следующих флагов.)`
|
||
.. |void| replace:: :abbr:`void (Нет возвращаемого значения.)`
|