Music Tutorial 2: Intermediate Guide

This guide presumes you have everything presented in its predecessor, namely a familiarity with how to actually insert the music as well as Anvil Studio. Additionally, I’m open to corrections on the information presented as well as suggestions for topics that I have not yet covered.

Pre-Insertion Instrumentation Previewing with Soundfonts

Through this method, we will be able to preview exactly how our music will sound ingame before we even start to insert it. We’ll accomplish this by using a few programs in conjunction to let us hear the midi as it will sound ingame.

1. VirtualMIDISynth

The program that will allow us to accomplish this first and foremost is VirtualMIDISynth. Additionally, you’ll need to grab the native instrument map soundfont .sf2 file, which can be found in the download here.

Run the VirtualMIDISynth installer and open the program to the Soundfonts tab.

VirtualMIDISynth_2019-02-08_18-59-35

Click the green + button, then navigate to the soundfont for the native instrument map. Hit Apply, and close the window; VirtualMIDISynth should be on the taskbar, where it needs to be to work. If you plan on using this often, I recommend that you set the program to automatically open at startup.

2. Anvil Studio

In order to actually hear your music using the VirtualMIDISynth device that’s using the soundfont you selected, you’ll need to set it up in your preferred MIDI editor. This guide covers how to do it in Anvil Studio, but your preferred program should also have a method to do so. With any MIDI open, click here on any track to open the following window:

mg2-2

Under the Synthesizer dropdown box, select add new synthesizer to get this window:

astudio2_2019-02-08_19-01-54

Under the <select Port the synthesizer is connected to> dropdown box, select VirtualMIDISynth #1 (you can have it act as up to 4 ports simultaneously, we only set up one port so you only get the #1 option) then give it a name and click Create a new Patch Library of type: (we want it to be General MIDI as the type and that’s the default option, so you don’t have to mess with anything there)

Now you’ll be taken back to the previous window, and if you check all 4 of the unchecked boxes at the bottom of the window now every track will use the VirtualMIDISynth device by default. Playback the MIDI and you’ll hear it in GBAFE NIMAP instruments! Note that the preview will be at a higher sample rate than ingame, so your songs will generally sound cleaner in the preview than they do ingame.

Cleaning Up Jenkiness

This will cover a few miscellaneous things, hence the more vague name. Going over a few functions of Anvil Studio to make things cleaner (once again assuming that you’re just using Anvil Studio), as well as midfix4agb.

1. Repair Song

The Repair Song function of Anvil Studio is one that is usually helpful for any midi that you didn’t make yourself from the ground up (and sometimes even ones that you did). It removes unnecessary MIDI events and generally lets you gain a little more control over the midi you’re editing. The function can be found here:

mg2

You can also run it on a per-track basis if you so desire, from the Track dropdown menu.

2. Program Changes

Say you have a MIDI where each track uses multiple instruments and switches between them regularly. In Anvil, the change instrument function is only going to let you change the very first time an instrument is set, which if the track switches to another instrument and then switches back won’t touch either. Some of the headache can be mitigated with Repair Song, since it removes instances of two or more instrument change events that change to the already set instrument (some songs, usually rips from older games, will have a program change every measure even if it stays as the same instrument. Repair song will fix this).

From this point, you have two fairly intertwined options. You can either elect to remove all program change events and set each track to always be a single instrument, or you can preserve the program change events while making them easier to manage on your end.

If you choose to do the latter, the first thing you’ll want to do is find where the instrument changes at in the track. From there, select the section that is a different instrument, right click, and select Move selection to another track and move to a new track. This moves the different instrument part of the track to somewhere that you can edit the instrument of like you would any track with a single instrument. Repeat this process for every instrument change in the track; remember to keep times it goes back to the initial instrument on that same track and to move instances of the same instrument to the same track to cut down on the number of tracks you’ll have.

Now comes the part you would do for both of your options. Go to ViewEvent List to open the event list, select the track you moved all the parts off of from the dropdown box at the top, and press Delete Events…. From here, check the Program Change box and hit OK. This will remove all instances of instruments changing on the track, including it being set initially, so you’ll have to set the track’s instrument again, however it will no longer change throughout the track. Repeat this process for all of the tracks you made from moving off different instrument sections of the original track. Now you can edit them all separately!

But what if you want to put in a program change yourself? This is even easier than taking them out. All you have to do is place the cursor where you want it to occur, go to EditInsert MIDI Event, check the Include all controller events box, then select Program Change from the dropdown box just above (it should be located above the default option). Now the bottom half of the window has changed to an event-specific option for program change, allowing you to select the instrument you want to change to. Change it as desired and press OK to insert the program change. To remove it, you can locate it on the event list and remove it manually or you can remove all program change events as was outlined previously.

Occasionally a program change event you added doesn’t seem to have an effect until a note or so after where you inserted it. This is because Anvil will round the cursor location slightly when deciding the timecode that the event will insert at. To circumvent this, you just need to set the time manually. One of the boxes in the Insert MIDI Event window we didn’t touch previously is the Time of box at the top. This is the timecode the event is inserted at. To get the timecode that you want to insert it at, find the first note you want to play as a different instrument and double-click on it. This will open Note Properties for that note. Listed under Note's Start Time is a timecode just like the one in the Insert MIDI Event window! Copy it, go back to inserting the program change event, and paste it into the Time of box. Now your program change will happen exactly with that note! It’s generally good practice to do this every time you insert a program change event, even if it wouldn’t otherwise be necessary.

midfix4agb

So you have a song and when you insert it it sounds like a loud siren where the midi sounds like a pitch bend. For a number of technical reasons (mostly outlined here), pitch bends need to have their effect lowered drastically when putting them through mid2agb. Fortunately this can be done, among other things, with midfix4agb. Just drop your midi file on it, and you’ll get a version of it that will sound much nicer ingame (If it’s still giving you issues, try running it through midfix4agb repeatedly to dilute the effects causing problems).

You can get midfix4agb here:

Automating MIDI to EA .event File

Utilities used for converting your MIDI to an EA installer for your buildfile cannot process more than one file at a time; therefore, you would need to run each MIDI through both mid2agb and s2ea every time you make a change to it. I found this to be somewhat antithetical to the purpose of a make hack script that runs all external programs and then EA, so I wrote a cmd script to automatically convert every .mid file into a .s file into a .event file. Put the script in the root of your buildfile, put your MIDIs in the subfolder Music, and put both mid2agb and s2ea in the same folder. You can run it from within your make hack full script if you so desire, though I would recommend keeping it a separate file if you do so and just running the cmd from within your make hack full cmd.

cmd Script

@cd %~dp0

@cd "%~dp0Music"

@echo Converting MIDIs...

@dir *.mid /b > mid.txt

@for /f "tokens=*" %%m in (mid.txt) do mid2agb %%m -V075

@echo Done!

@echo Converting to events...

@dir *.s /b > sappy.txt

@for /f "tokens=*" %%s in (sappy.txt) do s2ea %%s

@echo Done!

@echo Cleaning Up...

@del "mid.txt"

@del "sappy.txt"

@echo Done!

pause

21 Likes

Wew thumbs up. Imma try this out right away.

1 Like

Kermalis’s GBA Music Studio

GBA Music Studio is a music player and visualizer for both the common m4a sound engine, as well as others found in GBA games.

VG Music Studio is an alternative to Sappy that actually works and unlike VGMTrans can rip midis from GBA games other than ones that use the m4a engine, as long as they are compatible. The preview release linked above is a slightly outdated build; however, it will still function with GBA games properly.
By default, the only GBA Fire Emblem game it is compatible with is FE7, but with an incredibly simple edit to Games.yaml compatibility with FE8 can be added. Simply open it in a text editor and paste in the following:

BE8E:
Name: “Fire Emblem: The Sacred Stones (USA)”
Creator: “Intelligent Systems”
SongTable: 0x224470
SongTableSize: 1000

Once this has been added, loading any FE8U ROM or hack (assuming the hack doesn’t repoint the song table) will work properly. You can then preview how your music will sound ingame with a high level of accuracy. Since this was originally written, an update to the program has added in all Fire Emblem games by default, and as such, this section is no longer necessary.

Ripping MIDIs

Ripping MIDIs from any game is incredibly simple using this program, assuming the game is compatible (Games.yaml is also a list of all compatible games). Just open the ROM, then in the Data menu along the top click Export song to MIDI, and that’s all you have to do. This method is compatible with games that are not compatible with something like GBA Mus Riper or VGMTrans, so it can be used to get midis of songs those programs cannot, such as GBA Metroid games or The Legend of Zelda: The Minish Cap.
Note that although you can rip directly to a .s file, the method by which the program does so is very inefficient and as such ripping as midi and using mid2agb will give you a more reasonably sized file.

6 Likes

Export to asm is better actually. At least for FEBuilder users, because you get the .s file directly.

The problem with export to asm is that it reimports as humongous compared to the source rom, because that function is (or at least was at the time of the release) a work in progress; therefore, going midi to s is going to give you a smaller size file of effectively the same quality

VGMTrans is compatible with most mainstream console/handheld formats btw

You can still use program changes in your song with the free version of Anvil with no problems. In the preferences, there’s an unassigned “insert program change” hotkey that you can set. You just have to change them manually in the event list instead of selecting the track’s instrument because Anvil will yell at you to buy accessories, though. I also recommend setting a hotkey for “insert midi event”, since you can have dynamic volume and panning by inserting/editing events in the same way you can program changes.

I’ll probably edit this post with some more “work smarter not harder”-flavoured tips and tricks later.

edit: in the interest of having everything preserved on the forums, here are some settings I prefer for Anvil Studio:
· Ctrl+V: Paste insert
· Ctrl+B: Paste mix
· Ctrl+N: Paste special (allows you to choose whether to keep events, paste notes only, or events only)
· Ctrl+D: Insert MIDI event (allows you to insert pitch bends, panning, modulation, etc, without Anvil Studio yelling at you to buy accessories)
· Ctrl+S: Save (this is binded to recording by default. literally why?)
· Ctrl+L: Note properties (opens the box that lets you choose note volume/length on the fly)
· Ctrl+P: Insert program change (this changes the instrument in the middle of the track. Note that Anvil counts on a basis of 1-128 here)
· Ctrl+9: Shorten note(s)
· Ctrl+0: Lengthen note(s)

Additional settings of interest:
· “All volumes range from 0 to 127”: this will show you the actual volume of notes instead of simplifying it to 0%-100%
· “Refer to middle C as C4”: in GBA terminology, middle C is C3, but by default in Anvil it’s C5. This is at least closer to our expected norm and it’s easier to transpose in your head.
· “Display diamond on staff for program changes”: useful if you have a song where the instruments change willy-nilly all the time

Finally, if there are events lurking in your song that you wish to delete, e.g. you want to get rid of one program change but you don’t want to remove all program changes from the track when Anvil asks if you want to do so, you can always go to “View ->Event list” to look at the events of the song wherever your cursor is and find the ProgramChange event yourself. Double-click it to change its parameters or delete it. If there’s a mess of events all over the place (e.g. a bunch of unwanted modulation events), you can just copy the notes, use “paste special” to paste only the notes and not the events to a new track, and delete the old track.

3 Likes

Yeah I touched on VGMTrans in my other guide tbh I really should’ve kept them as one thread to cut down on confusion, but it’s not compatible with, say, Metroid Fusion, while this one is.

This may sound stupid, but If wanted to use another soundfont (for example, FF6 or FFTA) would I just need to plug the .sf2 file into Virtualmidi instead of the GBAFE soundfont?

How would I load the sound map into my romhack though? Like I’ve imported songs from other gba games using FEBuilder and it’s loaded the soundfont too, but how would I do that for a piece I made myself?

If you want to use a different soundfont, load the different soundfont into VirtualMIDISynth. If you need song tables in the form of soundfonts, many tools, VG Music Studio included, can export sound tables as .sf2 files.

FEBuilderGBA has the native instrument map as a patch entitled SOUND_NIMAP2(Native Instrument Map). Install this and it becomes an option when importing songs.

1 Like

Dude, I know I’m replying to an old comment, but i must say it’s good to have this, thanks for the tuto too!

1 Like

New question, old topic. I can’t get the drums in my soundfont to work with VirtualMIDISynth - is this a known issue, something wrong with my soundfont, or none of the above?

1 Like

Pretty sure I’ve had the same issue. Try changing the MIDI channel of your drum track(s) to a value other than 10.

I think that when the channel is 10, VirtualMIDISynth (or the MIDI program in question, I’m not really sure) assumes the instrument bank is bank 127 instead of bank 0 (where your drumset likely is, if you’re having this issue). If the drumset “instrument” isn’t in bank 127, it doesn’t play anything. Of course, this means you could just have a copy of your drumset(s) in bank 127 of your soundfont, if you absolutely must have your drums in MIDI channel 10.

Hope this helps you out!