Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:unfa/liblast
Browse files Browse the repository at this point in the history
  • Loading branch information
CombustibleLemonade committed Apr 7, 2021
2 parents 041d1cf + 2a7d3fc commit fd1fc90
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions Game/Classes/Audio/SoundPlayer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ var ready = true # used as a semaphor for MinDelay
var voices = []
var voice = 0

var debug = false

# Called when the node enters the scene tree for the first time.
func _ready():
var files = []
var dir = Directory.new()
dir.open(SFX_dir)
dir.list_dir_begin()

print("SoundClip: ", SoundClip)
if debug:
print("SoundClip: ", SoundClip)
# determine the sound group name part
var group = SoundClip.left(SoundClip.find_last('_')).right(SoundClip.find_last('/') + 1)

Expand All @@ -39,10 +42,10 @@ func _ready():
layer = ""
else: # if the layers was specified the group will be incorrectly including the variant number, let's fix that
group = group.left(group.find_last('_'))

print("group: ", group)
print("layer: ", layer)

if debug:
print("group: ", group)
print("layer: ", layer)
while true:
var file = dir.get_next()
#print(file)
Expand All @@ -51,20 +54,24 @@ func _ready():
elif not file.begins_with(".") and file.begins_with(group) and file.ends_with(".wav"):
if layer.length() == 0: # no layer specified?
files.append(file)
print("no layer specified - adding ", file)
if debug:
print("no layer specified - adding ", file)
elif file.find(layer) > -1: # chek if the file name contains the layer string
files.append(file)
print("layer matches - adding ", file)
if debug:
print("layer matches - adding ", file)

dir.list_dir_end()

print("files in list: \n", files)
if debug:
print("files in list: \n", files)

for f in files:
var res_file = SFX_dir + f
var clip = load(res_file)
clips.append(clip)
print("loading ", res_file, "; result: ", clip)
if debug:
print("loading ", res_file, "; result: ", clip)

var clip_count = clips.size()

Expand All @@ -86,7 +93,8 @@ func _ready():
for i in get_children():
voices.append(i)

print("voices: ", voices)
if debug:
print("voices: ", voices)

if AutoPlay:
play()
Expand All @@ -100,7 +108,8 @@ sync func play():

voice = (voice + 1) % voices.size()

print("playing ", name, " on voice ", voice)
if debug:
print("playing ", name, " on voice ", voice)

if PlayUntilEnd:
if player.playing:
Expand All @@ -122,7 +131,8 @@ sync func play():
if len(recently_played) > min_distance:
recently_played.remove(0)

print("random pick: ", clips[i])
if debug:
print("random pick: ", clips[i])

player.stream = clips[i]

Expand Down

0 comments on commit fd1fc90

Please sign in to comment.