BGM loop points allow music to repeat forever without breaks or seams, like real arcade games. The concept is simple: if your song schematically looks like
A B B B B ...
where A is an intro section (possibly not present), and B is a repeating section, then setting loop points at the beginning and end of B will allow B to repeat indefinitely.
Because there are many very different kinds of music file formats, there is no one way to specify loop points that is most natural for all of them. Therefore, exactly how the loop point parameters are interpreted depends on the specific plugin. For streamed audio formats like WAV, OGG, and MP3, loop points are most naturally specified in terms of samples of the audio stream. For tracker-type files like MOD or MIDI, a more natural way to specify looppoints might be in terms of measures, beats, or pattern numbers.
For streamed audio files, loop points can be identified by opening the file in an audio editor and looking for the precise point where the music repeats itself. Use your ear to get a rough location for the loop points, and fine-tune them visually by looking at the shape of the waveform at the loop start and end. If possible, you should put the loop points at a zero crossing in a quiet part of the music. If the loop end occurs exactly at the end of the file, then you can specify loopend = -1 as a shortcut. However, for lossily compressed streaming audio, it is not good practice to loop exactly at the end of the file, because audible artifacts may be produced. The best practice is to pick an internal loop, as indicated schematically in the diagram below:
A---- B---- B---- B-- ^ ^ |_____|
Another alternative is to straddle the beginning of B:
A---- B---- B---- ^ ^ |____|
Although the preceding basic description holds for all streamed audio files, the details are a bit more complicated for MP3s in particular.
MP3 files can be tricky to work with because of encoder padding. Every MP3 encoder inserts some silence at the beginning and end of your audio when you encode it. This has two deleterious effects on BGM looping: sample numbers are different from the original audio (because of the start padding), and there will be a silent gap if you try to loop at the end of the file (because of the end padding).
Encoders based on LAME support gapless encoding, meaning that they write extra metadata to the file that gives the precise start and end of the true audio data. This allows compatible decoders to trim the silent padding when playing back the file. If you don't know if your file was encoded with LAME, you can use a LAME tag reader to see if the LAME tag is present. The mpg123 decoder supports gapless playback for files with gapless info stored in the LAME tag.
Audio editors may or may not recognize the LAME tag when you open an MP3 in them. You will need to consult the documentation for your editor, or do some experimentation, to find out what it does. If your file was encoded with LAME, but your editor does not support the LAME tag, then you must manually correct sample positions by subtracting the encoder delay. (Use a LAME tag reader to find the encoder delay.)
WARNING: some editors may attempt to remove encoder padding by detecting silence, rather than by reading the LAME tag. The results of this procedure are unpredictable, so you should not use such editors to find loop points.
The following scenarios are all possible with a gapless decoder like mpg123:
With a non-gapless-capable mp3 plugin, only scenarios 4-6 are possible.