This commit is contained in:
Nyx
2025-08-26 11:39:30 -06:00
5 changed files with 88 additions and 10 deletions

View File

@@ -0,0 +1,11 @@
[configuration]
entry_symbol = "steam_audio_library_init"
compatibility_minimum = 4.1
[icons]
Example = "icons/Example.svg"
[libraries]
linux.debug.x86_64 = "lib/Linux-x86_64/libSteamAudioGodot-d.so"
macos.debug = "lib/Darwin-Universal/libSteamAudioGodot-d.dylib"
windows.debug.x86_64 = "lib/Windows-AMD64/libSteamAudioGodot-d.dll"

View File

@@ -0,0 +1 @@
uid://bo0wlwtwpxcrd

View File

@@ -14,6 +14,8 @@ void initialize_steam_audio(ModuleInitializationLevel p_level) {
} }
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
register_steam_audio_settings(); register_steam_audio_settings();
GDREGISTER_RUNTIME_CLASS(SteamAudio);
GDREGISTER_RUNTIME_CLASS(SteamAudioServer)
GDREGISTER_RUNTIME_CLASS(SteamAudioMaterial); GDREGISTER_RUNTIME_CLASS(SteamAudioMaterial);
GDREGISTER_RUNTIME_CLASS(SteamAudioListener); GDREGISTER_RUNTIME_CLASS(SteamAudioListener);
GDREGISTER_RUNTIME_CLASS(SteamAudioSource); GDREGISTER_RUNTIME_CLASS(SteamAudioSource);
@@ -38,7 +40,6 @@ void register_steam_audio_settings() {
info["type"] = Variant::INT; info["type"] = Variant::INT;
info["hint"] = PROPERTY_HINT_ENUM; info["hint"] = PROPERTY_HINT_ENUM;
info["hint_string"] = "Steam RT,Embree RT"; info["hint_string"] = "Steam RT,Embree RT";
info["usage"] = PROPERTY_USAGE_DEFAULT;
settings->add_property_info(info); settings->add_property_info(info);
settings->set_initial_value("steam_audio/ray_tracer/RayTracer",1); settings->set_initial_value("steam_audio/ray_tracer/RayTracer",1);
} }
@@ -50,7 +51,6 @@ void register_steam_audio_settings() {
info["type"] = Variant::INT; info["type"] = Variant::INT;
info["hint"] = PROPERTY_HINT_ENUM; info["hint"] = PROPERTY_HINT_ENUM;
info["hint_string"] = "Panning,HRTF,Ambisonic Pan,Ambisonic Binaural"; info["hint_string"] = "Panning,HRTF,Ambisonic Pan,Ambisonic Binaural";
info["usage"] = PROPERTY_USAGE_DEFAULT;
settings->add_property_info(info); settings->add_property_info(info);
settings->set_initial_value("steam_audio/spatializer/spatializer",1); settings->set_initial_value("steam_audio/spatializer/spatializer",1);
} }
@@ -62,7 +62,6 @@ void register_steam_audio_settings() {
info["type"] = Variant::INT; info["type"] = Variant::INT;
info["hint"] = PROPERTY_HINT_ENUM; info["hint"] = PROPERTY_HINT_ENUM;
info["hint_string"] = "Default,Custom"; info["hint_string"] = "Default,Custom";
info["usage"] = PROPERTY_USAGE_DEFAULT;
settings->add_property_info(info); settings->add_property_info(info);
settings->set_initial_value("steam_audio/spatializer/HRTF/HRTF_Type",0); settings->set_initial_value("steam_audio/spatializer/HRTF/HRTF_Type",0);
} }
@@ -74,7 +73,6 @@ void register_steam_audio_settings() {
info["type"] = Variant::STRING; info["type"] = Variant::STRING;
info["hint"] = PROPERTY_HINT_FILE; info["hint"] = PROPERTY_HINT_FILE;
info["hint_string"] = ""; info["hint_string"] = "";
info["usage"] = PROPERTY_USAGE_DEFAULT;
settings->add_property_info(info); settings->add_property_info(info);
settings->set_initial_value("steam_audio/spatializer/HRTF/Sofa_File",""); settings->set_initial_value("steam_audio/spatializer/HRTF/Sofa_File","");
} }
@@ -86,7 +84,6 @@ void register_steam_audio_settings() {
info["type"] = Variant::FLOAT; info["type"] = Variant::FLOAT;
info["hint"] = PROPERTY_HINT_RANGE; info["hint"] = PROPERTY_HINT_RANGE;
info["hint_string"] = "0.0,1.0,.01,slider"; info["hint_string"] = "0.0,1.0,.01,slider";
info["usage"] = PROPERTY_USAGE_DEFAULT;
settings->add_property_info(info); settings->add_property_info(info);
settings->set_initial_value("steam_audio/spatializer/HRTF/Volume",1.0f); settings->set_initial_value("steam_audio/spatializer/HRTF/Volume",1.0f);
} }
@@ -98,7 +95,6 @@ void register_steam_audio_settings() {
info["type"] = Variant::INT; info["type"] = Variant::INT;
info["hint"] = PROPERTY_HINT_ENUM; info["hint"] = PROPERTY_HINT_ENUM;
info["hint_string"] = "NONE,Root Mean Squared"; info["hint_string"] = "NONE,Root Mean Squared";
info["usage"] = PROPERTY_USAGE_DEFAULT;
settings->add_property_info(info); settings->add_property_info(info);
settings->set_initial_value("steam_audio/spatializer/HRTF/Norm_Type",0); settings->set_initial_value("steam_audio/spatializer/HRTF/Norm_Type",0);
} }

View File

@@ -3,14 +3,62 @@
using namespace godot; using namespace godot;
SteamAudioServer::SteamAudioServer() { SteamAudioServer::SteamAudioServer() {
initialize();
} }
SteamAudioServer::~SteamAudioServer() { SteamAudioServer::~SteamAudioServer() {
shutdown();
} }
// Core Godot Methods // Core Godot Methods
void SteamAudioServer::_bind_methods() { void SteamAudioServer::_bind_methods() {
}
void SteamAudioServer::initialize() {
IPLerror err = iplContextCreate(&ctxSettings,&ctx);
if (err!=IPL_STATUS_SUCCESS) {
ERR_PRINT("Failed to create IPL context");
}
switch (static_cast<int>(proj_settings->get_setting("steam_audio/ray_tracer/RayTracer"))){
case 0:
break;
case 1:
err = iplEmbreeDeviceCreate(ctx,&embreeDeviceSettings,embreeDevice);
if (err!=IPL_STATUS_SUCCESS) {
ERR_PRINT("Failed to create Embree device");
}
default:
break;
}
iplSimulatorCreate(ctx,&simulationSettings,&simulator);
} }
void SteamAudioServer::shutdown() {
if (simulator!=nullptr)
iplSimulatorRelease(&simulator);
if (ctx!=nullptr)
iplContextRelease(&ctx);
if (embreeDevice!=nullptr)
iplEmbreeDeviceRelease(embreeDevice);
if (scene!=nullptr)
iplSceneRelease(scene);
if (hrtf!=nullptr)
iplHRTFRelease(&hrtf);
}
void SteamAudioServer::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POSTINITIALIZE:
directThread.instantiate();
indirectThread.instantiate();
directThread->start(callable_mp(this,&SteamAudioServer::start_direct_thread),Thread::PRIORITY_NORMAL);
indirectThread->start(callable_mp(this,&SteamAudioServer::start_indirect_thread),Thread::PRIORITY_NORMAL);
}
}
void SteamAudioServer::start_direct_thread() {
iplSimulatorRunDirect(simulator);
}
void SteamAudioServer::start_indirect_thread() {
iplSimulatorRunReflections(simulator);
}

View File

@@ -5,6 +5,8 @@
#include <godot_cpp/classes/wrapped.hpp> #include <godot_cpp/classes/wrapped.hpp>
#include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/godot.hpp> #include <godot_cpp/godot.hpp>
#include <godot_cpp/classes/thread.hpp>
#include <godot_cpp/classes/mutex.hpp>
#include <phonon.h> #include <phonon.h>
#include <steam_audio.hpp> #include <steam_audio.hpp>
#include "steam_audio_dynamic_mesh.hpp" #include "steam_audio_dynamic_mesh.hpp"
@@ -17,12 +19,32 @@ using namespace godot;
class SteamAudioServer : public Object { class SteamAudioServer : public Object {
GDCLASS(SteamAudioServer, Object) // Godot class declaration macro GDCLASS(SteamAudioServer, Object) // Godot class declaration macro
private: private:
IPLContext ctx=nullptr;
IPLContextSettings ctxSettings;
IPLAudioSettings audioSettings;
IPLEmbreeDevice *embreeDevice=nullptr;
IPLEmbreeDeviceSettings embreeDeviceSettings;
IPLScene *scene=nullptr;
IPLSceneSettings sceneSettings;
IPLSimulator simulator;
IPLSimulationSettings simulationSettings;
IPLHRTF hrtf;
IPLHRTFSettings hrtfSettings;
ProjectSettings *proj_settings = ProjectSettings::get_singleton();
Ref<Thread> directThread;
Ref<Thread> indirectThread;
public: public:
SteamAudioServer(); // Constructor SteamAudioServer(); // Constructor
~SteamAudioServer() override; // Destructor ~SteamAudioServer() override; // Destructor
void _notification(int p_what);
protected: protected:
static void _bind_methods(); // Bind methods to Godot static void _bind_methods();
void initialize();
void shutdown();
void start_direct_thread();
void start_indirect_thread();
}; };