forked from unfa/liblast
Added pitch randomization and pitch scale to SoundPlayer.
This commit is contained in:
parent
9efb1baa18
commit
56169fb5f3
3 changed files with 10 additions and 1 deletions
|
@ -9,6 +9,7 @@ script = ExtResource( 2 )
|
|||
[node name="SoundPlayer" parent="." instance=ExtResource( 1 )]
|
||||
SoundClip = "res://Assets/SFX/Weapons-BulletFlyBy-01.wav"
|
||||
AutoPlay = true
|
||||
RandomizePitch = 0.3
|
||||
[connection signal="finished" from="SoundPlayer/AudioStreamPlayer3D" to="." method="_on_AudioStreamPlayer3D_finished"]
|
||||
|
||||
[editable path="SoundPlayer"]
|
||||
|
|
|
@ -11,6 +11,8 @@ export(bool) var AutoPlay = false
|
|||
export(float) var MinimumRandomDistance = 0.35 # gives optimal playback repetition for sound clip groups of different sizes.
|
||||
export(bool) var PlayUntilEnd = false # determines if the play() function is allowed to sop a previously started sound
|
||||
export(float) var MinDelay = 0 # determines how many seconds must pass before the sound can be triggered again
|
||||
export(float) var PitchScale = 1
|
||||
export(float) var RandomizePitch = 0
|
||||
var min_distance = 0 # this determines how ofte na sound is allowed to play (any Nth time) this is calculated automatically based on maximum_repetition
|
||||
var clips = [] # holds loaded sound stream resources
|
||||
var recently_played = [] # holds indexes of recently played
|
||||
|
@ -78,8 +80,13 @@ func play():
|
|||
|
||||
#print("recently played: ", recently_played)
|
||||
|
||||
|
||||
player.stream = clips[i]
|
||||
|
||||
if RandomizePitch != 0:
|
||||
player.pitch_scale = PitchScale + rand_range(-RandomizePitch /2, RandomizePitch/2)
|
||||
else:
|
||||
player.pitch_scale = PitchScale
|
||||
|
||||
player.play()
|
||||
|
||||
ready = false
|
||||
|
|
|
@ -61,6 +61,7 @@ SoundClip = "res://Assets/SFX/Player-Jump-01.wav"
|
|||
SoundClip = "res://Assets/SFX/Player-Step-Concrete-01.wav"
|
||||
PlayUntilEnd = true
|
||||
MinDelay = 0.2
|
||||
RandomizePitch = 0.2
|
||||
|
||||
[node name="Death" parent="Sounds" instance=ExtResource( 7 )]
|
||||
SoundClip = "res://Assets/SFX/Player-Death-01.wav"
|
||||
|
|
Loading…
Reference in a new issue