Open wrefgtzweve opened 1 day ago
Hey thanks for submitting this! I might be wrong but isn't this just cue
metadata? That's what the valve documentation seems to be describing. The example file doesn't have loops in the way the valve docs are describing, it seems to have a sampler smpl
description chunk.
Cue metadata (including timed ranges) is already provided in the module; I could look into figuring out smpl
but I'm not sure that'd help you out.
At first i thought it only used cues but then noticed it wasn't picking up all the files, then i found out loops were apparently also a thing.
For now i ended up getting chatgpt to just get me a way to find if a file has loops, figured it was worth the try and seems to work mostly fine. It does indeed seem to go for the same smpl
chunk you mentioned.
def has_loop(file_path):
"""Checks if a WAV file contains loop metadata in the smpl chunk."""
try:
with open(file_path, "rb") as f:
# Verify RIFF/WAVE file
riff_header = f.read(12)
if riff_header[:4] != b'RIFF' or riff_header[8:12] != b'WAVE':
return False
# Parse chunks
while True:
chunk_header = f.read(8)
if len(chunk_header) < 8:
break # End of file
chunk_id = chunk_header[:4].decode('ascii')
chunk_size = int.from_bytes(chunk_header[4:], byteorder='little')
if chunk_id == "smpl":
# Check for loop data in the smpl chunk
smpl_data = f.read(chunk_size)
num_loops = int.from_bytes(smpl_data[28:32], byteorder='little')
if num_loops > 0:
return True
else:
f.seek(chunk_size, 1) # Skip to the next chunk
return False
except Exception as e:
return False
Describe the type of metadata you want to read: A loop allows you to loop parts of the sound after it has played, used often in games together with cues.
List some applications that read and write this metadata: https://loopauditioneer.sourceforge.io/ A bigger list can be found here https://developer.valvesoftware.com/wiki/Looping_a_sound
List the authorities or organizations that use and standardize this metadata: https://developer.valvesoftware.com/wiki/Looping_a_sound
URL for example WAVE file with this metadata: https://archive.org/download/63468678/alarm_citizen_loop1.wav