Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

ResourceImporterWAV

繼承: ResourceImporter < RefCounted < Object

匯入 WAV 音訊檔案播放。

說明

WAV is an uncompressed format, which can provide higher quality compared to Ogg Vorbis and MP3. It also has the lowest CPU cost to decode. This means high numbers of WAV sounds can be played at the same time, even on low-end devices.

By default, Godot imports WAV files using the lossy Quite OK Audio compression. You may change this by setting the compress/mode property.

教學

屬性

int

compress/mode

2

int

edit/loop_begin

0

int

edit/loop_end

-1

int

edit/loop_mode

0

bool

edit/normalize

false

bool

edit/trim

false

bool

force/8_bit

false

bool

force/max_rate

false

float

force/max_rate_hz

44100

bool

force/mono

false


屬性說明

int compress/mode = 2 🔗

The compression mode to use on import.

  • PCM (Uncompressed): Imports audio data without any form of compression, preserving the highest possible quality. It has the lowest CPU cost, but the highest memory usage.

  • IMA ADPCM: Applies fast, lossy compression during import, noticeably decreasing the quality, but with low CPU cost and memory usage. Does not support seeking and only Forward loop mode is supported.

  • `Quite OK Audio <https://qoaformat.org/>`__: Also applies lossy compression on import, having a slightly higher CPU cost compared to IMA ADPCM, but much higher quality and the lowest memory usage.


int edit/loop_begin = 0 🔗

The begin loop point to use when edit/loop_mode is Forward, Ping-Pong, or Backward. This is set in samples after the beginning of the audio file.


int edit/loop_end = -1 🔗

The end loop point to use when edit/loop_mode is Forward, Ping-Pong, or Backward. This is set in samples after the beginning of the audio file. A value of -1 uses the end of the audio file as the end loop point.


int edit/loop_mode = 0 🔗

Controls how audio should loop.

  • Detect From WAV: Uses loop information from the WAV metadata.

  • Disabled: Don't loop audio, even if the metadata indicates the file playback should loop.

  • Forward: Standard audio looping. Plays the audio forward from the beginning to edit/loop_end, then returns to edit/loop_begin and repeats.

  • Ping-Pong: Plays the audio forward until edit/loop_end, then backwards to edit/loop_begin, repeating this cycle.

  • Backward: Plays the audio backwards from edit/loop_end to edit/loop_begin, then repeats.

Note: In AudioStreamPlayer, the AudioStreamPlayer.finished signal won't be emitted for looping audio when it reaches the end of the audio file, as the audio will keep playing indefinitely.


bool edit/normalize = false 🔗

如果true,則標準化音訊音量,使其峰值音量等於0 dB。啟用後,標準化將使音訊聽起來更響亮,取決於其原始峰值體積。


bool edit/trim = false 🔗

如果true,如果標準化後音訊低於-50 dB,則自動修剪音訊的開頭和結尾(請參閱edit/normalize)。這防止檔案在開頭或結尾處靜音,這不必要地增加了檔案的大小,並增加了播放時的延遲。在修剪過程中還使用了 500 個樣本的淡入/淡出週期,以避免聽到爆音。


bool force/8_bit = false 🔗

如果 true,如果來源檔案為 16 位元或更高,則強制匯入的音訊使用 8 位元量化。

通常不建議啟用此功能,因為 8 位元量化會顯著降低音訊品質。如果您需要較小的檔案大小,請考慮使用 Ogg Vorbis 或 MP3 音訊。


bool force/max_rate = false 🔗

如果設定為大於 0 的值,則強制音訊的取樣率降低到低於或等於 force/max_rate_hz 中指定的值。

這可以顯著減小某些聲音的檔案大小,而不會影響質量,具體取決於實際聲音的內容。有關詳細信息,請參閱最佳實踐


float force/max_rate_hz = 44100 🔗

代表粒子軌跡的時間量(以秒為單位)。僅當 force/max_ratetrue 時有效。


bool force/mono = false 🔗

如果true,如果來源檔案是立體聲,則強制匯入的音訊為單聲道。透過將兩個通道合併為一個通道,可以將檔案大小減少50% 。