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.

AudioStreamOggVorbis

继承: AudioStream < Resource < RefCounted < Object

代表 Ogg Vorbis 音频流的类。

描述

AudioStreamOggVorbis 类是专用于处理 Ogg Vorbis 文件格式的特化 AudioStream 类。它提供加载和播放 Ogg Vorbis 文件以及管理循环和其他播放属性的功能。更多详细信息可参阅 ResourceImporterOggVorbis

该类是音频流系统的一部分,该系统还通过 AudioStreamWAV 类支持 WAV 文件,通过 AudioStreamMP3 类支持 MP3 文件。

教程

属性

int

bar_beats

4

int

beat_count

0

float

bpm

0.0

bool

loop

false

float

loop_offset

0.0

OggPacketSequence

packet_sequence

Dictionary

tags

{}

方法

AudioStreamOggVorbis

load_from_buffer(stream_data: PackedByteArray) static

AudioStreamOggVorbis

load_from_file(path: String) static


属性说明

int bar_beats = 4 🔗

  • void set_bar_beats(value: int)

  • int get_bar_beats()

音轨中单节的拍数。


int beat_count = 0 🔗

  • void set_beat_count(value: int)

  • int get_beat_count()

音轨的长度,单位为节拍。音频文件的实际时长可能长于该属性所指示的值。它定义了音频用于循环播放、AudioStreamPlaylistAudioStreamInteractive 时的结束点。


float bpm = 0.0 🔗

音轨的拍速,以每分钟节拍数计量。


bool loop = false 🔗

  • void set_loop(value: bool)

  • bool has_loop()

如果为 true,则当音频流播放至音轨末尾,或者根据 beat_count 指定的节拍数播放至最后一个节拍的末尾时,它将从 loop_offset 指定的位置重新开始播放。适用于环境音效和背景音乐。


float loop_offset = 0.0 🔗

  • void set_loop_offset(value: float)

  • float get_loop_offset()

循环时,流开始的时间,单位为秒。


OggPacketSequence packet_sequence 🔗

包含用于这个流的原始 Ogg 数据。


Dictionary tags = {} 🔗

如果在 Ogg Vorbis 数据中存在标签,则包含用户定义的标签。

常用标签包括标题 title、艺术家 artist、专辑 album、音轨号 tracknumber、日期 datedate 没有标准日期格式)。

注意:无法保证每个文件中都有某个标签,因此请考虑键可能不是始终存在。


方法说明

AudioStreamOggVorbis load_from_buffer(stream_data: PackedByteArray) static 🔗

从给定缓冲区新建 AudioStreamOggVorbis 实例。缓冲区中必须包含 Ogg Vorbis 数据。


AudioStreamOggVorbis load_from_file(path: String) static 🔗

从给定的文件路径新建 AudioStreamOggVorbis 实例。文件必须为 Ogg Vorbis 格式。