class_audiostreamplayer3d.rst 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.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:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Plays 3D 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.
  13. By default, audio is heard from the camera position. This can be changed by adding a :ref:`Listener<class_Listener>` node to the scene and enabling it by calling :ref:`Listener.make_current<class_Listener_method_make_current>` on it.
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/audio/audio_streams`
  17. Properties
  18. ----------
  19. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  20. | :ref:`int<class_int>` | :ref:`area_mask<class_AudioStreamPlayer3D_property_area_mask>` | ``1`` |
  21. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  22. | :ref:`float<class_float>` | :ref:`attenuation_filter_cutoff_hz<class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz>` | ``5000.0`` |
  23. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  24. | :ref:`float<class_float>` | :ref:`attenuation_filter_db<class_AudioStreamPlayer3D_property_attenuation_filter_db>` | ``-24.0`` |
  25. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  26. | :ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` | :ref:`attenuation_model<class_AudioStreamPlayer3D_property_attenuation_model>` | ``0`` |
  27. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  28. | :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer3D_property_autoplay>` | ``false`` |
  29. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  30. | :ref:`String<class_String>` | :ref:`bus<class_AudioStreamPlayer3D_property_bus>` | ``"Master"`` |
  31. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  32. | :ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` | :ref:`doppler_tracking<class_AudioStreamPlayer3D_property_doppler_tracking>` | ``0`` |
  33. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  34. | :ref:`float<class_float>` | :ref:`emission_angle_degrees<class_AudioStreamPlayer3D_property_emission_angle_degrees>` | ``45.0`` |
  35. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  36. | :ref:`bool<class_bool>` | :ref:`emission_angle_enabled<class_AudioStreamPlayer3D_property_emission_angle_enabled>` | ``false`` |
  37. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  38. | :ref:`float<class_float>` | :ref:`emission_angle_filter_attenuation_db<class_AudioStreamPlayer3D_property_emission_angle_filter_attenuation_db>` | ``-12.0`` |
  39. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  40. | :ref:`float<class_float>` | :ref:`max_db<class_AudioStreamPlayer3D_property_max_db>` | ``3.0`` |
  41. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  42. | :ref:`float<class_float>` | :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` | ``0.0`` |
  43. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  44. | :ref:`OutOfRangeMode<enum_AudioStreamPlayer3D_OutOfRangeMode>` | :ref:`out_of_range_mode<class_AudioStreamPlayer3D_property_out_of_range_mode>` | ``0`` |
  45. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  46. | :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer3D_property_pitch_scale>` | ``1.0`` |
  47. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  48. | :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer3D_property_playing>` | ``false`` |
  49. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  50. | :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer3D_property_stream>` | |
  51. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  52. | :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer3D_property_stream_paused>` | ``false`` |
  53. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  54. | :ref:`float<class_float>` | :ref:`unit_db<class_AudioStreamPlayer3D_property_unit_db>` | ``0.0`` |
  55. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  56. | :ref:`float<class_float>` | :ref:`unit_size<class_AudioStreamPlayer3D_property_unit_size>` | ``1.0`` |
  57. +--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------------+
  58. Methods
  59. -------
  60. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  61. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer3D_method_get_playback_position>` **(** **)** |
  62. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  63. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer3D_method_get_stream_playback>` **(** **)** |
  64. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`play<class_AudioStreamPlayer3D_method_play>` **(** :ref:`float<class_float>` from_position=0.0 **)** |
  66. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`seek<class_AudioStreamPlayer3D_method_seek>` **(** :ref:`float<class_float>` to_position **)** |
  68. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`stop<class_AudioStreamPlayer3D_method_stop>` **(** **)** |
  70. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  71. Signals
  72. -------
  73. .. _class_AudioStreamPlayer3D_signal_finished:
  74. - **finished** **(** **)**
  75. Emitted when the audio stops playing.
  76. Enumerations
  77. ------------
  78. .. _enum_AudioStreamPlayer3D_AttenuationModel:
  79. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_INVERSE_DISTANCE:
  80. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_INVERSE_SQUARE_DISTANCE:
  81. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_LOGARITHMIC:
  82. .. _class_AudioStreamPlayer3D_constant_ATTENUATION_DISABLED:
  83. enum **AttenuationModel**:
  84. - **ATTENUATION_INVERSE_DISTANCE** = **0** --- Linear dampening of loudness according to distance.
  85. - **ATTENUATION_INVERSE_SQUARE_DISTANCE** = **1** --- Squared dampening of loudness according to distance.
  86. - **ATTENUATION_LOGARITHMIC** = **2** --- Logarithmic dampening of loudness according to distance.
  87. - **ATTENUATION_DISABLED** = **3** --- No dampening of loudness according to distance.
  88. ----
  89. .. _enum_AudioStreamPlayer3D_OutOfRangeMode:
  90. .. _class_AudioStreamPlayer3D_constant_OUT_OF_RANGE_MIX:
  91. .. _class_AudioStreamPlayer3D_constant_OUT_OF_RANGE_PAUSE:
  92. enum **OutOfRangeMode**:
  93. - **OUT_OF_RANGE_MIX** = **0** --- Mix this audio in, even when it's out of range.
  94. - **OUT_OF_RANGE_PAUSE** = **1** --- Pause this audio when it gets out of range.
  95. ----
  96. .. _enum_AudioStreamPlayer3D_DopplerTracking:
  97. .. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_DISABLED:
  98. .. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_IDLE_STEP:
  99. .. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_PHYSICS_STEP:
  100. enum **DopplerTracking**:
  101. - **DOPPLER_TRACKING_DISABLED** = **0** --- Disables doppler tracking.
  102. - **DOPPLER_TRACKING_IDLE_STEP** = **1** --- Executes doppler tracking in idle step.
  103. - **DOPPLER_TRACKING_PHYSICS_STEP** = **2** --- Executes doppler tracking in physics step.
  104. Property Descriptions
  105. ---------------------
  106. .. _class_AudioStreamPlayer3D_property_area_mask:
  107. - :ref:`int<class_int>` **area_mask**
  108. +-----------+----------------------+
  109. | *Default* | ``1`` |
  110. +-----------+----------------------+
  111. | *Setter* | set_area_mask(value) |
  112. +-----------+----------------------+
  113. | *Getter* | get_area_mask() |
  114. +-----------+----------------------+
  115. Areas in which this sound plays.
  116. ----
  117. .. _class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz:
  118. - :ref:`float<class_float>` **attenuation_filter_cutoff_hz**
  119. +-----------+-----------------------------------------+
  120. | *Default* | ``5000.0`` |
  121. +-----------+-----------------------------------------+
  122. | *Setter* | set_attenuation_filter_cutoff_hz(value) |
  123. +-----------+-----------------------------------------+
  124. | *Getter* | get_attenuation_filter_cutoff_hz() |
  125. +-----------+-----------------------------------------+
  126. Dampens audio above this frequency, in Hz.
  127. ----
  128. .. _class_AudioStreamPlayer3D_property_attenuation_filter_db:
  129. - :ref:`float<class_float>` **attenuation_filter_db**
  130. +-----------+----------------------------------+
  131. | *Default* | ``-24.0`` |
  132. +-----------+----------------------------------+
  133. | *Setter* | set_attenuation_filter_db(value) |
  134. +-----------+----------------------------------+
  135. | *Getter* | get_attenuation_filter_db() |
  136. +-----------+----------------------------------+
  137. Amount how much the filter affects the loudness, in dB.
  138. ----
  139. .. _class_AudioStreamPlayer3D_property_attenuation_model:
  140. - :ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **attenuation_model**
  141. +-----------+------------------------------+
  142. | *Default* | ``0`` |
  143. +-----------+------------------------------+
  144. | *Setter* | set_attenuation_model(value) |
  145. +-----------+------------------------------+
  146. | *Getter* | get_attenuation_model() |
  147. +-----------+------------------------------+
  148. Decides if audio should get quieter with distance linearly, quadratically, logarithmically, or not be affected by distance, effectively disabling attenuation.
  149. ----
  150. .. _class_AudioStreamPlayer3D_property_autoplay:
  151. - :ref:`bool<class_bool>` **autoplay**
  152. +-----------+-----------------------+
  153. | *Default* | ``false`` |
  154. +-----------+-----------------------+
  155. | *Setter* | set_autoplay(value) |
  156. +-----------+-----------------------+
  157. | *Getter* | is_autoplay_enabled() |
  158. +-----------+-----------------------+
  159. If ``true``, audio plays when added to scene tree.
  160. ----
  161. .. _class_AudioStreamPlayer3D_property_bus:
  162. - :ref:`String<class_String>` **bus**
  163. +-----------+----------------+
  164. | *Default* | ``"Master"`` |
  165. +-----------+----------------+
  166. | *Setter* | set_bus(value) |
  167. +-----------+----------------+
  168. | *Getter* | get_bus() |
  169. +-----------+----------------+
  170. Bus on which this audio is playing.
  171. ----
  172. .. _class_AudioStreamPlayer3D_property_doppler_tracking:
  173. - :ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` **doppler_tracking**
  174. +-----------+-----------------------------+
  175. | *Default* | ``0`` |
  176. +-----------+-----------------------------+
  177. | *Setter* | set_doppler_tracking(value) |
  178. +-----------+-----------------------------+
  179. | *Getter* | get_doppler_tracking() |
  180. +-----------+-----------------------------+
  181. Decides in which step the Doppler effect should be calculated.
  182. ----
  183. .. _class_AudioStreamPlayer3D_property_emission_angle_degrees:
  184. - :ref:`float<class_float>` **emission_angle_degrees**
  185. +-----------+---------------------------+
  186. | *Default* | ``45.0`` |
  187. +-----------+---------------------------+
  188. | *Setter* | set_emission_angle(value) |
  189. +-----------+---------------------------+
  190. | *Getter* | get_emission_angle() |
  191. +-----------+---------------------------+
  192. The angle in which the audio reaches cameras undampened.
  193. ----
  194. .. _class_AudioStreamPlayer3D_property_emission_angle_enabled:
  195. - :ref:`bool<class_bool>` **emission_angle_enabled**
  196. +-----------+-----------------------------------+
  197. | *Default* | ``false`` |
  198. +-----------+-----------------------------------+
  199. | *Setter* | set_emission_angle_enabled(value) |
  200. +-----------+-----------------------------------+
  201. | *Getter* | is_emission_angle_enabled() |
  202. +-----------+-----------------------------------+
  203. If ``true``, the audio should be dampened according to the direction of the sound.
  204. ----
  205. .. _class_AudioStreamPlayer3D_property_emission_angle_filter_attenuation_db:
  206. - :ref:`float<class_float>` **emission_angle_filter_attenuation_db**
  207. +-----------+-------------------------------------------------+
  208. | *Default* | ``-12.0`` |
  209. +-----------+-------------------------------------------------+
  210. | *Setter* | set_emission_angle_filter_attenuation_db(value) |
  211. +-----------+-------------------------------------------------+
  212. | *Getter* | get_emission_angle_filter_attenuation_db() |
  213. +-----------+-------------------------------------------------+
  214. 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 dB.
  215. ----
  216. .. _class_AudioStreamPlayer3D_property_max_db:
  217. - :ref:`float<class_float>` **max_db**
  218. +-----------+-------------------+
  219. | *Default* | ``3.0`` |
  220. +-----------+-------------------+
  221. | *Setter* | set_max_db(value) |
  222. +-----------+-------------------+
  223. | *Getter* | get_max_db() |
  224. +-----------+-------------------+
  225. Sets the absolute maximum of the soundlevel, in dB.
  226. ----
  227. .. _class_AudioStreamPlayer3D_property_max_distance:
  228. - :ref:`float<class_float>` **max_distance**
  229. +-----------+-------------------------+
  230. | *Default* | ``0.0`` |
  231. +-----------+-------------------------+
  232. | *Setter* | set_max_distance(value) |
  233. +-----------+-------------------------+
  234. | *Getter* | get_max_distance() |
  235. +-----------+-------------------------+
  236. Sets the distance from which the :ref:`out_of_range_mode<class_AudioStreamPlayer3D_property_out_of_range_mode>` takes effect. Has no effect if set to 0.
  237. ----
  238. .. _class_AudioStreamPlayer3D_property_out_of_range_mode:
  239. - :ref:`OutOfRangeMode<enum_AudioStreamPlayer3D_OutOfRangeMode>` **out_of_range_mode**
  240. +-----------+------------------------------+
  241. | *Default* | ``0`` |
  242. +-----------+------------------------------+
  243. | *Setter* | set_out_of_range_mode(value) |
  244. +-----------+------------------------------+
  245. | *Getter* | get_out_of_range_mode() |
  246. +-----------+------------------------------+
  247. Decides if audio should pause when source is outside of :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` range.
  248. ----
  249. .. _class_AudioStreamPlayer3D_property_pitch_scale:
  250. - :ref:`float<class_float>` **pitch_scale**
  251. +-----------+------------------------+
  252. | *Default* | ``1.0`` |
  253. +-----------+------------------------+
  254. | *Setter* | set_pitch_scale(value) |
  255. +-----------+------------------------+
  256. | *Getter* | get_pitch_scale() |
  257. +-----------+------------------------+
  258. The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
  259. ----
  260. .. _class_AudioStreamPlayer3D_property_playing:
  261. - :ref:`bool<class_bool>` **playing**
  262. +-----------+--------------+
  263. | *Default* | ``false`` |
  264. +-----------+--------------+
  265. | *Getter* | is_playing() |
  266. +-----------+--------------+
  267. If ``true``, audio is playing.
  268. ----
  269. .. _class_AudioStreamPlayer3D_property_stream:
  270. - :ref:`AudioStream<class_AudioStream>` **stream**
  271. +----------+-------------------+
  272. | *Setter* | set_stream(value) |
  273. +----------+-------------------+
  274. | *Getter* | get_stream() |
  275. +----------+-------------------+
  276. The :ref:`AudioStream<class_AudioStream>` object to be played.
  277. ----
  278. .. _class_AudioStreamPlayer3D_property_stream_paused:
  279. - :ref:`bool<class_bool>` **stream_paused**
  280. +-----------+--------------------------+
  281. | *Default* | ``false`` |
  282. +-----------+--------------------------+
  283. | *Setter* | set_stream_paused(value) |
  284. +-----------+--------------------------+
  285. | *Getter* | get_stream_paused() |
  286. +-----------+--------------------------+
  287. If ``true``, the playback is paused. You can resume it by setting ``stream_paused`` to ``false``.
  288. ----
  289. .. _class_AudioStreamPlayer3D_property_unit_db:
  290. - :ref:`float<class_float>` **unit_db**
  291. +-----------+--------------------+
  292. | *Default* | ``0.0`` |
  293. +-----------+--------------------+
  294. | *Setter* | set_unit_db(value) |
  295. +-----------+--------------------+
  296. | *Getter* | get_unit_db() |
  297. +-----------+--------------------+
  298. Base sound level unaffected by dampening, in dB.
  299. ----
  300. .. _class_AudioStreamPlayer3D_property_unit_size:
  301. - :ref:`float<class_float>` **unit_size**
  302. +-----------+----------------------+
  303. | *Default* | ``1.0`` |
  304. +-----------+----------------------+
  305. | *Setter* | set_unit_size(value) |
  306. +-----------+----------------------+
  307. | *Getter* | get_unit_size() |
  308. +-----------+----------------------+
  309. Factor for the attenuation effect.
  310. Method Descriptions
  311. -------------------
  312. .. _class_AudioStreamPlayer3D_method_get_playback_position:
  313. - :ref:`float<class_float>` **get_playback_position** **(** **)**
  314. Returns the position in the :ref:`AudioStream<class_AudioStream>`.
  315. ----
  316. .. _class_AudioStreamPlayer3D_method_get_stream_playback:
  317. - :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback** **(** **)**
  318. Returns the :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` object associated with this ``AudioStreamPlayer3D``.
  319. ----
  320. .. _class_AudioStreamPlayer3D_method_play:
  321. - void **play** **(** :ref:`float<class_float>` from_position=0.0 **)**
  322. Plays the audio from the given position ``from_position``, in seconds.
  323. ----
  324. .. _class_AudioStreamPlayer3D_method_seek:
  325. - void **seek** **(** :ref:`float<class_float>` to_position **)**
  326. Sets the position from which audio will be played, in seconds.
  327. ----
  328. .. _class_AudioStreamPlayer3D_method_stop:
  329. - void **stop** **(** **)**
  330. Stops the audio.
  331. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  332. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  333. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`