Skip to content

Commit d5f6370

Browse files
authored
Merge pull request #16 from Kylamber/master
Add support for wav files with data bytes starting from byte 100+
2 parents 96d85a7 + 5a2ecb3 commit d5f6370

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

GDScriptAudioImport.gd

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ func loadfile(filepath):
6464
#parrrrseeeeee!!! :D
6565

6666
var bits_per_sample = 0
67-
68-
for i in range(0, 100):
67+
var i = 0
68+
while true:
69+
if i >= len(bytes) - 4: # Failsafe, if there is no data bytes
70+
print("Data byte not found")
71+
break
72+
6973
var those4bytes = str(char(bytes[i])+char(bytes[i+1])+char(bytes[i+2])+char(bytes[i+3]))
7074

7175
if those4bytes == "RIFF":
@@ -136,6 +140,10 @@ func loadfile(filepath):
136140
newstream.data = convert_to_16bit(data, bits_per_sample)
137141
else:
138142
newstream.data = data
143+
144+
break # the data will be at the end, end searching here
145+
146+
i += 1
139147
# end of parsing
140148
#---------------------------
141149

0 commit comments

Comments
 (0)