# How is loop information encoded in FLAC files?

I'm trying to convert .wav files (samples for a sampled instrument) into FLAC format. The .wav files have loop information in the smpl chunk. I understand that various sample players support loops in FLAC files. However, I can't find a converter that converts .wav to .flac and preserves the loop information. I could code it myself (say, by postprocessing results from SoX), but can't find any information on how loops are encoded in FLAC files.

I'm using this for sampled instruments with hundreds of .wav files and so need to be able to do batch processing.

Sorry if this is the wrong forum. It's not quite stackoverflow or sounddesign.

• The information is in the flac file format specifications. Look up seekpoints or cues based on what suits better for your purpose. Apr 24, 2020 at 4:59

The simple answer is, "the same way it's kept in .wav files." FLAC uses the same RIFF "chunk" structure as WAV. The WAV file format has a chunk for use by samplers, which includes looping information. I found I could simply copy that chunk from the WAV file and append it to the FLAC file and it worked (for anything that supported loops in FLAC files, which isn't everything -- for example linuxsampler does not, due to a library it uses not supporting it yet.)

Better yet, the flac application has a --keep-foreign-metadata option that does the trick without my having to code anything.