Skip to content

Commit b3bbaf3

Browse files
committed
Add Opus to various docs
1 parent cff44a7 commit b3bbaf3

4 files changed

Lines changed: 60 additions & 21 deletions

File tree

about/list_of_features.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ Import
545545
- WAV with optional IMA-ADPCM compression.
546546
- Ogg Vorbis.
547547
- MP3.
548+
- Opus.
548549

549550
- *3D scenes:* See :ref:`doc_importing_3d_scenes`.
550551

engine_details/development/compiling/optimizing_for_size.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ a lot of them:
270270

271271
::
272272

273-
scons target=template_release module_astcenc_enabled=no module_basis_universal_enabled=no module_bcdec_enabled=no module_bmp_enabled=no module_camera_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_etcpak_enabled=no module_fbx_enabled=no module_gltf_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_interactive_music_enabled=no module_jsonrpc_enabled=no module_ktx_enabled=no module_mbedtls_enabled=no module_meshoptimizer_enabled=no module_mp3_enabled=no module_mobile_vr_enabled=no module_msdfgen_enabled=no module_multiplayer_enabled=no module_noise_enabled=no module_navigation_2d_enabled=no module_navigation_3d_enabled=no module_ogg_enabled=no module_openxr_enabled=no module_raycast_enabled=no module_regex_enabled=no module_svg_enabled=no module_tga_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_upnp_enabled=no module_vhacd_enabled=no module_vorbis_enabled=no module_webrtc_enabled=no module_websocket_enabled=no module_webxr_enabled=no module_zip_enabled=no
273+
scons target=template_release module_astcenc_enabled=no module_basis_universal_enabled=no module_bcdec_enabled=no module_bmp_enabled=no module_camera_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_etcpak_enabled=no module_fbx_enabled=no module_gltf_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_interactive_music_enabled=no module_jsonrpc_enabled=no module_ktx_enabled=no module_mbedtls_enabled=no module_meshoptimizer_enabled=no module_mp3_enabled=no module_mobile_vr_enabled=no module_msdfgen_enabled=no module_multiplayer_enabled=no module_noise_enabled=no module_navigation_2d_enabled=no module_navigation_3d_enabled=no module_ogg_enabled=no module_openxr_enabled=no module_opus_enabled=no module_raycast_enabled=no module_regex_enabled=no module_svg_enabled=no module_tga_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_upnp_enabled=no module_vhacd_enabled=no module_vorbis_enabled=no module_webrtc_enabled=no module_websocket_enabled=no module_webxr_enabled=no module_zip_enabled=no
274274

275275
If this proves not to work for your use case, you should review the list of
276276
modules and see which ones you actually still need for your game (e.g. you might
277277
want to keep networking-related modules, regex support,
278-
``mp3``/``ogg``/``vorbis`` to play music, or ``theora`` to play videos).
278+
``mp3``/``ogg``/``vorbis``/``opus`` to play music, or ``theora`` to play videos).
279279

280280
Alternatively, you can supply a list of disabled modules by creating
281281
``custom.py`` at the root of the source, with the contents similar to the
@@ -311,6 +311,7 @@ following:
311311
module_navigation_3d_enabled = "no"
312312
module_ogg_enabled = "no"
313313
module_openxr_enabled = "no"
314+
module_opus_enabled = "no"
314315
module_raycast_enabled = "no"
315316
module_regex_enabled = "no"
316317
module_svg_enabled = "no"

tutorials/assets_pipeline/importing_audio_samples.rst

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Importing audio samples
66
Supported audio formats
77
-----------------------
88

9-
Godot provides 3 options to import your audio data: WAV, Ogg Vorbis and MP3.
9+
Godot provides 4 options to import your audio data: WAV, Ogg Vorbis, MP3 and Opus.
1010

1111
Each format has different advantages:
1212

@@ -20,6 +20,9 @@ Each format has different advantages:
2020
worse than Ogg Vorbis. This means that an MP3 file with roughly equal quality
2121
to Ogg Vorbis will be significantly larger. On the bright side, MP3 requires
2222
less CPU usage to play back compared to Ogg Vorbis.
23+
- Opus files use a more modern compression than Ogg Vorbis and MP3 that results in
24+
much smaller file size for a given quality, but require slightly more processing
25+
power to play back than Ogg Vorbis.
2326

2427
.. note::
2528

@@ -46,17 +49,19 @@ each format:
4649
+------------------------------+-------------------+
4750
| Ogg Vorbis 96 Kb/s, stereo | 12 KB |
4851
+------------------------------+-------------------+
52+
| Opus 128 Kb/s, stereo | 16 KB |
53+
+------------------------------+-------------------+
4954

50-
Note that the MP3 and Ogg Vorbis figures can vary depending on the encoding
51-
type. The above figures use :abbr:`CBR (Constant Bit Rate)` encoding for
52-
simplicity, but most Ogg Vorbis and MP3 files you can find online are encoded
53-
with :abbr:`VBR (Variable Bit Rate)` encoding which is more efficient.
55+
Note that the MP3, Ogg Vorbis and Opus figures can vary depending on the
56+
encoding type. The above figures use :abbr:`CBR (Constant Bit Rate)` encoding
57+
for simplicity, but most MP3, Ogg Vorbis and Opus files you can find online are
58+
encoded with :abbr:`VBR (Variable Bit Rate)` encoding which is more efficient.
5459
VBR encoding makes the effective audio file size depend on how "complex" the
5560
source audio is.
5661

5762
.. tip::
5863

59-
Consider using WAV for short and repetitive sound effects, and Ogg Vorbis for
64+
Consider using WAV for short and repetitive sound effects, and Opus for
6065
music, speech, and long sound effects. MP3 is useful for mobile and web projects
6166
where CPU resources are limited, especially when playing multiple compressed
6267
sounds at the same time (such as long ambient sounds).
@@ -73,14 +78,14 @@ the FileSystem dock:
7378

7479
Import options in the Import dock after selecting a WAV file in the FileSystem dock
7580

76-
The set of options available after selecting an Ogg Vorbis or MP3 file is different:
81+
The set of options available after selecting an Ogg Vorbis, MP3 or Opus file is different:
7782

7883
.. figure:: img/importing_audio_samples_import_options_mp3.webp
7984
:align: center
8085
:alt: Import options in the Import dock after selecting an MP3 file in the FileSystem dock
8186

8287
Import options in the Import dock after selecting an MP3 file in the
83-
FileSystem dock. Options are identical for Ogg Vorbis files.
88+
FileSystem dock. Options are identical for Ogg Vorbis and Opus files.
8489

8590
After importing a sound, you can play it back using the AudioStreamPlayer,
8691
AudioStreamPlayer2D or AudioStreamPlayer3D nodes. See :ref:`doc_audio_streams`
@@ -96,8 +101,8 @@ If enabled, forces the imported audio to use 8-bit quantization if the source
96101
file is 16-bit or higher.
97102

98103
Enabling this is generally not recommended, as 8-bit quantization decreases
99-
audio quality significantly. If you need smaller file sizes, consider using Ogg
100-
Vorbis or MP3 audio instead.
104+
audio quality significantly. If you need smaller file sizes, consider using Opus,
105+
Ogg Vorbis or MP3 audio instead.
101106

102107
Force > Mono
103108
------------
@@ -138,7 +143,7 @@ its original peak volume.
138143
Edit > Loop Mode
139144
----------------
140145

141-
Unlike Ogg Vorbis and MP3, WAV files can contain metadata to indicate whether
146+
Unlike Ogg Vorbis, MP3 and Opus, WAV files can contain metadata to indicate whether
142147
they're looping (in addition to loop points). By default, Godot will follow this
143148
metadata, but you can choose to apply a specific loop mode:
144149

@@ -174,12 +179,12 @@ and memory usage a little, at the cost of decreasing quality in an audible manne
174179
decrease is much less noticeable, at the cost of slightly higher CPU usage (still
175180
much lower than MP3).
176181

177-
Ogg Vorbis and MP3 don't decrease quality as much and can provide greater file
182+
Ogg Vorbis, MP3 and Opus don't decrease quality as much and can provide greater file
178183
size reductions, at the cost of higher CPU usage during playback. This higher
179184
CPU usage is usually not a problem (especially with MP3), unless playing dozens
180185
of compressed sounds at the same time on mobile/web platforms.
181186

182-
Import options (Ogg Vorbis and MP3)
187+
Import options (Ogg Vorbis, MP3 and Opus)
183188
-----------------------------------
184189

185190
Loop
@@ -245,17 +250,17 @@ dialog, as it lets you preview your changes without having to reimport the audio
245250

246251
.. _doc_importing_audio_samples_advanced_import_settings:
247252

248-
Advanced import settings (Ogg Vorbis and MP3)
253+
Advanced import settings (Ogg Vorbis, MP3 and Opus)
249254
---------------------------------------------
250255

251-
If you double-click an Ogg Vorbis or MP3 file in the FileSystem dock (or choose
256+
If you double-click an Ogg Vorbis, MP3 or Opus file in the FileSystem dock (or choose
252257
**Advanced…** in the Import dock), you will see a dialog appear:
253258

254259
.. figure:: img/importing_audio_samples_advanced_import_settings.webp
255260
:align: center
256-
:alt: Advanced dialog when double-clicking an Ogg Vorbis or MP3 file in the FileSystem dock
261+
:alt: Advanced dialog when double-clicking an Ogg Vorbis, MP3 or Opus file in the FileSystem dock
257262

258-
Advanced dialog when double-clicking an Ogg Vorbis or MP3 file in the FileSystem dock
263+
Advanced dialog when double-clicking an Ogg Vorbis, MP3 or Opus file in the FileSystem dock
259264

260265
This dialog allows you to edit the audio's loop point with a real-time preview,
261266
in addition to the :abbr:`BPM (Beats Per Minute)`, beat count and bar beats.
@@ -265,7 +270,7 @@ music tracks).
265270

266271
.. note::
267272

268-
Unlike WAV files, Ogg Vorbis and MP3 only support a "loop begin" loop point,
273+
Unlike WAV files, Ogg Vorbis, MP3 and Opus only support a "loop begin" loop point,
269274
not a "loop end" point. Looping can also be only be standard forward looping,
270275
not ping-pong or backward.
271276

@@ -300,6 +305,38 @@ sample rate and number of channels for your audio:
300305
reduced to 22 kHz without a noticeable loss in quality (unless the voice is
301306
very high-pitched). This is because most human voices never go past 11 kHz.
302307

308+
Use the right bitrate for the chosen file format
309+
~~~~~~~~~~~~~~~~~~~~~~~
310+
311+
While audio files are commonly compressed as MP3 for historical reasons, formats like Ogg Vorbis
312+
and Opus can provide lower sizes with higher quality.
313+
314+
Here is a comparative chart with estimates for "transparent" bitrates for each audio format:
315+
316+
+--------------------+--------------------------------+
317+
| Format | Estimated Transparency Bitrate |
318+
+====================+================================+
319+
| WAV (uncompressed) | 1411 kbps |
320+
+--------------------+--------------------------------+
321+
| MP3 | 192 kbps |
322+
+--------------------+--------------------------------+
323+
| Ogg Vorbis | 160 kbps |
324+
+--------------------+--------------------------------+
325+
| Opus | 128 kbps |
326+
+--------------------+--------------------------------+
327+
328+
Since audio at "transparent" bitrates has no noticeable compression artifacts (even with studio
329+
headphones) you can save space without impacting quality by reducing the bitrate to the level
330+
of transparency. Note that audio can sound "good enough" at much lower bitrates, depending on
331+
the purpose of the audio.
332+
333+
When changing the format or reducing the bitrate of an audio file, avoid converting from one lossy
334+
format to another (e.g. MP3 to Ogg Vorbis) to avoid generational loss. Always convert from
335+
the source WAV file if possible.
336+
337+
Unless processing power is limited, always prefer Opus encoding as it provides the best quality
338+
for a given bitrate. MP3 and Ogg Vorbis are older and use outdated compression techniques.
339+
303340
Use real-time audio effects to reduce file size
304341
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305342

tutorials/io/runtime_file_loading_and_saving.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Example of loading an image and displaying it in a :ref:`class_TextureRect` node
168168
Audio/video files
169169
-----------------
170170

171-
Godot supports loading Ogg Vorbis, MP3, and WAV audio at runtime. Note that not *all*
171+
Godot supports loading Ogg Vorbis, MP3, Opus and WAV audio at runtime. Note that not *all*
172172
files with a ``.ogg`` extension are Ogg Vorbis files. Some may be Ogg Theora
173173
videos, or contain Opus audio within an Ogg container. These files will **not**
174174
load correctly as audio files in Godot.

0 commit comments

Comments
 (0)