Optimized spatial audio parameter detection
This commit is contained in:
parent
8900ce4a71
commit
e8985f4e79
3 changed files with 60 additions and 10 deletions
|
@ -3,6 +3,9 @@ extends AudioStreamPlayer2D
|
||||||
|
|
||||||
# EXPORTED VARS
|
# EXPORTED VARS
|
||||||
|
|
||||||
|
# detect every nth tick
|
||||||
|
@export var detect_mod: int = 4
|
||||||
|
|
||||||
@export_category("dampening effect")
|
@export_category("dampening effect")
|
||||||
@export var n_pointcasts_to_player: int = 25
|
@export var n_pointcasts_to_player: int = 25
|
||||||
@export var lowpass_cutoff_mult: float = 1000
|
@export var lowpass_cutoff_mult: float = 1000
|
||||||
|
@ -159,8 +162,12 @@ func _ready() -> void:
|
||||||
create_audio_bus_effects()
|
create_audio_bus_effects()
|
||||||
create_raycasts()
|
create_raycasts()
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
var tick: int = 0
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if tick == 0:
|
||||||
var reverb_params = determine_reverb_params()
|
var reverb_params = determine_reverb_params()
|
||||||
var blocked_amount = determine_distance_amount_blocked()
|
var blocked_amount = determine_distance_amount_blocked()
|
||||||
update_reverb(reverb_params[0], reverb_params[1])
|
update_reverb(reverb_params[0], reverb_params[1])
|
||||||
update_dampening(blocked_amount)
|
update_dampening(blocked_amount)
|
||||||
|
tick = (tick + 1) % detect_mod
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://core/polygon/polygon.gd" id="1_ga37f"]
|
[ext_resource type="Script" path="res://core/polygon/polygon.gd" id="1_ga37f"]
|
||||||
|
|
||||||
[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_cjgtr"]
|
[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_2cqf3"]
|
||||||
|
|
||||||
[node name="Polygon" type="CollisionPolygon2D"]
|
[node name="Polygon" type="CollisionPolygon2D"]
|
||||||
script = ExtResource("1_ga37f")
|
script = ExtResource("1_ga37f")
|
||||||
|
@ -11,4 +11,4 @@ script = ExtResource("1_ga37f")
|
||||||
|
|
||||||
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
|
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
|
||||||
editor_description = "For particle collisions"
|
editor_description = "For particle collisions"
|
||||||
occluder = SubResource("OccluderPolygon2D_cjgtr")
|
occluder = SubResource("OccluderPolygon2D_2cqf3")
|
||||||
|
|
|
@ -1,10 +1,43 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://c6w7lrydi43ts"]
|
[gd_scene load_steps=9 format=3 uid="uid://c6w7lrydi43ts"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cbynoofsjcl45" path="res://core/polygon/polygon.tscn" id="1_cup10"]
|
[ext_resource type="PackedScene" uid="uid://cbynoofsjcl45" path="res://core/polygon/polygon.tscn" id="1_cup10"]
|
||||||
[ext_resource type="Script" path="res://levels/intro.gd" id="1_pgj82"]
|
[ext_resource type="Script" path="res://levels/intro.gd" id="1_pgj82"]
|
||||||
[ext_resource type="Script" path="res://core/audio/spatial_audio_player.gd" id="3_3eqhh"]
|
[ext_resource type="Script" path="res://core/audio/spatial_audio_player.gd" id="3_3eqhh"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cs6l2t3jtags8" path="res://assets/sounds/clock-tick-76039.mp3" id="3_6yss2"]
|
[ext_resource type="AudioStream" uid="uid://cs6l2t3jtags8" path="res://assets/sounds/clock-tick-76039.mp3" id="3_6yss2"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_h8pmj"]
|
||||||
|
resource_name = "audio"
|
||||||
|
length = 10.0
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("AnimationPlayer/Polygon2D:position")
|
||||||
|
tracks/0/interp = 2
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 1.96667, 4.46667, 6.46667, 6.76667, 7.23333, 8.13333),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(768, 328), Vector2(888, 178), Vector2(256, 208), Vector2(384, 328), Vector2(512, 336), Vector2(520, 408), Vector2(472, 408)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_i0i2l"]
|
||||||
|
length = 0.001
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ucyvg"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_i0i2l"),
|
||||||
|
"audio": SubResource("Animation_h8pmj")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_e2u3o"]
|
||||||
|
script/source = "extends AnimationPlayer
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
self.play(\"audio\")
|
||||||
|
"
|
||||||
|
|
||||||
[node name="Intro" type="Node2D"]
|
[node name="Intro" type="Node2D"]
|
||||||
script = ExtResource("1_pgj82")
|
script = ExtResource("1_pgj82")
|
||||||
|
|
||||||
|
@ -32,12 +65,22 @@ color = Color(1, 0.1, 0, 1)
|
||||||
polygon = PackedVector2Array(416, 400, 416, 424, 440, 424, 440, 400)
|
polygon = PackedVector2Array(416, 400, 416, 424, 440, 424, 440, 400)
|
||||||
color = Color(0.484431, 0.687354, 1, 1)
|
color = Color(0.484431, 0.687354, 1, 1)
|
||||||
|
|
||||||
[node name="SpatialAudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_ucyvg")
|
||||||
|
}
|
||||||
|
script = SubResource("GDScript_e2u3o")
|
||||||
|
|
||||||
|
[node name="Polygon2D" type="Polygon2D" parent="AnimationPlayer"]
|
||||||
position = Vector2(768, 328)
|
position = Vector2(768, 328)
|
||||||
|
polygon = PackedVector2Array(0, -8, -8, 0, 0, 8, 8, 0)
|
||||||
|
|
||||||
|
[node name="SpatialAudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="AnimationPlayer/Polygon2D"]
|
||||||
stream = ExtResource("3_6yss2")
|
stream = ExtResource("3_6yss2")
|
||||||
volume_db = 15.0
|
volume_db = 5.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
script = ExtResource("3_3eqhh")
|
script = ExtResource("3_3eqhh")
|
||||||
|
detect_mod = 2
|
||||||
|
|
||||||
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||||
[connection signal="body_entered" from="next_level" to="." method="_on_next_level_body_entered"]
|
[connection signal="body_entered" from="next_level" to="." method="_on_next_level_body_entered"]
|
||||||
|
|
Reference in a new issue