This commit is contained in:
Nyx
2025-08-27 01:55:21 -06:00
parent 60546099a6
commit 8108879147
8 changed files with 49 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://dtccwj1qujhxp"] [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="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"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wrm1d"]
albedo_texture = ExtResource("1_qxrlw") 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) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.039711, 1, -0.146652)
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] [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) transform = Transform3D(1, 0, 0, 0, 0.70354384, 0.7106518, 0, -0.7106518, 0.70354384, -1.0560093, 9.826818, -1.0042496)
[node name="SteamAudioManager" type="SteamAudioManager" parent="."]
[node name="SteamAudioSource" type="SteamAudioSource" parent="."] [node name="SteamAudioSource" type="SteamAudioSource" parent="."]
attenuation_model = 0

View File

@@ -3,19 +3,20 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://ch0aljsxfwrd6" uid="uid://ch0aljsxfwrd6"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
metadata={ metadata={
"vram_texture": false "imported_formats": ["s3tc_bptc"],
"vram_texture": true
} }
[deps] [deps]
source_file="res://icon.svg" 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] [params]
compress/mode=0 compress/mode=2
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/uastc_level=0 compress/uastc_level=0
@@ -23,7 +24,7 @@ compress/rdo_quality_loss=0.0
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
mipmaps/generate=false mipmaps/generate=true
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""
@@ -37,7 +38,7 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false process/hdr_as_srgb=false
process/hdr_clamp_exposure=false process/hdr_clamp_exposure=false
process/size_limit=0 process/size_limit=0
detect_3d/compress_to=1 detect_3d/compress_to=0
svg/scale=1.0 svg/scale=1.0
editor/scale_with_editor_scale=false editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false editor/convert_colors_with_editor_theme=false

View File

@@ -13,3 +13,11 @@ config_version=5
config/name="demo" config/name="demo"
config/features=PackedStringArray("4.5", "Forward Plus") config/features=PackedStringArray("4.5", "Forward Plus")
config/icon="res://icon.svg" 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

View File

@@ -8,14 +8,15 @@ void initialize_steam_audio(ModuleInitializationLevel p_level) {
if (p_level!=MODULE_INITIALIZATION_LEVEL_SCENE && p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) { if (p_level!=MODULE_INITIALIZATION_LEVEL_SCENE && p_level != MODULE_INITIALIZATION_LEVEL_SERVERS) {
return; return;
} }
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) { if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
GDREGISTER_CLASS(SteamAudioServer); GDREGISTER_CLASS(SteamAudioServer);
srv = memnew(SteamAudioServer); srv = memnew(SteamAudioServer);
} }
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(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);
@@ -28,6 +29,7 @@ void uninitialize_steam_audio(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) { if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
memdelete(srv); memdelete(srv);
} }
} }
void register_steam_audio_settings() { void register_steam_audio_settings() {

View File

@@ -3,7 +3,7 @@
using namespace godot; using namespace godot;
SteamAudioServer::SteamAudioServer() { SteamAudioServer::SteamAudioServer() {
initialize();
} }
SteamAudioServer::~SteamAudioServer() { SteamAudioServer::~SteamAudioServer() {
@@ -15,6 +15,8 @@ void SteamAudioServer::_bind_methods() {
} }
void SteamAudioServer::initialize() { void SteamAudioServer::initialize() {
if (Engine::get_singleton()->is_editor_hint())
return;
IPLerror err = iplContextCreate(&ctxSettings,&ctx); IPLerror err = iplContextCreate(&ctxSettings,&ctx);
if (err!=IPL_STATUS_SUCCESS) { if (err!=IPL_STATUS_SUCCESS) {
ERR_PRINT("Failed to create IPL context"); ERR_PRINT("Failed to create IPL context");
@@ -50,8 +52,12 @@ void SteamAudioServer::shutdown() {
void SteamAudioServer::_notification(int p_what) { void SteamAudioServer::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_POSTINITIALIZE: case NOTIFICATION_POSTINITIALIZE:
initialize();
directThread.instantiate(); directThread.instantiate();
indirectThread.instantiate(); indirectThread.instantiate();
directThread->start(callable_mp(this,&SteamAudioServer::start_direct_thread),Thread::PRIORITY_NORMAL); directThread->start(callable_mp(this,&SteamAudioServer::start_direct_thread),Thread::PRIORITY_NORMAL);
indirectThread->start(callable_mp(this,&SteamAudioServer::start_indirect_thread),Thread::PRIORITY_NORMAL); indirectThread->start(callable_mp(this,&SteamAudioServer::start_indirect_thread),Thread::PRIORITY_NORMAL);
} }
@@ -62,3 +68,7 @@ void SteamAudioServer::start_direct_thread() {
void SteamAudioServer::start_indirect_thread() { void SteamAudioServer::start_indirect_thread() {
iplSimulatorRunReflections(simulator); iplSimulatorRunReflections(simulator);
} }
void SteamAudioServer::register_audio_source(SteamAudioSource *source) {
}

View File

@@ -19,6 +19,16 @@ 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:
struct AudioSourceData {
Vector<AudioFrame> input_buffer;
Vector<AudioFrame> output_buffer;
IPLSource source;
Transform3D transform;
bool needs_processing = false;
};
std::unordered_map<SteamAudioSource*,AudioSourceData> audio_sources;
Ref<Mutex> audio_mutex;
IPLContext ctx=nullptr; IPLContext ctx=nullptr;
IPLContextSettings ctxSettings; IPLContextSettings ctxSettings;
IPLAudioSettings audioSettings; IPLAudioSettings audioSettings;
@@ -40,6 +50,10 @@ public:
SteamAudioServer(); // Constructor SteamAudioServer(); // Constructor
~SteamAudioServer() override; // Destructor ~SteamAudioServer() override; // Destructor
void _notification(int p_what); 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<AudioFrame> &input_buffer);
Vector<AudioFrame> get_processed_audio_buffer(SteamAudioSource *source);
protected: protected:
static void _bind_methods(); static void _bind_methods();