Merge branch 'master' of https://github.com/TheRiverNyx/steam-audio-godot
This commit is contained in:
11
demo/addons/SteamAudioGodot/SteamAudioGodot.gdextension
Normal file
11
demo/addons/SteamAudioGodot/SteamAudioGodot.gdextension
Normal 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"
|
||||
@@ -0,0 +1 @@
|
||||
uid://bo0wlwtwpxcrd
|
||||
@@ -14,6 +14,8 @@ void initialize_steam_audio(ModuleInitializationLevel p_level) {
|
||||
}
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
register_steam_audio_settings();
|
||||
GDREGISTER_RUNTIME_CLASS(SteamAudio);
|
||||
GDREGISTER_RUNTIME_CLASS(SteamAudioServer)
|
||||
GDREGISTER_RUNTIME_CLASS(SteamAudioMaterial);
|
||||
GDREGISTER_RUNTIME_CLASS(SteamAudioListener);
|
||||
GDREGISTER_RUNTIME_CLASS(SteamAudioSource);
|
||||
@@ -38,7 +40,6 @@ void register_steam_audio_settings() {
|
||||
info["type"] = Variant::INT;
|
||||
info["hint"] = PROPERTY_HINT_ENUM;
|
||||
info["hint_string"] = "Steam RT,Embree RT";
|
||||
info["usage"] = PROPERTY_USAGE_DEFAULT;
|
||||
settings->add_property_info(info);
|
||||
settings->set_initial_value("steam_audio/ray_tracer/RayTracer",1);
|
||||
}
|
||||
@@ -50,7 +51,6 @@ void register_steam_audio_settings() {
|
||||
info["type"] = Variant::INT;
|
||||
info["hint"] = PROPERTY_HINT_ENUM;
|
||||
info["hint_string"] = "Panning,HRTF,Ambisonic Pan,Ambisonic Binaural";
|
||||
info["usage"] = PROPERTY_USAGE_DEFAULT;
|
||||
settings->add_property_info(info);
|
||||
settings->set_initial_value("steam_audio/spatializer/spatializer",1);
|
||||
}
|
||||
@@ -62,7 +62,6 @@ void register_steam_audio_settings() {
|
||||
info["type"] = Variant::INT;
|
||||
info["hint"] = PROPERTY_HINT_ENUM;
|
||||
info["hint_string"] = "Default,Custom";
|
||||
info["usage"] = PROPERTY_USAGE_DEFAULT;
|
||||
settings->add_property_info(info);
|
||||
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["hint"] = PROPERTY_HINT_FILE;
|
||||
info["hint_string"] = "";
|
||||
info["usage"] = PROPERTY_USAGE_DEFAULT;
|
||||
settings->add_property_info(info);
|
||||
settings->set_initial_value("steam_audio/spatializer/HRTF/Sofa_File","");
|
||||
}
|
||||
@@ -86,7 +84,6 @@ void register_steam_audio_settings() {
|
||||
info["type"] = Variant::FLOAT;
|
||||
info["hint"] = PROPERTY_HINT_RANGE;
|
||||
info["hint_string"] = "0.0,1.0,.01,slider";
|
||||
info["usage"] = PROPERTY_USAGE_DEFAULT;
|
||||
settings->add_property_info(info);
|
||||
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["hint"] = PROPERTY_HINT_ENUM;
|
||||
info["hint_string"] = "NONE,Root Mean Squared";
|
||||
info["usage"] = PROPERTY_USAGE_DEFAULT;
|
||||
settings->add_property_info(info);
|
||||
settings->set_initial_value("steam_audio/spatializer/HRTF/Norm_Type",0);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,62 @@
|
||||
using namespace godot;
|
||||
|
||||
SteamAudioServer::SteamAudioServer() {
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
SteamAudioServer::~SteamAudioServer() {
|
||||
|
||||
shutdown();
|
||||
}
|
||||
|
||||
// Core Godot 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);
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <godot_cpp/classes/wrapped.hpp>
|
||||
#include <godot_cpp/core/class_db.hpp>
|
||||
#include <godot_cpp/godot.hpp>
|
||||
#include <godot_cpp/classes/thread.hpp>
|
||||
#include <godot_cpp/classes/mutex.hpp>
|
||||
#include <phonon.h>
|
||||
#include <steam_audio.hpp>
|
||||
#include "steam_audio_dynamic_mesh.hpp"
|
||||
@@ -17,12 +19,32 @@ using namespace godot;
|
||||
class SteamAudioServer : public Object {
|
||||
GDCLASS(SteamAudioServer, Object) // Godot class declaration macro
|
||||
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:
|
||||
SteamAudioServer(); // Constructor
|
||||
~SteamAudioServer() override; // Destructor
|
||||
void _notification(int p_what);
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user