Implemented wind noise played when players move fast
It's modulated with volume and a resonant lowpass filter all mapped using curves to produce pleasing resultsfeature-rocketlauncher
parent
bceafb74da
commit
f68b72c840
|
@ -0,0 +1,36 @@
|
||||||
|
extends AudioStreamPlayer
|
||||||
|
|
||||||
|
#@export var minimum_speed: float
|
||||||
|
#@export var minimum_speed_hysteresis: float
|
||||||
|
#@export var maximum_speed: float
|
||||||
|
@export var speed_to_volume: Curve
|
||||||
|
@export var speed_to_cutoff: Curve
|
||||||
|
|
||||||
|
# for mapping the curves
|
||||||
|
@export var max_speed: float = 50.0
|
||||||
|
|
||||||
|
# for pausing playback to save resources and avoid quiet hum all the time
|
||||||
|
@export var min_speed: float = 5.0
|
||||||
|
@export var min_speed_hysteresis: float = 0.5
|
||||||
|
|
||||||
|
@onready var audio_bus = AudioServer.get_bus_index("WindSFX")
|
||||||
|
@onready var audio_filter : AudioEffectFilter = AudioServer.get_bus_effect(audio_bus,1)
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
speed_to_volume.bake()
|
||||||
|
speed_to_cutoff.bake()
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
var speed = get_parent().get_parent().motion_velocity.length()
|
||||||
|
print("speed: ", speed)
|
||||||
|
|
||||||
|
if speed > min_speed + min_speed_hysteresis / 2:
|
||||||
|
stream_paused = false
|
||||||
|
elif speed < min_speed - min_speed_hysteresis / 2:
|
||||||
|
stream_paused = true
|
||||||
|
|
||||||
|
volume_db = speed_to_volume.interpolate_baked(speed / max_speed)
|
||||||
|
print(volume_db)
|
||||||
|
|
||||||
|
audio_filter.cutoff_hz = speed_to_cutoff.interpolate_baked(speed / max_speed) * 10 # cnvert to 0-1 kHz range
|
||||||
|
print(audio_filter.cutoff_hz)
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_scene load_steps=40 format=3 uid="uid://cwuys43c7ak61"]
|
[gd_scene load_steps=44 format=3 uid="uid://cwuys43c7ak61"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Assets/Characters/Player.gd" id="1"]
|
[ext_resource type="Script" path="res://Assets/Characters/Player.gd" id="1"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://gbs6q7vx33ni" path="res://Assets/SFX/WhiteNoise.ogg" id="2_76pkp"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bemrov0tiy08n" path="res://Assets/Weapons/Weapon.tscn" id="3"]
|
[ext_resource type="PackedScene" uid="uid://bemrov0tiy08n" path="res://Assets/Weapons/Weapon.tscn" id="3"]
|
||||||
|
[ext_resource type="Script" path="res://Assets/Audio/WindSFX.gd" id="3_7t4ny"]
|
||||||
[ext_resource type="Texture2D" uid="uid://pnh872qjk0oy" path="res://Assets/Effects/Flame.png" id="3_jw7jd"]
|
[ext_resource type="Texture2D" uid="uid://pnh872qjk0oy" path="res://Assets/Effects/Flame.png" id="3_jw7jd"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bmjh522fpxeee" path="res://Assets/SFX/Player_Jetpack.wav" id="4_k24if"]
|
[ext_resource type="AudioStream" uid="uid://bmjh522fpxeee" path="res://Assets/SFX/Player_Jetpack.wav" id="4_k24if"]
|
||||||
[ext_resource type="AudioStream" uid="uid://3kb1cqt6lcaq" path="res://Assets/SFX/Player_Spawn.wav" id="5_bmajs"]
|
[ext_resource type="AudioStream" uid="uid://3kb1cqt6lcaq" path="res://Assets/SFX/Player_Spawn.wav" id="5_bmajs"]
|
||||||
|
@ -26,6 +28,15 @@ material = SubResource( "4" )
|
||||||
radius = 0.4
|
radius = 0.4
|
||||||
height = 1.7
|
height = 1.7
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id="Curve_drgxy"]
|
||||||
|
min_value = -80.0
|
||||||
|
max_value = 0.0
|
||||||
|
_data = [Vector2(0, -80), 0.0, 102.109, 0, 0, Vector2(1, 0), 2.1708, 0.0, 0, 0]
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id="Curve_mmscc"]
|
||||||
|
max_value = 100.0
|
||||||
|
_data = [Vector2(0, 28.1818), 0.0, 6.633, 0, 1, Vector2(0.274112, 30), 6.633, 0.0, 1, 0, Vector2(1, 70.9091), 0.0, 0.0, 0, 0]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="2"]
|
[sub_resource type="CapsuleShape3D" id="2"]
|
||||||
radius = 0.4
|
radius = 0.4
|
||||||
height = 1.7
|
height = 1.7
|
||||||
|
@ -238,6 +249,15 @@ mesh = SubResource( "1" )
|
||||||
[node name="Head" type="Node3D" parent="."]
|
[node name="Head" type="Node3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.45276, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.45276, 0)
|
||||||
|
|
||||||
|
[node name="WindSFX" type="AudioStreamPlayer" parent="Head"]
|
||||||
|
stream = ExtResource( "2_76pkp" )
|
||||||
|
volume_db = -50.0
|
||||||
|
autoplay = true
|
||||||
|
bus = &"WindSFX"
|
||||||
|
script = ExtResource( "3_7t4ny" )
|
||||||
|
speed_to_volume = SubResource( "Curve_drgxy" )
|
||||||
|
speed_to_cutoff = SubResource( "Curve_mmscc" )
|
||||||
|
|
||||||
[node name="Camera" type="Camera3D" parent="Head"]
|
[node name="Camera" type="Camera3D" parent="Head"]
|
||||||
fov = 90.0
|
fov = 90.0
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,16 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOGGVorbis"
|
||||||
|
uid="uid://gbs6q7vx33ni"
|
||||||
|
path="res://.godot/imported/WhiteNoise.ogg-6280e93b7b1c9263391e422d5cccc729.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/SFX/WhiteNoise.ogg"
|
||||||
|
dest_files=["res://.godot/imported/WhiteNoise.ogg-6280e93b7b1c9263391e422d5cccc729.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=true
|
||||||
|
loop_offset=0
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_resource type="AudioBusLayout" load_steps=7 format=3 uid="uid://bo2748emkln7r"]
|
[gd_resource type="AudioBusLayout" load_steps=9 format=3 uid="uid://elfmay4cs52a"]
|
||||||
|
|
||||||
[sub_resource type="AudioEffectLimiter" id="AudioEffectLimiter_34kb8"]
|
[sub_resource type="AudioEffectLimiter" id="AudioEffectLimiter_34kb8"]
|
||||||
resource_name = "Limiter"
|
resource_name = "Limiter"
|
||||||
|
@ -40,6 +40,24 @@ room_size = 0.29
|
||||||
damping = 0.25
|
damping = 0.25
|
||||||
wet = 0.35
|
wet = 0.35
|
||||||
|
|
||||||
|
[sub_resource type="AudioEffectChorus" id="AudioEffectChorus_tfjpx"]
|
||||||
|
resource_name = "Chorus"
|
||||||
|
dry = 0.12
|
||||||
|
wet = 0.37
|
||||||
|
voice/1/delay_ms = 25.0
|
||||||
|
voice/1/rate_hz = 0.5
|
||||||
|
voice/1/depth_ms = 3.0
|
||||||
|
voice/1/pan = -1.0
|
||||||
|
voice/2/delay_ms = 50.0
|
||||||
|
voice/2/rate_hz = 0.8
|
||||||
|
voice/2/depth_ms = 3.01
|
||||||
|
voice/2/pan = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="AudioEffectLowPassFilter" id="AudioEffectLowPassFilter_x2q3c"]
|
||||||
|
resource_name = "LowPassFilter"
|
||||||
|
cutoff_hz = 1000.0
|
||||||
|
resonance = 1.0
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
bus/0/effect/0/effect = SubResource( "AudioEffectLimiter_34kb8" )
|
bus/0/effect/0/effect = SubResource( "AudioEffectLimiter_34kb8" )
|
||||||
bus/0/effect/0/enabled = true
|
bus/0/effect/0/enabled = true
|
||||||
|
@ -77,3 +95,13 @@ bus/4/volume_db = -0.923751
|
||||||
bus/4/send = &"Reverb"
|
bus/4/send = &"Reverb"
|
||||||
bus/4/effect/0/effect = SubResource( "AudioEffectReverb_kj6q8" )
|
bus/4/effect/0/effect = SubResource( "AudioEffectReverb_kj6q8" )
|
||||||
bus/4/effect/0/enabled = true
|
bus/4/effect/0/enabled = true
|
||||||
|
bus/5/name = &"WindSFX"
|
||||||
|
bus/5/solo = false
|
||||||
|
bus/5/mute = false
|
||||||
|
bus/5/bypass_fx = false
|
||||||
|
bus/5/volume_db = 0.0
|
||||||
|
bus/5/send = &"Master"
|
||||||
|
bus/5/effect/0/effect = SubResource( "AudioEffectChorus_tfjpx" )
|
||||||
|
bus/5/effect/0/enabled = true
|
||||||
|
bus/5/effect/1/effect = SubResource( "AudioEffectLowPassFilter_x2q3c" )
|
||||||
|
bus/5/effect/1/enabled = true
|
||||||
|
|
Reference in New Issue