diff --git a/demo/Scenes/game.tscn b/demo/Scenes/game.tscn index 841c23a..75efc17 100644 --- a/demo/Scenes/game.tscn +++ b/demo/Scenes/game.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=6 format=3 uid="uid://dtccwj1qujhxp"] [ext_resource type="PackedScene" uid="uid://djvqisfxi1l0b" path="res://Scenes/Characters/Player.tscn" id="1_ebmjs"] -[ext_resource type="Texture2D" uid="uid://bj23bn0s4mt0d" path="res://icon.svg" id="1_qxrlw"] +[ext_resource type="Texture2D" uid="uid://ch0aljsxfwrd6" path="res://icon.svg" id="1_qxrlw"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wrm1d"] albedo_texture = ExtResource("1_qxrlw") @@ -45,8 +45,7 @@ shape = SubResource("WorldBoundaryShape3D_ebmjs") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.039711, 1, -0.146652) [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.703544, 0.710652, 0, -0.710652, 0.703544, 0, 7.28685, 0) - -[node name="SteamAudioManager" type="SteamAudioManager" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.70354384, 0.7106518, 0, -0.7106518, 0.70354384, -1.0560093, 9.826818, -1.0042496) [node name="SteamAudioSource" type="SteamAudioSource" parent="."] +attenuation_model = 0 diff --git a/demo/icon.svg.import b/demo/icon.svg.import index de936f7..6d36685 100644 --- a/demo/icon.svg.import +++ b/demo/icon.svg.import @@ -3,19 +3,20 @@ importer="texture" type="CompressedTexture2D" uid="uid://ch0aljsxfwrd6" -path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://icon.svg" -dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/uastc_level=0 @@ -23,7 +24,7 @@ compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -37,7 +38,7 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 svg/scale=1.0 editor/scale_with_editor_scale=false editor/convert_colors_with_editor_theme=false diff --git a/demo/project.godot b/demo/project.godot index 850d8a4..6b044fa 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -13,3 +13,11 @@ config_version=5 config/name="demo" config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" + +[steam_audio] + +ray_tracer/RayTracer=0 +spatializer/spatializer=0 +spatializer/HRTF/Sofa_File=0.0 +sampling_rate=0 +buffer_size=0 diff --git a/extern/godot-cpp b/extern/godot-cpp index e4b7c25..449e37f 160000 --- a/extern/godot-cpp +++ b/extern/godot-cpp @@ -1 +1 @@ -Subproject commit e4b7c25e721ce3435a029087e3917a30aa73f06b +Subproject commit 449e37fa219a326c9e0c3a3de6cee635eb15e75d diff --git a/extern/steam-audio b/extern/steam-audio index eba1798..f398d69 160000 --- a/extern/steam-audio +++ b/extern/steam-audio @@ -1 +1 @@ -Subproject commit eba1798c11b9b3bf0cf2c9cca91c6e9d7bec782e +Subproject commit f398d69fa568e0d05f56224ca6b5df45a853bb18 diff --git a/src/register_types.cpp b/src/register_types.cpp index 32a4ac5..6757a72 100644 --- a/src/register_types.cpp +++ b/src/register_types.cpp @@ -8,14 +8,15 @@ void initialize_steam_audio(ModuleInitializationLevel p_level) { if (p_level!=MODULE_INITIALIZATION_LEVEL_SCENE && p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) { return; } + if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) { GDREGISTER_CLASS(SteamAudioServer); srv = memnew(SteamAudioServer); } + 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); @@ -28,6 +29,7 @@ void uninitialize_steam_audio(ModuleInitializationLevel p_level) { if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) { memdelete(srv); } + } void register_steam_audio_settings() { diff --git a/src/steam_audio_server.cpp b/src/steam_audio_server.cpp index a79ac2e..2d99206 100644 --- a/src/steam_audio_server.cpp +++ b/src/steam_audio_server.cpp @@ -3,7 +3,7 @@ using namespace godot; SteamAudioServer::SteamAudioServer() { - initialize(); + } SteamAudioServer::~SteamAudioServer() { @@ -15,6 +15,8 @@ void SteamAudioServer::_bind_methods() { } void SteamAudioServer::initialize() { + if (Engine::get_singleton()->is_editor_hint()) + return; IPLerror err = iplContextCreate(&ctxSettings,&ctx); if (err!=IPL_STATUS_SUCCESS) { ERR_PRINT("Failed to create IPL context"); @@ -50,8 +52,12 @@ void SteamAudioServer::shutdown() { void SteamAudioServer::_notification(int p_what) { switch (p_what) { case NOTIFICATION_POSTINITIALIZE: + + initialize(); + 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); } @@ -61,4 +67,8 @@ void SteamAudioServer::start_direct_thread() { } void SteamAudioServer::start_indirect_thread() { iplSimulatorRunReflections(simulator); - } \ No newline at end of file + } + +void SteamAudioServer::register_audio_source(SteamAudioSource *source) { + + } diff --git a/src/steam_audio_server.hpp b/src/steam_audio_server.hpp index 16922b2..05b0ca4 100644 --- a/src/steam_audio_server.hpp +++ b/src/steam_audio_server.hpp @@ -19,6 +19,16 @@ using namespace godot; class SteamAudioServer : public Object { GDCLASS(SteamAudioServer, Object) // Godot class declaration macro private: + struct AudioSourceData { + Vector input_buffer; + Vector output_buffer; + IPLSource source; + Transform3D transform; + bool needs_processing = false; + }; + + std::unordered_map audio_sources; + Ref audio_mutex; IPLContext ctx=nullptr; IPLContextSettings ctxSettings; IPLAudioSettings audioSettings; @@ -40,6 +50,10 @@ public: SteamAudioServer(); // Constructor ~SteamAudioServer() override; // Destructor void _notification(int p_what); + void register_audio_source(SteamAudioSource *source); + void unregister_audio_source(SteamAudioSource *source); + void process_audio_source(SteamAudioSource *source, const Vector &input_buffer); + Vector get_processed_audio_buffer(SteamAudioSource *source); protected: static void _bind_methods();