class_audiostreamplayer3d.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the AudioStreamPlayer3D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AudioStreamPlayer3D:
  6. AudioStreamPlayer3D
  7. ===================
  8. **Inherits:** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Plays positional sound in 3D space.
  10. Description
  11. -----------
  12. Plays a sound effect with directed sound effects, dampens with distance if needed, generates effect of hearable position in space. For greater realism, a low-pass filter is automatically applied to distant sounds. This can be disabled by setting :ref:`attenuation_filter_cutoff_hz<class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz>` to ``20500``.
  13. By default, audio is heard from the camera position. This can be changed by adding a :ref:`AudioListener3D<class_AudioListener3D>` node to the scene and enabling it by calling :ref:`AudioListener3D.make_current<class_AudioListener3D_method_make_current>` on it.
  14. See also :ref:`AudioStreamPlayer<class_AudioStreamPlayer>` to play a sound non-positionally.
  15. **Note:** Hiding an ``AudioStreamPlayer3D`` node does not disable its audio output. To temporarily disable an ``AudioStreamPlayer3D``'s audio output, set :ref:`unit_db<class_AudioStreamPlayer3D_property_unit_db>` to a very low value like ``-100`` (which isn't audible to human hearing).
  16. Tutorials
  17. ---------
  18. - :doc:`../tutorials/audio/audio_streams`
  19. Properties
  20. ----------
  21. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  22. | :ref:`int<class_int>` | :ref:`area_mask<class_AudioStreamPlayer3D_property_area_mask>` | ``1`` |
  23. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  24. | :ref:`float<class_float>` | :ref:`attenuation_filter_cutoff_hz<class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz>` | ``5000.0`` |
  25. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  26. | :ref:`float<class_float>` | :ref:`attenuation_filter_db<class_AudioStreamPlayer3D_property_attenuation_filter_db>` | ``-24.0`` |
  27. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  28. | :ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` | :ref:`attenuation_model<class_AudioStreamPlayer3D_property_attenuation_model>` | ``0`` |
  29. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  30. | :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer3D_property_autoplay>` | ``false`` |
  31. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  32. | :ref:`StringName<class_StringName>` | :ref:`bus<class_AudioStreamPlayer3D_property_bus>` | ``&"Master"`` |
  33. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  34. | :ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` | :ref:`doppler_tracking<class_AudioStreamPlayer3D_property_doppler_tracking>` | ``0`` |
  35. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  36. | :ref:`float<class_float>` | :ref:`emission_angle_degrees<class_AudioStreamPlayer3D_property_emission_angle_degrees>` | ``45.0`` |
  37. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  38. | :ref:`bool<class_bool>` | :ref:`emission_angle_enabled<class_AudioStreamPlayer3D_property_emission_angle_enabled>` | ``false`` |
  39. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  40. | :ref:`float<class_float>` | :ref:`emission_angle_filter_attenuation_db<class_AudioStreamPlayer3D_property_emission_angle_filter_attenuation_db>` | ``-12.0`` |
  41. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  42. | :ref:`float<class_float>` | :ref:`max_db<class_AudioStreamPlayer3D_property_max_db>` | ``3.0`` |
  43. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  44. | :ref:`float<class_float>` | :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` | ``0.0`` |
  45. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  46. | :ref:`int<class_int>` | :ref:`max_polyphony<class_AudioStreamPlayer3D_property_max_polyphony>` | ``1`` |
  47. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  48. | :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer3D_property_pitch_scale>` | ``1.0`` |
  49. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  50. | :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer3D_property_playing>` | ``false`` |
  51. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  52. | :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer3D_property_stream>` | |
  53. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  54. | :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer3D_property_stream_paused>` | ``false`` |
  55. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  56. | :ref:`float<class_float>` | :ref:`unit_db<class_AudioStreamPlayer3D_property_unit_db>` | ``0.0`` |
  57. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  58. | :ref:`float<class_float>` | :ref:`unit_size<class_AudioStreamPlayer3D_property_unit_size>` | ``10.0`` |
  59. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
  60. Methods
  61. -------
  62. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  63. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer3D_method_get_playback_position>` **(** **)** |
  64. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  65. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer3D_method_get_stream_playback>` **(** **)** |
  66. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`play<class_AudioStreamPlayer3D_method_play>` **(** :ref:`float<class_float>` from_position=0.0 **)** |
  68. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`seek<class_AudioStreamPlayer3D_method_seek>` **(** :ref:`float<class_float>` to_position **)** |
  70. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`stop<class_AudioStreamPlayer3D_method_stop>` **(** **)** |
  72. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  73. Signals
  74. -------
  75. .. _class_AudioStreamPlayer3D_signal_finished:
  76. - **finished** **(** **)**
  77. Emitted when the audio stops playing.
  78. Enumerations
  79. ------------
  80. .. _enum_AudioStreamPlayer3D_AttenuationModel:
  81. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_INVERSE_DISTANCE:
  82. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_INVERSE_SQUARE_DISTANCE:
  83. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_LOGARITHMIC:
  84. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_DISABLED:
  85. enum **AttenuationModel**:
  86. - **ATTENUATION_INVERSE_DISTANCE** = **0** --- Linear dampening of loudness according to distance.
  87. - **ATTENUATION_INVERSE_SQUARE_DISTANCE** = **1** --- Squared dampening of loudness according to distance.
  88. - **ATTENUATION_LOGARITHMIC** = **2** --- Logarithmic dampening of loudness according to distance.
  89. - **ATTENUATION_DISABLED** = **3** --- No dampening of loudness according to distance. The sound will still be heard positionally, unlike an :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`. :ref:`ATTENUATION_DISABLED<class_AudioStreamPlayer3D_constant_ATTENUATION_DISABLED>` can be combined with a :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` value greater than ``0.0`` to achieve linear attenuation clamped to a sphere of a defined size.
  90. ----
  91. .. _enum_AudioStreamPlayer3D_DopplerTracking:
  92. .. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_DISABLED:
  93. .. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_IDLE_STEP:
  94. .. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_PHYSICS_STEP:
  95. enum **DopplerTracking**:
  96. - **DOPPLER_TRACKING_DISABLED** = **0** --- Disables doppler tracking.
  97. - **DOPPLER_TRACKING_IDLE_STEP** = **1** --- Executes doppler tracking in idle step.
  98. - **DOPPLER_TRACKING_PHYSICS_STEP** = **2** --- Executes doppler tracking in physics step.
  99. Property Descriptions
  100. ---------------------
  101. .. _class_AudioStreamPlayer3D_property_area_mask:
  102. - :ref:`int<class_int>` **area_mask**
  103. +-----------+----------------------+
  104. | *Default* | ``1`` |
  105. +-----------+----------------------+
  106. | *Setter* | set_area_mask(value) |
  107. +-----------+----------------------+
  108. | *Getter* | get_area_mask() |
  109. +-----------+----------------------+
  110. Areas in which this sound plays.
  111. ----
  112. .. _class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz:
  113. - :ref:`float<class_float>` **attenuation_filter_cutoff_hz**
  114. +-----------+-----------------------------------------+
  115. | *Default* | ``5000.0`` |
  116. +-----------+-----------------------------------------+
  117. | *Setter* | set_attenuation_filter_cutoff_hz(value) |
  118. +-----------+-----------------------------------------+
  119. | *Getter* | get_attenuation_filter_cutoff_hz() |
  120. +-----------+-----------------------------------------+
  121. Dampens audio using a low-pass filter above this frequency, in Hz. To disable the dampening effect entirely, set this to ``20500`` as this frequency is above the human hearing limit.
  122. ----
  123. .. _class_AudioStreamPlayer3D_property_attenuation_filter_db:
  124. - :ref:`float<class_float>` **attenuation_filter_db**
  125. +-----------+----------------------------------+
  126. | *Default* | ``-24.0`` |
  127. +-----------+----------------------------------+
  128. | *Setter* | set_attenuation_filter_db(value) |
  129. +-----------+----------------------------------+
  130. | *Getter* | get_attenuation_filter_db() |
  131. +-----------+----------------------------------+
  132. Amount how much the filter affects the loudness, in decibels.
  133. ----
  134. .. _class_AudioStreamPlayer3D_property_attenuation_model:
  135. - :ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **attenuation_model**
  136. +-----------+------------------------------+
  137. | *Default* | ``0`` |
  138. +-----------+------------------------------+
  139. | *Setter* | set_attenuation_model(value) |
  140. +-----------+------------------------------+
  141. | *Getter* | get_attenuation_model() |
  142. +-----------+------------------------------+
  143. Decides if audio should get quieter with distance linearly, quadratically, logarithmically, or not be affected by distance, effectively disabling attenuation.
  144. ----
  145. .. _class_AudioStreamPlayer3D_property_autoplay:
  146. - :ref:`bool<class_bool>` **autoplay**
  147. +-----------+-----------------------+
  148. | *Default* | ``false`` |
  149. +-----------+-----------------------+
  150. | *Setter* | set_autoplay(value) |
  151. +-----------+-----------------------+
  152. | *Getter* | is_autoplay_enabled() |
  153. +-----------+-----------------------+
  154. If ``true``, audio plays when the AudioStreamPlayer3D node is added to scene tree.
  155. ----
  156. .. _class_AudioStreamPlayer3D_property_bus:
  157. - :ref:`StringName<class_StringName>` **bus**
  158. +-----------+----------------+
  159. | *Default* | ``&"Master"`` |
  160. +-----------+----------------+
  161. | *Setter* | set_bus(value) |
  162. +-----------+----------------+
  163. | *Getter* | get_bus() |
  164. +-----------+----------------+
  165. The bus on which this audio is playing.
  166. ----
  167. .. _class_AudioStreamPlayer3D_property_doppler_tracking:
  168. - :ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` **doppler_tracking**
  169. +-----------+-----------------------------+
  170. | *Default* | ``0`` |
  171. +-----------+-----------------------------+
  172. | *Setter* | set_doppler_tracking(value) |
  173. +-----------+-----------------------------+
  174. | *Getter* | get_doppler_tracking() |
  175. +-----------+-----------------------------+
  176. Decides in which step the Doppler effect should be calculated.
  177. ----
  178. .. _class_AudioStreamPlayer3D_property_emission_angle_degrees:
  179. - :ref:`float<class_float>` **emission_angle_degrees**
  180. +-----------+---------------------------+
  181. | *Default* | ``45.0`` |
  182. +-----------+---------------------------+
  183. | *Setter* | set_emission_angle(value) |
  184. +-----------+---------------------------+
  185. | *Getter* | get_emission_angle() |
  186. +-----------+---------------------------+
  187. The angle in which the audio reaches cameras undampened.
  188. ----
  189. .. _class_AudioStreamPlayer3D_property_emission_angle_enabled:
  190. - :ref:`bool<class_bool>` **emission_angle_enabled**
  191. +-----------+-----------------------------------+
  192. | *Default* | ``false`` |
  193. +-----------+-----------------------------------+
  194. | *Setter* | set_emission_angle_enabled(value) |
  195. +-----------+-----------------------------------+
  196. | *Getter* | is_emission_angle_enabled() |
  197. +-----------+-----------------------------------+
  198. If ``true``, the audio should be dampened according to the direction of the sound.
  199. ----
  200. .. _class_AudioStreamPlayer3D_property_emission_angle_filter_attenuation_db:
  201. - :ref:`float<class_float>` **emission_angle_filter_attenuation_db**
  202. +-----------+-------------------------------------------------+
  203. | *Default* | ``-12.0`` |
  204. +-----------+-------------------------------------------------+
  205. | *Setter* | set_emission_angle_filter_attenuation_db(value) |
  206. +-----------+-------------------------------------------------+
  207. | *Getter* | get_emission_angle_filter_attenuation_db() |
  208. +-----------+-------------------------------------------------+
  209. Dampens audio if camera is outside of :ref:`emission_angle_degrees<class_AudioStreamPlayer3D_property_emission_angle_degrees>` and :ref:`emission_angle_enabled<class_AudioStreamPlayer3D_property_emission_angle_enabled>` is set by this factor, in decibels.
  210. ----
  211. .. _class_AudioStreamPlayer3D_property_max_db:
  212. - :ref:`float<class_float>` **max_db**
  213. +-----------+-------------------+
  214. | *Default* | ``3.0`` |
  215. +-----------+-------------------+
  216. | *Setter* | set_max_db(value) |
  217. +-----------+-------------------+
  218. | *Getter* | get_max_db() |
  219. +-----------+-------------------+
  220. Sets the absolute maximum of the soundlevel, in decibels.
  221. ----
  222. .. _class_AudioStreamPlayer3D_property_max_distance:
  223. - :ref:`float<class_float>` **max_distance**
  224. +-----------+-------------------------+
  225. | *Default* | ``0.0`` |
  226. +-----------+-------------------------+
  227. | *Setter* | set_max_distance(value) |
  228. +-----------+-------------------------+
  229. | *Getter* | get_max_distance() |
  230. +-----------+-------------------------+
  231. The distance past which the sound can no longer be heard at all. Only has an effect if set to a value greater than ``0.0``. :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` works in tandem with :ref:`unit_size<class_AudioStreamPlayer3D_property_unit_size>`. However, unlike :ref:`unit_size<class_AudioStreamPlayer3D_property_unit_size>` whose behavior depends on the :ref:`attenuation_model<class_AudioStreamPlayer3D_property_attenuation_model>`, :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` always works in a linear fashion. This can be used to prevent the ``AudioStreamPlayer3D`` from requiring audio mixing when the listener is far away, which saves CPU resources.
  232. ----
  233. .. _class_AudioStreamPlayer3D_property_max_polyphony:
  234. - :ref:`int<class_int>` **max_polyphony**
  235. +-----------+--------------------------+
  236. | *Default* | ``1`` |
  237. +-----------+--------------------------+
  238. | *Setter* | set_max_polyphony(value) |
  239. +-----------+--------------------------+
  240. | *Getter* | get_max_polyphony() |
  241. +-----------+--------------------------+
  242. The maximum number of sounds this node can play at the same time. Playing additional sounds after this value is reached will cut off the oldest sounds.
  243. ----
  244. .. _class_AudioStreamPlayer3D_property_pitch_scale:
  245. - :ref:`float<class_float>` **pitch_scale**
  246. +-----------+------------------------+
  247. | *Default* | ``1.0`` |
  248. +-----------+------------------------+
  249. | *Setter* | set_pitch_scale(value) |
  250. +-----------+------------------------+
  251. | *Getter* | get_pitch_scale() |
  252. +-----------+------------------------+
  253. The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
  254. ----
  255. .. _class_AudioStreamPlayer3D_property_playing:
  256. - :ref:`bool<class_bool>` **playing**
  257. +-----------+--------------+
  258. | *Default* | ``false`` |
  259. +-----------+--------------+
  260. | *Getter* | is_playing() |
  261. +-----------+--------------+
  262. If ``true``, audio is playing.
  263. ----
  264. .. _class_AudioStreamPlayer3D_property_stream:
  265. - :ref:`AudioStream<class_AudioStream>` **stream**
  266. +----------+-------------------+
  267. | *Setter* | set_stream(value) |
  268. +----------+-------------------+
  269. | *Getter* | get_stream() |
  270. +----------+-------------------+
  271. The :ref:`AudioStream<class_AudioStream>` resource to be played.
  272. ----
  273. .. _class_AudioStreamPlayer3D_property_stream_paused:
  274. - :ref:`bool<class_bool>` **stream_paused**
  275. +-----------+--------------------------+
  276. | *Default* | ``false`` |
  277. +-----------+--------------------------+
  278. | *Setter* | set_stream_paused(value) |
  279. +-----------+--------------------------+
  280. | *Getter* | get_stream_paused() |
  281. +-----------+--------------------------+
  282. If ``true``, the playback is paused. You can resume it by setting :ref:`stream_paused<class_AudioStreamPlayer3D_property_stream_paused>` to ``false``.
  283. ----
  284. .. _class_AudioStreamPlayer3D_property_unit_db:
  285. - :ref:`float<class_float>` **unit_db**
  286. +-----------+--------------------+
  287. | *Default* | ``0.0`` |
  288. +-----------+--------------------+
  289. | *Setter* | set_unit_db(value) |
  290. +-----------+--------------------+
  291. | *Getter* | get_unit_db() |
  292. +-----------+--------------------+
  293. The base sound level unaffected by dampening, in decibels.
  294. ----
  295. .. _class_AudioStreamPlayer3D_property_unit_size:
  296. - :ref:`float<class_float>` **unit_size**
  297. +-----------+----------------------+
  298. | *Default* | ``10.0`` |
  299. +-----------+----------------------+
  300. | *Setter* | set_unit_size(value) |
  301. +-----------+----------------------+
  302. | *Getter* | get_unit_size() |
  303. +-----------+----------------------+
  304. The factor for the attenuation effect. Higher values make the sound audible over a larger distance.
  305. Method Descriptions
  306. -------------------
  307. .. _class_AudioStreamPlayer3D_method_get_playback_position:
  308. - :ref:`float<class_float>` **get_playback_position** **(** **)**
  309. Returns the position in the :ref:`AudioStream<class_AudioStream>`.
  310. ----
  311. .. _class_AudioStreamPlayer3D_method_get_stream_playback:
  312. - :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback** **(** **)**
  313. Returns the :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` object associated with this ``AudioStreamPlayer3D``.
  314. ----
  315. .. _class_AudioStreamPlayer3D_method_play:
  316. - void **play** **(** :ref:`float<class_float>` from_position=0.0 **)**
  317. Plays the audio from the given position ``from_position``, in seconds.
  318. ----
  319. .. _class_AudioStreamPlayer3D_method_seek:
  320. - void **seek** **(** :ref:`float<class_float>` to_position **)**
  321. Sets the position from which audio will be played, in seconds.
  322. ----
  323. .. _class_AudioStreamPlayer3D_method_stop:
  324. - void **stop** **(** **)**
  325. Stops the audio.
  326. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  327. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  328. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  329. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  330. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  331. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`