After getting a MIDI file that you are content with, edit the file using Anvil Studio to add cues for the looping. I highly recommend reading the relevant section in this guide:
https://feuniverse.us/t/music-insertion-guide-for-beginners/3791
After getting the loops right, and exported in the correct format, then place the MIDI file in sound/songs/midi with a memorable and descriptive name (i.e. mus_new_battle_music).
Now in ld_script.txt place the reference to the song at the bottom of the song_data structure. For this example, it would be sound/songs/midi/mus_new_battle_music.o(.rodata);
In songs.mk, add a line for the song. The format will be much the same as other entries. Here is my entry:
$(MID_SUBDIR)/mus_new_battle_music.s: %.s: %.mid
$(MID) $< $@ -E -R$(STD_REVERB) -G005 -V100 -P1
The things that will need to be changed are the file name, to whatever your file name is, G, to whatever voicegroup you wish to use, V, for whatever volume, and P, for whatever priority. I found that battle music will not play without a priority of 1, which is confirmed when looking at the other battle music entries. To find a voice group you like, search for the name of the instrument you used in MidiEditor. Here are a list of valid names:
https://www.pokecommunity.com/threads/148811
The instrument I used was a bright acoustic piano, and so I searched piano in the project folder (in VSCode), and found in sound/voicegroups/voicegroup005.inc a reference to piano. I used -G005 in the command, and the sound turned out pretty good.
Next, in include/constants/songs.h, add
#define MUS_NEW_BATTLE_MUSIC #
Where # is the next number after the last entry in the file. For me, the last entry in the file was 609, so my entry had 610 assigned to it.
Now, add the entry to the bottom of gSongTable in sound/song_table.inc with an entry that looks like this:
song mus_new_battle_music, 0, 0
Unfortunately, I haven't yet figured out the purpose of the two numbers following the song are yet. I just added 0's since the other battle musics used 0's as well.
The last step, which I'm not entirely sure is necessary, is to add an entry to charmap.txt
Assign MUS_NEW_BATTLE_MUSIC to the next available number, which was, in my case, F9 FF. Again, not too sure what the purpose of this is, but some other music was in the charmap, so I added it just in case.
If you used the other spoiler section, go back to the case and change the return statement depending on what you named the constant.