mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-05 14:10:19 +03:00
686 lines
33 KiB
ReStructuredText
686 lines
33 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. meta::
|
||
:keywords: sound, sfx
|
||
|
||
.. _class_AudioStreamPlayer3D:
|
||
|
||
AudioStreamPlayer3D
|
||
===================
|
||
|
||
**繼承:** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
||
|
||
在 3D 空間中播放與位置相關的聲音。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
說明
|
||
----
|
||
|
||
根據聆聽者的相對位置播放具備空間化效果的音訊。位置效果包含距離衰減、方向性與多普勒效應。為了更逼真,系統會對遠處聲音套用低通濾波器;若要停用,將 :ref:`attenuation_filter_cutoff_hz<class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz>` 設為 ``20500``\ 。
|
||
|
||
預設情況下,聲音從攝影機位置輸出。你可以在場景中新增 :ref:`AudioListener3D<class_AudioListener3D>` 節點,並呼叫 :ref:`AudioListener3D.make_current()<class_AudioListener3D_method_make_current>` 來啟用以改變聆聽位置。
|
||
|
||
若要播放非空間化音效,請參閱 :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`\ 。
|
||
|
||
\ **注意:** 隱藏 **AudioStreamPlayer3D** 節點不會停止音訊輸出。若需暫時靜音,可將 :ref:`volume_db<class_AudioStreamPlayer3D_property_volume_db>` 設為極低值,例如 ``-100``\ (人耳已無法聽見)。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
教學
|
||
----
|
||
|
||
- :doc:`音訊流 <../tutorials/audio/audio_streams>`
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
屬性
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`int<class_int>` | :ref:`area_mask<class_AudioStreamPlayer3D_property_area_mask>` | ``1`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`attenuation_filter_cutoff_hz<class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz>` | ``5000.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`attenuation_filter_db<class_AudioStreamPlayer3D_property_attenuation_filter_db>` | ``-24.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` | :ref:`attenuation_model<class_AudioStreamPlayer3D_property_attenuation_model>` | ``0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer3D_property_autoplay>` | ``false`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`StringName<class_StringName>` | :ref:`bus<class_AudioStreamPlayer3D_property_bus>` | ``&"Master"`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` | :ref:`doppler_tracking<class_AudioStreamPlayer3D_property_doppler_tracking>` | ``0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`emission_angle_degrees<class_AudioStreamPlayer3D_property_emission_angle_degrees>` | ``45.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`bool<class_bool>` | :ref:`emission_angle_enabled<class_AudioStreamPlayer3D_property_emission_angle_enabled>` | ``false`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`emission_angle_filter_attenuation_db<class_AudioStreamPlayer3D_property_emission_angle_filter_attenuation_db>` | ``-12.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`max_db<class_AudioStreamPlayer3D_property_max_db>` | ``3.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` | ``0.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`int<class_int>` | :ref:`max_polyphony<class_AudioStreamPlayer3D_property_max_polyphony>` | ``1`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`panning_strength<class_AudioStreamPlayer3D_property_panning_strength>` | ``1.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer3D_property_pitch_scale>` | ``1.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`PlaybackType<enum_AudioServer_PlaybackType>` | :ref:`playback_type<class_AudioStreamPlayer3D_property_playback_type>` | ``0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer3D_property_playing>` | ``false`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer3D_property_stream>` | |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer3D_property_stream_paused>` | ``false`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`unit_size<class_AudioStreamPlayer3D_property_unit_size>` | ``10.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`volume_db<class_AudioStreamPlayer3D_property_volume_db>` | ``0.0`` |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
| :ref:`float<class_float>` | :ref:`volume_linear<class_AudioStreamPlayer3D_property_volume_linear>` | |
|
||
+--------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------+
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
方法
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
|
||
| :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer3D_method_get_playback_position>`\ (\ ) |
|
||
+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
|
||
| :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer3D_method_get_stream_playback>`\ (\ ) |
|
||
+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_stream_playback<class_AudioStreamPlayer3D_method_has_stream_playback>`\ (\ ) |
|
||
+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`play<class_AudioStreamPlayer3D_method_play>`\ (\ from_position\: :ref:`float<class_float>` = 0.0\ ) |
|
||
+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`seek<class_AudioStreamPlayer3D_method_seek>`\ (\ to_position\: :ref:`float<class_float>`\ ) |
|
||
+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`stop<class_AudioStreamPlayer3D_method_stop>`\ (\ ) |
|
||
+-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
訊號
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_signal_finished:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**finished**\ (\ ) :ref:`🔗<class_AudioStreamPlayer3D_signal_finished>`
|
||
|
||
當音訊停止播放時發出。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
列舉
|
||
----
|
||
|
||
.. _enum_AudioStreamPlayer3D_AttenuationModel:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **AttenuationModel**: :ref:`🔗<enum_AudioStreamPlayer3D_AttenuationModel>`
|
||
|
||
.. _class_AudioStreamPlayer3D_constant_ATTENUATION_INVERSE_DISTANCE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **ATTENUATION_INVERSE_DISTANCE** = ``0``
|
||
|
||
依線性距離衰減響度。
|
||
|
||
.. _class_AudioStreamPlayer3D_constant_ATTENUATION_INVERSE_SQUARE_DISTANCE:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **ATTENUATION_INVERSE_SQUARE_DISTANCE** = ``1``
|
||
|
||
依平方距離衰減響度。
|
||
|
||
.. _class_AudioStreamPlayer3D_constant_ATTENUATION_LOGARITHMIC:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **ATTENUATION_LOGARITHMIC** = ``2``
|
||
|
||
依對數距離衰減響度。
|
||
|
||
.. _class_AudioStreamPlayer3D_constant_ATTENUATION_DISABLED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **ATTENUATION_DISABLED** = ``3``
|
||
|
||
響度不隨距離衰減,但仍保留空間定位(不同於 :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`\ )。可將 :ref:`ATTENUATION_DISABLED<class_AudioStreamPlayer3D_constant_ATTENUATION_DISABLED>` 與大於 ``0.0`` 的 :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` 搭配,以線性方式在指定球體範圍內衰減。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_AudioStreamPlayer3D_DopplerTracking:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **DopplerTracking**: :ref:`🔗<enum_AudioStreamPlayer3D_DopplerTracking>`
|
||
|
||
.. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_DISABLED:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` **DOPPLER_TRACKING_DISABLED** = ``0``
|
||
|
||
停用多普勒追蹤。
|
||
|
||
.. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_IDLE_STEP:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` **DOPPLER_TRACKING_IDLE_STEP** = ``1``
|
||
|
||
於邏輯處理影格期間執行多普勒追蹤(見 :ref:`Node.NOTIFICATION_INTERNAL_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PROCESS>`\ )。
|
||
|
||
.. _class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_PHYSICS_STEP:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` **DOPPLER_TRACKING_PHYSICS_STEP** = ``2``
|
||
|
||
於物理影格期間執行多普勒追蹤(見 :ref:`Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PHYSICS_PROCESS>`\ )。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
屬性說明
|
||
--------
|
||
|
||
.. _class_AudioStreamPlayer3D_property_area_mask:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **area_mask** = ``1`` :ref:`🔗<class_AudioStreamPlayer3D_property_area_mask>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_area_mask**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_area_mask**\ (\ )
|
||
|
||
決定哪些 :ref:`Area3D<class_Area3D>` 分層影響混響與音訊匯流排效果。你可以利用區域將 :ref:`AudioStream<class_AudioStream>` 重新導向至特定匯流排。例如建立「水域」區域,讓水中的聲音透過匯流排處理,聽起來像在水下播放。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **attenuation_filter_cutoff_hz** = ``5000.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_attenuation_filter_cutoff_hz>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_attenuation_filter_cutoff_hz**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_attenuation_filter_cutoff_hz**\ (\ )
|
||
|
||
衰減低通濾波器的截止頻率(Hz)。高於此頻率的聲音會比低於此頻率的聲音被更大幅度衰減。若要停用,請設為 ``20500``\ (高於人耳可聽極限)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_attenuation_filter_db:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **attenuation_filter_db** = ``-24.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_attenuation_filter_db>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_attenuation_filter_db**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_attenuation_filter_db**\ (\ )
|
||
|
||
濾波器對響度影響的幅度,單位為分貝。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_attenuation_model:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **attenuation_model** = ``0`` :ref:`🔗<class_AudioStreamPlayer3D_property_attenuation_model>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_attenuation_model**\ (\ value\: :ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>`\ )
|
||
- :ref:`AttenuationModel<enum_AudioStreamPlayer3D_AttenuationModel>` **get_attenuation_model**\ (\ )
|
||
|
||
決定音訊是否隨距離而線性、平方、對數衰減,或完全不受距離影響(即停用衰減)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_autoplay:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **autoplay** = ``false`` :ref:`🔗<class_AudioStreamPlayer3D_property_autoplay>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_autoplay**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_autoplay_enabled**\ (\ )
|
||
|
||
若為 ``true``\ ,當 AudioStreamPlayer3D 節點加入場景樹時即開始播放。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_bus:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`StringName<class_StringName>` **bus** = ``&"Master"`` :ref:`🔗<class_AudioStreamPlayer3D_property_bus>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_bus**\ (\ value\: :ref:`StringName<class_StringName>`\ )
|
||
- :ref:`StringName<class_StringName>` **get_bus**\ (\ )
|
||
|
||
此音訊播放所在的匯流排。
|
||
|
||
\ **注意:** 設定時不會驗證名稱是否存在,因為匯流排配置可能稍後才載入。若執行期間找不到對應匯流排,將回退至 ``"Master"``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_doppler_tracking:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` **doppler_tracking** = ``0`` :ref:`🔗<class_AudioStreamPlayer3D_property_doppler_tracking>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_doppler_tracking**\ (\ value\: :ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>`\ )
|
||
- :ref:`DopplerTracking<enum_AudioStreamPlayer3D_DopplerTracking>` **get_doppler_tracking**\ (\ )
|
||
|
||
Decides in which step the Doppler effect should be calculated.
|
||
|
||
\ **Note:** If :ref:`doppler_tracking<class_AudioStreamPlayer3D_property_doppler_tracking>` is not :ref:`DOPPLER_TRACKING_DISABLED<class_AudioStreamPlayer3D_constant_DOPPLER_TRACKING_DISABLED>` but the current :ref:`Camera3D<class_Camera3D>`/:ref:`AudioListener3D<class_AudioListener3D>` has doppler tracking disabled, the Doppler effect will be heard but will not take the movement of the current listener into account. If accurate Doppler effect is desired, doppler tracking should be enabled on both the **AudioStreamPlayer3D** and the current :ref:`Camera3D<class_Camera3D>`/:ref:`AudioListener3D<class_AudioListener3D>`.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_emission_angle_degrees:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **emission_angle_degrees** = ``45.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_emission_angle_degrees>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_emission_angle**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_emission_angle**\ (\ )
|
||
|
||
聲音在此角度內傳至聽者時不會衰減。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_emission_angle_enabled:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **emission_angle_enabled** = ``false`` :ref:`🔗<class_AudioStreamPlayer3D_property_emission_angle_enabled>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_emission_angle_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_emission_angle_enabled**\ (\ )
|
||
|
||
若為 ``true``\ ,將依聲音方向進行衰減。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_emission_angle_filter_attenuation_db:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **emission_angle_filter_attenuation_db** = ``-12.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_emission_angle_filter_attenuation_db>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_emission_angle_filter_attenuation_db**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_emission_angle_filter_attenuation_db**\ (\ )
|
||
|
||
當聽者位於 :ref:`emission_angle_degrees<class_AudioStreamPlayer3D_property_emission_angle_degrees>` 之外且 :ref:`emission_angle_enabled<class_AudioStreamPlayer3D_property_emission_angle_enabled>` 啟用時,採用的衰減係數(分貝)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_max_db:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **max_db** = ``3.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_max_db>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_max_db**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_max_db**\ (\ )
|
||
|
||
設定聲音輸出的絕對最大值,單位為分貝。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_max_distance:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **max_distance** = ``0.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_max_distance>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_max_distance**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_max_distance**\ (\ )
|
||
|
||
超過此距離後將完全聽不到聲音。僅在設為大於 ``0.0`` 時生效。\ :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` 與 :ref:`unit_size<class_AudioStreamPlayer3D_property_unit_size>` 協同運作;不同於 :ref:`unit_size<class_AudioStreamPlayer3D_property_unit_size>` 受 :ref:`attenuation_model<class_AudioStreamPlayer3D_property_attenuation_model>` 影響,\ :ref:`max_distance<class_AudioStreamPlayer3D_property_max_distance>` 一律採線性模式。這可避免聽者距離過遠時仍需混音,節省 CPU。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_max_polyphony:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`int<class_int>` **max_polyphony** = ``1`` :ref:`🔗<class_AudioStreamPlayer3D_property_max_polyphony>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_max_polyphony**\ (\ value\: :ref:`int<class_int>`\ )
|
||
- :ref:`int<class_int>` **get_max_polyphony**\ (\ )
|
||
|
||
此節點同時可播放的最大音效數。超過後播放新音效會截斷最舊的音效。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_panning_strength:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **panning_strength** = ``1.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_panning_strength>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_panning_strength**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_panning_strength**\ (\ )
|
||
|
||
將此節點的聲道平移強度設為 :ref:`ProjectSettings.audio/general/3d_panning_strength<class_ProjectSettings_property_audio/general/3d_panning_strength>` 乘以本係數。若乘積為 ``0.0``\ ,則停用立體聲平移,所有聲道音量相同;若為 ``1.0``\ ,當聲源位於聽者正左或正右時,將靜音其中一個聲道。
|
||
|
||
兩聲道立體聲配置遵循 `WebAudio StereoPannerNode <https://webaudio.github.io/web-audio-api/#stereopanner-algorithm>`__ 演算法,以耳朵方位角一半的餘弦值計算音量。
|
||
|
||
至於 5.1、7.1 等其他喇叭配置,則實作 SPCAP(Speaker-Placement Correction Amplitude)演算法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_pitch_scale:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **pitch_scale** = ``1.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_pitch_scale>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_pitch_scale**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_pitch_scale**\ (\ )
|
||
|
||
音訊的音高與節奏倍率,相對於其取樣率。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_playback_type:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`PlaybackType<enum_AudioServer_PlaybackType>` **playback_type** = ``0`` :ref:`🔗<class_AudioStreamPlayer3D_property_playback_type>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_playback_type**\ (\ value\: :ref:`PlaybackType<enum_AudioServer_PlaybackType>`\ )
|
||
- :ref:`PlaybackType<enum_AudioServer_PlaybackType>` **get_playback_type**\ (\ )
|
||
|
||
**實驗性:** 此屬性可能在未來版本中變更或移除。
|
||
|
||
串流播放器的播放型態。若設定為非預設值,將強制使用該型態。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_playing:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **playing** = ``false`` :ref:`🔗<class_AudioStreamPlayer3D_property_playing>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_playing**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **is_playing**\ (\ )
|
||
|
||
若為 ``true``\ ,音訊正在播放或已排入播放佇列(見 :ref:`play()<class_AudioStreamPlayer3D_method_play>`\ )。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_stream:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`AudioStream<class_AudioStream>` **stream** :ref:`🔗<class_AudioStreamPlayer3D_property_stream>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_stream**\ (\ value\: :ref:`AudioStream<class_AudioStream>`\ )
|
||
- :ref:`AudioStream<class_AudioStream>` **get_stream**\ (\ )
|
||
|
||
要播放的 :ref:`AudioStream<class_AudioStream>` 資源。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_stream_paused:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`bool<class_bool>` **stream_paused** = ``false`` :ref:`🔗<class_AudioStreamPlayer3D_property_stream_paused>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_stream_paused**\ (\ value\: :ref:`bool<class_bool>`\ )
|
||
- :ref:`bool<class_bool>` **get_stream_paused**\ (\ )
|
||
|
||
若為 ``true`` 則播放暫停,將 :ref:`stream_paused<class_AudioStreamPlayer3D_property_stream_paused>` 設為 ``false`` 可恢復。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_unit_size:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **unit_size** = ``10.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_unit_size>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_unit_size**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_unit_size**\ (\ )
|
||
|
||
衰減係數。值越高,聲音可被聽見的距離越遠。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_volume_db:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **volume_db** = ``0.0`` :ref:`🔗<class_AudioStreamPlayer3D_property_volume_db>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_volume_db**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_volume_db**\ (\ )
|
||
|
||
衰減前的基礎聲級,單位為分貝。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_property_volume_linear:
|
||
|
||
.. rst-class:: classref-property
|
||
|
||
:ref:`float<class_float>` **volume_linear** :ref:`🔗<class_AudioStreamPlayer3D_property_volume_linear>`
|
||
|
||
.. rst-class:: classref-property-setget
|
||
|
||
- |void| **set_volume_linear**\ (\ value\: :ref:`float<class_float>`\ )
|
||
- :ref:`float<class_float>` **get_volume_linear**\ (\ )
|
||
|
||
衰減前的基礎聲級,以線性值表示。
|
||
|
||
\ **注意:**\ 此成員會同步修改 :ref:`volume_db<class_AudioStreamPlayer3D_property_volume_db>`\ 。傳回值等同於對 :ref:`volume_db<class_AudioStreamPlayer3D_property_volume_db>` 執行 :ref:`@GlobalScope.db_to_linear()<class_@GlobalScope_method_db_to_linear>` 的結果。設定此成員則等同於將 :ref:`volume_db<class_AudioStreamPlayer3D_property_volume_db>` 設為對該值執行 :ref:`@GlobalScope.linear_to_db()<class_@GlobalScope_method_linear_to_db>` 的結果。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
方法說明
|
||
--------
|
||
|
||
.. _class_AudioStreamPlayer3D_method_get_playback_position:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`float<class_float>` **get_playback_position**\ (\ ) :ref:`🔗<class_AudioStreamPlayer3D_method_get_playback_position>`
|
||
|
||
回傳在 :ref:`AudioStream<class_AudioStream>` 中的位置。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_method_get_stream_playback:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback**\ (\ ) :ref:`🔗<class_AudioStreamPlayer3D_method_get_stream_playback>`
|
||
|
||
返回與此 **AudioStreamPlayer3D** 關聯的 :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` 物件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_method_has_stream_playback:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **has_stream_playback**\ (\ ) :ref:`🔗<class_AudioStreamPlayer3D_method_has_stream_playback>`
|
||
|
||
回傳此 :ref:`AudioStreamPlayer<class_AudioStreamPlayer>` 是否能取得 :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` 物件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_method_play:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **play**\ (\ from_position\: :ref:`float<class_float>` = 0.0\ ) :ref:`🔗<class_AudioStreamPlayer3D_method_play>`
|
||
|
||
將音訊排入佇列,於下個物理影格自 ``from_position``\ (秒)開始播放。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_method_seek:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **seek**\ (\ to_position\: :ref:`float<class_float>`\ ) :ref:`🔗<class_AudioStreamPlayer3D_method_seek>`
|
||
|
||
設定音訊開始播放的位置(秒)。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_AudioStreamPlayer3D_method_stop:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **stop**\ (\ ) :ref:`🔗<class_AudioStreamPlayer3D_method_stop>`
|
||
|
||
停止音訊。
|
||
|
||
.. |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 (無回傳值。)`
|