class_audioeffectcapture.rst 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AudioEffectCapture.xml.
  6. .. _class_AudioEffectCapture:
  7. AudioEffectCapture
  8. ==================
  9. **Inherits:** :ref:`AudioEffect<class_AudioEffect>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Captures audio from an audio bus in real-time.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. AudioEffectCapture is an AudioEffect which copies all audio frames from the attached audio effect bus into its internal ring buffer.
  15. 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.
  16. Unlike :ref:`AudioEffectRecord<class_AudioEffectRecord>`, this effect only returns the raw audio samples instead of encoding them into an :ref:`AudioStream<class_AudioStream>`.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Audio buses <../tutorials/audio/audio_buses>`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +---------------------------+-----------------------------------------------------------------------+---------+
  27. | :ref:`float<class_float>` | :ref:`buffer_length<class_AudioEffectCapture_property_buffer_length>` | ``0.1`` |
  28. +---------------------------+-----------------------------------------------------------------------+---------+
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`can_get_buffer<class_AudioEffectCapture_method_can_get_buffer>`\ (\ frames\: :ref:`int<class_int>`\ ) |const| |
  36. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  37. | |void| | :ref:`clear_buffer<class_AudioEffectCapture_method_clear_buffer>`\ (\ ) |
  38. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`get_buffer<class_AudioEffectCapture_method_get_buffer>`\ (\ frames\: :ref:`int<class_int>`\ ) |
  40. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_buffer_length_frames<class_AudioEffectCapture_method_get_buffer_length_frames>`\ (\ ) |const| |
  42. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`get_discarded_frames<class_AudioEffectCapture_method_get_discarded_frames>`\ (\ ) |const| |
  44. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`get_frames_available<class_AudioEffectCapture_method_get_frames_available>`\ (\ ) |const| |
  46. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_pushed_frames<class_AudioEffectCapture_method_get_pushed_frames>`\ (\ ) |const| |
  48. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  49. .. rst-class:: classref-section-separator
  50. ----
  51. .. rst-class:: classref-descriptions-group
  52. Property Descriptions
  53. ---------------------
  54. .. _class_AudioEffectCapture_property_buffer_length:
  55. .. rst-class:: classref-property
  56. :ref:`float<class_float>` **buffer_length** = ``0.1`` :ref:`🔗<class_AudioEffectCapture_property_buffer_length>`
  57. .. rst-class:: classref-property-setget
  58. - |void| **set_buffer_length**\ (\ value\: :ref:`float<class_float>`\ )
  59. - :ref:`float<class_float>` **get_buffer_length**\ (\ )
  60. Length of the internal ring buffer, in seconds. Setting the buffer length will have no effect if already initialized.
  61. .. rst-class:: classref-section-separator
  62. ----
  63. .. rst-class:: classref-descriptions-group
  64. Method Descriptions
  65. -------------------
  66. .. _class_AudioEffectCapture_method_can_get_buffer:
  67. .. rst-class:: classref-method
  68. :ref:`bool<class_bool>` **can_get_buffer**\ (\ frames\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_AudioEffectCapture_method_can_get_buffer>`
  69. Returns ``true`` if at least ``frames`` audio frames are available to read in the internal ring buffer.
  70. .. rst-class:: classref-item-separator
  71. ----
  72. .. _class_AudioEffectCapture_method_clear_buffer:
  73. .. rst-class:: classref-method
  74. |void| **clear_buffer**\ (\ ) :ref:`🔗<class_AudioEffectCapture_method_clear_buffer>`
  75. Clears the internal ring buffer.
  76. \ **Note:** Calling this during a capture can cause the loss of samples which causes popping in the playback.
  77. .. rst-class:: classref-item-separator
  78. ----
  79. .. _class_AudioEffectCapture_method_get_buffer:
  80. .. rst-class:: classref-method
  81. :ref:`PackedVector2Array<class_PackedVector2Array>` **get_buffer**\ (\ frames\: :ref:`int<class_int>`\ ) :ref:`🔗<class_AudioEffectCapture_method_get_buffer>`
  82. Gets the next ``frames`` audio samples from the internal ring buffer.
  83. Returns a :ref:`PackedVector2Array<class_PackedVector2Array>` containing exactly ``frames`` audio samples if available, or an empty :ref:`PackedVector2Array<class_PackedVector2Array>` if insufficient data was available.
  84. 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``)
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_AudioEffectCapture_method_get_buffer_length_frames:
  88. .. rst-class:: classref-method
  89. :ref:`int<class_int>` **get_buffer_length_frames**\ (\ ) |const| :ref:`🔗<class_AudioEffectCapture_method_get_buffer_length_frames>`
  90. Returns the total size of the internal ring buffer in frames.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_AudioEffectCapture_method_get_discarded_frames:
  94. .. rst-class:: classref-method
  95. :ref:`int<class_int>` **get_discarded_frames**\ (\ ) |const| :ref:`🔗<class_AudioEffectCapture_method_get_discarded_frames>`
  96. Returns the number of audio frames discarded from the audio bus due to full buffer.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_AudioEffectCapture_method_get_frames_available:
  100. .. rst-class:: classref-method
  101. :ref:`int<class_int>` **get_frames_available**\ (\ ) |const| :ref:`🔗<class_AudioEffectCapture_method_get_frames_available>`
  102. Returns the number of frames available to read using :ref:`get_buffer<class_AudioEffectCapture_method_get_buffer>`.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_AudioEffectCapture_method_get_pushed_frames:
  106. .. rst-class:: classref-method
  107. :ref:`int<class_int>` **get_pushed_frames**\ (\ ) |const| :ref:`🔗<class_AudioEffectCapture_method_get_pushed_frames>`
  108. Returns the number of audio frames inserted from the audio bus.
  109. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  110. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  111. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  112. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  113. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  114. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  115. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  116. .. |void| replace:: :abbr:`void (No return value.)`