Skip to content

Commit

Permalink
Fixes for 4.3 compat, in-engine docs.
Browse files Browse the repository at this point in the history
(closes #66, closes #68, closes #2)
  • Loading branch information
stechyo committed Aug 24, 2024
1 parent 4660cad commit 40792b1
Show file tree
Hide file tree
Showing 21 changed files with 324 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ project/addons/godot-steam-audio/bin/*.ilk
project/addons/godot-steam-audio/bin/*.exp
project/addons/godot-steam-audio/bin/*.lib
project/addons/godot-steam-audio/bin/*.dylib
src/gen/*
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "src/lib/godot-cpp"]
path = src/lib/godot-cpp
url = https://github.com/stechyo/godot-cpp
branch = gdext/steam-audio
branch = 4.3-steam-audio
[submodule "src/lib/steamaudio"]
path = src/lib/steamaudio
url = https://github.com/ValveSoftware/steam-audio
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# godot-steam-audio
This is a GDExtension that integrates the [steam-audio](https://valvesoftware.github.io/steam-audio/) library
into Godot 4.2. This adds sound effects such as occlusion and reverb into the engine.
into Godot 4.3. This adds sound effects such as occlusion and reverb into the engine.

### [Demo Video](https://www.youtube.com/watch?v=vRnzfnb93Gw)
![A picture of the editor screen with some godot-steam-audio nodes.](doc/imgs/editor.png)
Expand Down
4 changes: 4 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ elif env["platform"] == "macos":
env.Append(LIBPATH=[f'{steam_audio_lib_path}/osx'])
env.Append(LIBS=["libphonon.dylib"])

if env["target"] in ["editor", "template_debug"]:
doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
sources.append(doc_data)

library = env.SharedLibrary(
"project/addons/godot-steam-audio/bin/godot-steam-audio{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
Expand Down
42 changes: 42 additions & 0 deletions doc_classes/SteamAudioConfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioConfig" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
</brief_description>
<description>
This node makes [SteamAudioServer] tick. You must have one, and only one, instance of it in your scene if you'd like the extension to do anything.
</description>
<tutorials>
</tutorials>
<members>
<member name="diffuse_samples" type="int" setter="set_num_diffuse_samples" getter="get_num_diffuse_samples" default="32">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N21IPLSimulationSettings17numDiffuseSamplesE]IPLSimulationSettings.numDiffuseSamples[/url]
</member>
<member name="global_log_level" type="int" setter="set_global_log_level" getter="get_global_log_level" enum="SteamAudio.GodotSteamAudioLogLevel" default="1">
The global log level for this extension. Setting it to a lower level will show more logs.
</member>
<member name="hrtf_volume" type="float" setter="set_hrtf_volume" getter="get_hrtf_volume" default="1.0">
Audio volume (see [url=https://valvesoftware.github.io/steam-audio/doc/capi/hrtf.html#_CPPv4N15IPLHRTFSettings6volumeE]IPLHRTFSettings.volume[/url])
</member>
<member name="max_ambisonics_order" type="int" setter="set_max_ambisonics_order" getter="get_max_ambisonics_order" default="1">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N21IPLSimulationSettings8maxOrderE]IPLSimulationSettings.maxOrder[/url]
</member>
<member name="max_occlusion_samples" type="int" setter="set_max_num_occ_samples" getter="get_max_num_occ_samples" default="64">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N21IPLSimulationSettings22maxNumOcclusionSamplesE]IPLSimulationSettings.maxNumOcclusionSamples[/url]
</member>
<member name="max_reflection_duration" type="float" setter="set_max_refl_duration" getter="get_max_refl_duration" default="2.0">
Higher values will result in more realistic reflections, but this will impact performance - see [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N21IPLSimulationSettings11maxDurationE]IPLSimulationSettings.maxDuration[/url]
</member>
<member name="max_reflection_rays" type="int" setter="set_max_num_refl_rays" getter="get_max_num_refl_rays" default="4096">
Overrides each source's max_reflection_rays setting - see [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N21IPLSimulationSettings10maxNumRaysE]IPLSimulationSettings.maxNumRays[/url]
</member>
<member name="max_reflection_sources" type="float" setter="set_max_num_refl_srcs" getter="get_max_num_refl_srcs" default="8.0">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N21IPLSimulationSettings13maxNumSourcesE]IPLSimulationSettings.maxNumSources[/url]
</member>
<member name="reflection_threads" type="float" setter="set_num_refl_threads" getter="get_num_refl_threads" default="2.0">
Number of threads that reflection simulation will use (see [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N21IPLSimulationSettings10numThreadsE]IPLSimulationSettings.numThreads[/url])
</member>
<member name="scene_type" type="int" setter="set_scene_type" getter="get_scene_type" enum="IPLSceneType" default="1">
The ray tracing implementation to use - see [url=https://valvesoftware.github.io/steam-audio/doc/capi/scene.html#_CPPv412IPLSceneType]IPLSceneType[/url]
</member>
</members>
</class>
32 changes: 32 additions & 0 deletions doc_classes/SteamAudioDynamicGeometry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioDynamicGeometry" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
Dynamic geometry that will affect SteamAudio simulation.
</brief_description>
<description>
This node will attempt to get a mesh from its parent at [code]_ready()[/code] and add it to the internal SteamAudio scene. Adding a node after the game has started probably works, but it is not supported. If this object isn't going to move, then just use [SteamAudioGeometry].

This node can extract meshes from the following nodes:
- [MeshInstance3D]
- [CollisionShape3D], [b]if its shape is one of[/b]:
- [BoxShape3D]
- [CylinderShape3D]
- [CapsuleShape3D]
- [SphereShape3D]
- [ConcavePolygonShape3D]
</description>
<tutorials>
</tutorials>
<methods>
<method name="recalculate">
<return type="void" />
<description>
</description>
</method>
</methods>
<members>
<member name="material" type="SteamAudioMaterial" setter="set_material" getter="get_material">
The geometry's material.
</member>
</members>
</class>
35 changes: 35 additions & 0 deletions doc_classes/SteamAudioGeometry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioGeometry" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
Static geometry that will affect SteamAudio simulation.
</brief_description>
<description>
This node will attempt to get a mesh from its parent at [code]_ready()[/code] and add it to the internal SteamAudio scene. Adding a node after the game has started probably works, but it is not supported. If you want to move this node's transform at runtime, use [code]recalculate()[/code] or consider (if you want more detailed simulation and don't mind worse performance) [SteamAudioDynamicGeometry].
This node can extract meshes from the following nodes:
- [MeshInstance3D]
- [CollisionShape3D], [b]if its shape is one of[/b]:
- [BoxShape3D]
- [CylinderShape3D]
- [CapsuleShape3D]
- [SphereShape3D]
- [ConcavePolygonShape3D]
</description>
<tutorials>
</tutorials>
<methods>
<method name="recalculate">
<return type="void" />
<description>
Changes the internal SteamAudio scene to reflect any changes in transform that you may have made to the object. If you plan on calling this every frame to account for an object's motion, it's probably better to use [SteamAudioDynamicGeometry].
</description>
</method>
</methods>
<members>
<member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false">
Whether the geometry is disabled.
</member>
<member name="material" type="SteamAudioMaterial" setter="set_material" getter="get_material">
The geometry's material.
</member>
</members>
</class>
27 changes: 27 additions & 0 deletions doc_classes/SteamAudioListener.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioListener" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
This node's transform is used for simulating the listener's transform in the SteamAudio simulation. You'll likely want to have this as a child of your [Camera3D].
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<members>
<member name="irradiance_min_distance" type="float" setter="set_irradiance_min_dist" getter="get_irradiance_min_dist" default="1.0">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N25IPLSimulationSharedInputs21irradianceMinDistanceE]IPLSimulationSharedInputs.irradianceMinDistance[/url]
</member>
<member name="reflection_ambisonics_order" type="int" setter="set_refl_ambisonics_order" getter="get_refl_ambisonics_order" default="1">
May be overriden by [SteamAudioConfig] - see [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N25IPLSimulationSharedInputs5orderE]IPLSimulationSharedInputs.order[/url]
</member>
<member name="reflection_bounces" type="int" setter="set_num_refl_bounces" getter="get_num_refl_bounces" default="16">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N25IPLSimulationSharedInputs10numBouncesE]IPLSimulationSharedInputs.numBounces[/url]
</member>
<member name="reflection_duration" type="float" setter="set_refl_duration" getter="get_refl_duration" default="2.0">
May be overriden by [SteamAudioConfig] - see [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N25IPLSimulationSharedInputs8durationE]IPLSimulationSharedInputs.duration[/url]
</member>
<member name="reflection_rays" type="int" setter="set_num_refl_rays" getter="get_num_refl_rays" default="4096">
May be overriden by [SteamAudioConfig] - see [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N25IPLSimulationSharedInputs7numRaysE]IPLSimulationSharedInputs.numRays[/url]
</member>
</members>
</class>
34 changes: 34 additions & 0 deletions doc_classes/SteamAudioMaterial.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioMaterial" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
The acoustic properties of a surface.
</brief_description>
<description>
This resource is a Godot translation of [url=https://valvesoftware.github.io/steam-audio/doc/capi/scene.html?highlight=iplmaterial#_CPPv411IPLMaterial]IPLMaterial[/url]. Low, middle, and high refer to frequency bands with center frequencies of 400Hz, 2.5kHz and 15kHz.
</description>
<tutorials>
</tutorials>
<members>
<member name="absorption_high" type="float" setter="set_absorption_high" getter="get_absorption_high" default="0.0">
Fraction of sound energy absorbed at high frequencies.
</member>
<member name="absorption_low" type="float" setter="set_absorption_low" getter="get_absorption_low" default="0.0">
Fraction of sound energy absorbed at low frequencies.
</member>
<member name="absorption_mid" type="float" setter="set_absorption_mid" getter="get_absorption_mid" default="0.0">
Fraction of sound energy absorbed at mid frequencies.
</member>
<member name="scattering" type="float" setter="set_scattering" getter="get_scattering" default="0.0">
Fraction of sound energy scattered in a random direction when reflecting.
</member>
<member name="transmission_high" type="float" setter="set_transmission_high" getter="get_transmission_high" default="0.0">
Fraction of sound energy absorbed at high frequencies.
</member>
<member name="transmission_low" type="float" setter="set_transmission_low" getter="get_transmission_low" default="0.0">
Fraction of sound energy absorbed at low frequencies.
</member>
<member name="transmission_mid" type="float" setter="set_transmission_mid" getter="get_transmission_mid" default="0.0">
Fraction of sound energy absorbed at mid frequencies.
</member>
</members>
</class>
65 changes: 65 additions & 0 deletions doc_classes/SteamAudioPlayer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioPlayer" inherits="AudioStreamPlayer3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
This player's transform is used as the audio source transform in the SteamAudio simulation.
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_inner_stream">
<return type="AudioStream" />
<description>
Returns the player's inner [AudioStream]
</description>
</method>
<method name="get_inner_stream_playback">
<return type="AudioStreamPlayback" />
<description>
Returns the player's inner [AudioStreamPlayback]
</description>
</method>
<method name="play_stream">
<return type="void" />
<param index="0" name="stream" type="AudioStream" />
<param index="1" name="from_offset" type="float" default="0" />
<param index="2" name="volume_db" type="float" default="0" />
<param index="3" name="pitch_scale" type="float" default="1.0" />
<description>
Plays the given stream starting at from_offset, at the defined volume and pitch scale.
[b]A very important note[/b]: play_stream is what you want to use if you'd like to change a SteamAudioPlayer's stream at runtime. Do not try to set the player's stream directly through set_stream, as that will disable all SteamAudio effects for that player. At runtime, the stream you've configured will be replaced with a [SteamAudioStream]. This stream has an inner stream which corresponds to what you configured in the scene.
</description>
</method>
</methods>
<members>
<member name="ambisonics_order" type="int" setter="set_ambisonics_order" getter="get_ambisonics_order" default="1">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/ambisonics-encode-effect.html#_CPPv4N31IPLAmbisonicsEncodeEffectParams5orderE]IPLAmbisonicsEncodeEffectParams.order[/url].
</member>
<member name="distance_attenuation" type="bool" setter="set_dist_attn_on" getter="is_dist_attn_on" default="false">
Whether SteamAudio distance attenuation is enabled. Keep in mind that this is disabled by default, and enabling it will disable Godot's built-in attenuation, which you can only re-enable when you disable this.
</member>
<member name="max_reflection_distance" type="float" setter="set_max_reflection_distance" getter="get_max_reflection_distance" default="10000.0">
The maximum distance from the listener at which reflection simulation is run for this audio source. Keep in mind that this does not disable reflection if it has already been simulated, it just doesn't update the effect.
</member>
<member name="min_attenuation_distance" type="float" setter="set_min_attenuation_distance" getter="get_min_attenuation_distance" default="0.0">
See
[url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N27IPLDistanceAttenuationModel11minDistanceE]IPLDistanceAttenuationModel.minDistance[/url], and note the distance attenuation type in godot-steam-audio is always [code]IPL_DISTANCEATTENUATIONTYPE_INVERSEDISTANCE[/code].
</member>
<member name="occlusion" type="bool" setter="set_occlusion_on" getter="is_occlusion_on" default="true">
Whether SteamAudio occlusion and transmission is enabled.
</member>
<member name="occlusion_radius" type="float" setter="set_occlusion_radius" getter="get_occlusion_radius" default="4.0">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N19IPLSimulationInputs15occlusionRadiusE]IPLSimulationInputs.occlusionRadius[/url].
</member>
<member name="occlusion_samples" type="int" setter="set_occlusion_samples" getter="get_occlusion_samples" default="32">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N19IPLSimulationInputs19numOcclusionSamplesE]IPLSimulationInputs.numOcclusionSamples.
</member>
<member name="reflection" type="bool" setter="set_reflection_on" getter="is_reflection_on" default="false">
Whether SteamAudio reflection is on.
</member>
<member name="transmission_rays" type="int" setter="set_transmission_rays" getter="get_transmission_rays" default="16">
See [url=https://valvesoftware.github.io/steam-audio/doc/capi/simulation.html#_CPPv4N19IPLSimulationInputs19numTransmissionRaysE]IPLSimulationInputs.numTransmissionRays[/url].
</member>
</members>
</class>
22 changes: 22 additions & 0 deletions doc_classes/SteamAudioServer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioServer" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
This is a singleton that handles all SteamAudio global state. You should not interact with it directly.
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_singleton" qualifiers="static">
<return type="SteamAudioServer" />
<description>
</description>
</method>
<method name="tick">
<return type="void" />
<description>
</description>
</method>
</methods>
</class>
10 changes: 10 additions & 0 deletions doc_classes/SteamAudioStream.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioStream" inherits="AudioStream" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
You do not need to, and [b]should not[/b] assign this stream to your [SteamAudioPlayer], as the extension handles that for you.
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
</class>
21 changes: 21 additions & 0 deletions doc_classes/SteamAudioStreamPlayback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SteamAudioStreamPlayback" inherits="AudioStreamPlayback" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
This playback will contain an audio stream that you provided when configuring your Godot scene, and it will apply the SteamAudio effects configured in the corresponding [SteamAudioPlayer] to it.
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="play_stream">
<return type="int" />
<param index="0" name="stream" type="AudioStream" />
<param index="1" name="from_offset" type="float" default="0" />
<param index="2" name="volume_db" type="float" default="0" />
<param index="3" name="pitch_scale" type="float" default="1.0" />
<description>
</description>
</method>
</methods>
</class>
Loading

0 comments on commit 40792b1

Please sign in to comment.